zxl
16 小时以前 dd77ff32e2618ee64f5c9447279d04e46874af59
framework/src/main/resources/mapper/lmk/VideoMapper.xml
@@ -17,6 +17,7 @@
        <result column="play_num" property="playNum" />
        <result column="collect_num" property="collectNum" />
        <result column="comment_num" property="commentNum" />
        <result column="thumbs_up_num" property="thumbsUpNum" />
        <result column="weight" property="weight" />
        <result column="audit_pass_time" property="auditPassTime" />
        <result column="update_time" property="updateTime" />
@@ -25,6 +26,7 @@
        <result column="video_imgs" property="videoImgs" />
        <collection property="goodsList" column="id" select="getVideoGoods" ofType="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO"/>
    </resultMap>
    <resultMap id="VideoGoodsMap" type="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO">
        <result column="goods_id" property="goodsId"/>
@@ -46,7 +48,7 @@
               LG.price
        FROM
             lmk_video_goods LVG
             INNER JOIN li_goods LG ON LVG.goods_id = LG.id AND LG.market_enable = 'UPPER' AND LG.delete_flag = 0
             INNER JOIN li_goods_sku LG ON LVG.goods_sku_id = LG.id AND LG.market_enable = 'UPPER' AND LG.delete_flag = 0
        WHERE
             LVG.video_id = #{id} AND LVG.delete_flag = 0
        ORDER BY
@@ -70,6 +72,7 @@
        <result column="play_num" property="playNum" />
        <result column="collect_num" property="collectNum" />
        <result column="comment_num" property="commentNum" />
        <result column="thumbs_up_num" property="thumbsUpNum" />
        <result column="weight" property="weight" />
        <result column="audit_pass_time" property="auditPassTime" />
        <result column="update_time" property="updateTime" />
@@ -91,6 +94,7 @@
        <result column="title" property="title" />
        <result column="collect_num" property="collectNum" />
        <result column="comment_num" property="commentNum" />
        <result column="thumbs_up_num" property="thumbsUpNum" />
        <result column="status" property="status" />
        <result column="video_content_type" property="videoContentType" />
        <result column="video_type" property="videoType" />
@@ -98,6 +102,29 @@
        <collection property="goodsList" column="id" select="getVideoGoods" ofType="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO"/>
    </resultMap>
    <!-- 播放历史 -->
    <resultMap id="HistoryMap" type="cn.lili.modules.lmk.domain.vo.VideoHistoryVO">
        <id column="id" property="id"/>
        <result column="author_id" property="authorId" />
        <result column="authorName" property="authorName" />
        <result column="authorAvatar" property="authorAvatar" />
        <result column="cover_url" property="coverFileKey" />
        <result column="video_file_key" property="videoFileKey" />
        <result column="video_fit" property="videoFit" />
        <result column="video_duration" property="videoDuration" />
        <result column="title" property="title" />
        <result column="collect_num" property="collectNum" />
        <result column="comment_num" property="commentNum" />
        <result column="thumbs_up_num" property="thumbsUpNum" />
        <result column="status" property="status" />
        <result column="video_content_type" property="videoContentType" />
        <result column="video_type" property="videoType" />
        <result column="video_imgs" property="videoImgs" />
        <result column="historyId" property="historyId" />
        <result column="play_at" property="playAt" />
        <result column="playTime" property="playTime" />
        <collection property="goodsList" column="id" select="getVideoGoods" ofType="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO"/>
    </resultMap>
    <select id="getById" resultMap="BaseResultMap">
        SELECT
@@ -114,6 +141,7 @@
            LV.play_num,
            LV.collect_num,
            LV.comment_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
@@ -145,6 +173,7 @@
            LV.play_num,
            LV.collect_num,
            LV.comment_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
@@ -176,6 +205,7 @@
            LV.play_num,
            LV.collect_num,
            LV.comment_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
@@ -218,6 +248,7 @@
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
@@ -236,6 +267,132 @@
        ORDER BY
            LV.create_time DESC
    </select>
    <select id="recommendVideoList" resultMap="WxResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.create_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName,
            LM.face as authorAvatar
        FROM
            lmk_video LV
            LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.delete_flag = 0 AND LV.status = '1' AND LV.video_type = #{query.videoType}
        ORDER BY
            LV.create_time DESC
    </select>
    <select id="goodsSimilarlyPage" resultMap="WxResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.create_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            CASE
                WHEN LM.nick_name IS NOT NULL THEN LM.nick_name
                WHEN LM.nick_name IS NULL THEN (SELECT nick_name FROM li_admin_user WHERE id = LV.author_id)
                ELSE ''
            END as authorName,
            CASE
                WHEN LM.face IS NOT NULL THEN LM.face
                WHEN LM.face IS NULL THEN (SELECT avatar FROM li_admin_user WHERE id = LV.author_id)
                ELSE ''
            END as authorAvatar
        FROM
            lmk_video LV
                INNER JOIN lmk_video_goods LVG ON LVG.video_id = LV.id AND LVG.goods_id in <foreach collection="query.goodsIds" open="(" item="goodsId" close=")" separator=",">#{goodsId}</foreach>
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.delete_flag = 0 AND LV.status = '1' AND LV.id != #{query.currentVideoId}
        ORDER BY
            LV.create_time DESC
    </select>
    <select id="getHistoryPage" resultMap="HistoryMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.create_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            CASE
                WHEN LM.nick_name IS NOT NULL THEN LM.nick_name
                WHEN LM.nick_name IS NULL THEN (SELECT nick_name FROM li_admin_user WHERE id = LV.author_id)
                ELSE ''
            END as authorName,
            CASE
                WHEN LM.face IS NOT NULL THEN LM.face
                WHEN LM.face IS NULL THEN (SELECT avatar FROM li_admin_user WHERE id = LV.author_id)
                ELSE ''
            END as authorAvatar,
            LFP.id as historyId,
            LFP.play_at,
            LFP.update_time as playTime
        FROM
            li_foot_print LFP
                INNER JOIN lmk_video LV ON LFP.ref_id = LV.id AND LFP.view_type = 'video' AND LFP.delete_flag = 0 AND LFP.member_id = #{query.userId}
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.delete_flag = 0 AND LV.status = '1'
        ORDER BY
            LFP.update_time DESC
    </select>
    <select id="recommendHealthVideo" resultMap="WxResultMap">
        SELECT
            LV.author_id,
@@ -251,6 +408,7 @@
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
@@ -283,6 +441,7 @@
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
@@ -326,6 +485,20 @@
            WHEN #{video.id} THEN #{video.countNum}
        </foreach>
        ELSE comment_num
        END
        WHERE id IN
        <foreach collection="list" item="video" open="(" separator="," close=")">
            #{video.id}
        </foreach>
    </update>
    <update id="updateThumbsUpNumBatch">
        UPDATE lmk_video
        SET thumbs_up_num = CASE id
        <foreach collection="list" item="video">
            WHEN #{video.id} THEN #{video.countNum}
        </foreach>
        ELSE thumbs_up_num
        END
        WHERE id IN
        <foreach collection="list" item="video" open="(" separator="," close=")">
@@ -378,6 +551,7 @@
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
@@ -416,6 +590,7 @@
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
@@ -431,6 +606,41 @@
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LMC.delete_flag = 0 AND LMC.user_id = #{query.authorId} AND LMC.collect_type = 'video' AND LV.video_type = #{query.videoType}
        ORDER BY
            LMC.create_time DESC
    </select>
    <select id="getAuthorLikeVideoPage" resultMap="WxResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName,
            LM.face as authorAvatar
        FROM
            lmk_thumbs_up_record LMC
                INNER JOIN lmk_video LV ON LMC.ref_id = LV.id AND LV.delete_flag = 0 AND LV.status = '1'
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LMC.delete_flag = 0 AND LMC.user_id = #{query.authorId} AND LMC.thumbs_up_type = 'video' AND LV.video_type = #{query.videoType}
        ORDER BY
            LMC.create_time DESC
    </select>
@@ -479,6 +689,7 @@
        LV.play_num,
        LV.collect_num,
        LV.comment_num,
        LV.thumbs_up_num,
        LV.weight,
        LV.audit_pass_time,
        LV.update_time,
@@ -520,6 +731,7 @@
        LV.play_num,
        LV.collect_num,
        LV.comment_num,
        LV.thumbs_up_num,
        LV.weight,
        LV.audit_pass_time,
        LV.update_time,
@@ -546,6 +758,109 @@
        <if test="query.status != null and query.status != ''">AND LV.status = #{query.status}</if>
    </select>
    <resultMap id="videoFootMap" type="cn.lili.modules.lmk.domain.vo.VideoFootVO">
        <id column="id" property="id"/>
        <result column="author_id" property="authorId" />
        <result column="authorName" property="authorName" />
        <result column="cover_url" property="coverUrl" />
        <result column="video_file_key" property="videoFileKey" />
        <result column="video_fit" property="videoFit" />
        <result column="title" property="title" />
        <result column="video_duration" property="videoDuration" />
        <result column="recommend" property="recommend" />
        <result column="status" property="status" />
        <result column="play_num" property="playNum" />
        <result column="collect_num" property="collectNum" />
        <result column="comment_num" property="commentNum" />
        <result column="weight" property="weight" />
        <result column="audit_pass_time" property="auditPassTime" />
        <result column="update_time" property="updateTime" />
        <result column="video_content_type" property="videoContentType" />
        <result column="video_type" property="videoType" />
        <result column="video_imgs" property="videoImgs" />
        <result column="view_duration" property="viewDuration"/>
        <result column="play_at" property="playAt"/>
        <collection property="goodsList" column="id" select="getVideoGoods" ofType="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO"/>
        <collection property="tagList" column="id" select="getVideoTags" ofType="cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO"/>
    </resultMap>
    <select id="videoFootPage" resultMap="videoFootMap">
        SELECT
            LFP.view_duration,
            LFP.play_at,
            LV.*
        from
            li_foot_print LFP
                INNER JOIN lmk_video LV
                          ON LFP.ref_id = lV.id AND LV.delete_flag = 0
        where LFP.member_id = #{query.memberId}
          AND LFP.ref_id IS NOT NULL
          AND LFP.delete_flag = 0
          AND LFP.view_type = 'video'
    </select>
    <select id="videoFoot" resultMap="videoFootMap">
        SELECT
            LFP.view_duration,
            LFP.play_at,
            LV.*
        from
            li_foot_print LFP
                INNER JOIN lmk_video LV
                           ON LFP.ref_id = lV.id AND LV.delete_flag = 0
        where LFP.member_id = #{query.memberId}
          AND LFP.ref_id IS NOT NULL
          AND LFP.delete_flag = 0
          AND LFP.view_type = 'video'
    </select>
    <resultMap id="videoFootInfo" type="cn.lili.modules.lmk.domain.vo.VideoFootInfoVo">
        <result column="total_duration" property="totalDuration"/>
        <result column="video_count" property="videoCount"/>
        <result column="avg_completion_rate" property="avgCompletionRate"/>
    </resultMap>
    <resultMap id="videoTagMap" type="cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO">
        <id property="id" column="id"/>
        <result property="tagName" column="tag_name"/>
    </resultMap>
<!--    <select id="getVideoTags" parameterType="String" resultMap="videoTagMap">-->
<!--        SELECT LVT.id,-->
<!--               LVT.tag_name-->
<!--        from lmk_video_tag_ref LVTR-->
<!--                 LEFT JOIN lmk_video_tag LVT ON LVT.id = LVTR.video_tag_id  and LVT.delete_flag = 0-->
<!--        WHERE LVTR.video_id = #{id}-->
<!--    </select>-->
    <select id="getVideoFootInfo" resultMap="videoFootInfo">
        SELECT
            SUM(LFP.view_duration) AS total_duration,
            ROUND(AVG(CASE
                          WHEN LV.video_duration > 0 THEN LFP.play_at / LV.video_duration
                          ELSE 0
                END),2) AS avg_completion_rate,
            COUNT(*) AS video_count
        from
            li_foot_print LFP
                INNER JOIN lmk_video LV
                          ON LFP.ref_id = lV.id AND LV.delete_flag = 0
        where LFP.member_id = #{id}
          AND LFP.ref_id IS NOT NULL
          AND LFP.delete_flag = 0
          AND LFP.view_type = 'video'
          AND LV.id IS NOT NULL
        GROUP BY
            LFP.member_id
    </select>
    <resultMap id="EsResultMap" type="cn.lili.modules.lmk.domain.es.VideoIndex">
        <id column="id" property="id"/>
        <result column="author_id" property="authorId" />
@@ -558,9 +873,13 @@
        <result column="title" property="title" />
        <result column="status" property="status" />
        <result column="recommend" property="recommend" />
        <result column="audit_pass_time" property="publishTime" />
        <result column="video_content_type" property="videoContentType" />
        <result column="video_type" property="videoType" />
        <result column="video_imgs" property="videoImgs" />
        <result column="collect_num" property="collectNum" />
        <result column="thumbs_up_num" property="thumbsUpNum" />
        <result column="comment_num" property="commentNum" />
        <collection property="goodsList" column="id" select="getVideoGoods" ofType="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO"/>
        <collection property="tagList" column="id" select="getVideoTags" ofType="cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO"/>
    </resultMap>
@@ -591,16 +910,28 @@
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            CASE
                WHEN LV.audit_pass_time IS NOT NULL THEN LV.audit_pass_time
                ELSE LV.create_time
            END as audit_pass_time,
            LV.update_time,
            LV.create_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName,
            LM.face as authorAvatar
            CASE
                WHEN LM.nick_name IS NOT NULL THEN LM.nick_name
                WHEN LM.nick_name IS NULL THEN (SELECT nick_name FROM li_admin_user WHERE id = LV.author_id)
                ELSE ''
            END as authorName,
            CASE
                WHEN LM.face IS NOT NULL THEN LM.face
                WHEN LM.face IS NULL THEN (SELECT avatar FROM li_admin_user WHERE id = LV.author_id)
                ELSE ''
                END as authorAvatar
        FROM
            lmk_video LV
                LEFT JOIN li_member LM ON LV.author_id = LM.id