|
|
@@ -0,0 +1,203 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
+<mapper namespace="com.fs.life.mapper.FsLifeVideoMapper">
|
|
|
+
|
|
|
+ <resultMap id="FsLifeVideoResult" type="com.fs.life.domain.FsLifeVideo">
|
|
|
+ <result property="videoId" column="video_id"/>
|
|
|
+ <result property="vestId" column="vest_id"/>
|
|
|
+ <result property="title" column="title"/>
|
|
|
+ <result property="fileName" column="file_name"/>
|
|
|
+ <result property="coverUrl" column="cover_url"/>
|
|
|
+ <result property="videoUrl" column="video_url"/>
|
|
|
+ <result property="duration" column="duration"/>
|
|
|
+ <result property="isShow" column="is_show"/>
|
|
|
+ <result property="isHot" column="is_hot"/>
|
|
|
+ <result property="views" column="views"/>
|
|
|
+ <result property="likes" column="likes"/>
|
|
|
+ <result property="favoriteNum" column="favorite_num"/>
|
|
|
+ <result property="shareNum" column="share_num"/>
|
|
|
+ <result property="isDel" column="is_del"/>
|
|
|
+ <result property="shelfTime" column="shelf_time"/>
|
|
|
+ <result property="createBy" column="create_by"/>
|
|
|
+ <result property="createTime" column="create_time"/>
|
|
|
+ <result property="updateBy" column="update_by"/>
|
|
|
+ <result property="updateTime" column="update_time"/>
|
|
|
+ <result property="remark" column="remark"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <resultMap id="LifeVideoCardResult" type="com.fs.life.vo.LifeVideoCardVO">
|
|
|
+ <result property="videoId" column="video_id"/>
|
|
|
+ <result property="vestId" column="vest_id"/>
|
|
|
+ <result property="title" column="title"/>
|
|
|
+ <result property="coverUrl" column="cover_url"/>
|
|
|
+ <result property="videoUrl" column="video_url"/>
|
|
|
+ <result property="duration" column="duration"/>
|
|
|
+ <result property="views" column="views"/>
|
|
|
+ <result property="likes" column="likes"/>
|
|
|
+ <result property="favoriteNum" column="favorite_num"/>
|
|
|
+ <result property="shareNum" column="share_num"/>
|
|
|
+ <result property="isHot" column="is_hot"/>
|
|
|
+ <result property="shelfTime" column="shelf_time"/>
|
|
|
+ <result property="vestNickName" column="vest_nick_name"/>
|
|
|
+ <result property="vestAvatar" column="vest_avatar"/>
|
|
|
+ <result property="liked" column="liked"/>
|
|
|
+ <result property="favorited" column="favorited"/>
|
|
|
+ <result property="productCount" column="product_count"/>
|
|
|
+ <result property="minPrice" column="min_price"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectVo">
|
|
|
+ select video_id, vest_id, title, file_name, cover_url, video_url, duration, is_show, is_hot,
|
|
|
+ views, likes, favorite_num, share_num, is_del, shelf_time,
|
|
|
+ create_by, create_time, update_by, update_time, remark
|
|
|
+ from fs_life_video
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectFsLifeVideoById" resultMap="FsLifeVideoResult">
|
|
|
+ <include refid="selectVo"/>
|
|
|
+ where video_id = #{videoId} and is_del = 0
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectFsLifeVideoList" resultMap="FsLifeVideoResult">
|
|
|
+ <include refid="selectVo"/>
|
|
|
+ where is_del = 0
|
|
|
+ <if test="vestId != null">and vest_id = #{vestId}</if>
|
|
|
+ <if test="isShow != null">and is_show = #{isShow}</if>
|
|
|
+ <if test="isHot != null">and is_hot = #{isHot}</if>
|
|
|
+ <if test="keyword != null and keyword != ''">
|
|
|
+ and (title like concat('%', #{keyword}, '%')
|
|
|
+ or cast(video_id as char) like concat('%', #{keyword}, '%')
|
|
|
+ or file_name like concat('%', #{keyword}, '%'))
|
|
|
+ </if>
|
|
|
+ <if test="title != null and title != ''">
|
|
|
+ and title like concat('%', #{title}, '%')
|
|
|
+ </if>
|
|
|
+ order by create_time desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectFeedVideoList" resultMap="LifeVideoCardResult">
|
|
|
+ select v.video_id, v.vest_id, v.title, v.cover_url, v.video_url, v.duration,
|
|
|
+ v.views, v.likes, v.favorite_num, v.share_num, v.is_hot, v.shelf_time,
|
|
|
+ t.nick_name as vest_nick_name, t.avatar as vest_avatar,
|
|
|
+ case when like_a.id is null then 0 else 1 end as liked,
|
|
|
+ case when fav_a.id is null then 0 else 1 end as favorited,
|
|
|
+ (select count(1) from fs_life_video_product p where p.video_id = v.video_id) as product_count,
|
|
|
+ (select min(sp.price) from fs_life_video_product p
|
|
|
+ left join fs_store_product_scrm sp on sp.product_id = p.product_id and sp.is_del = 0
|
|
|
+ where p.video_id = v.video_id) as min_price
|
|
|
+ from fs_life_video v
|
|
|
+ left join fs_life_vest t on t.id = v.vest_id and t.is_del = 0
|
|
|
+ left join fs_life_video_user_action like_a
|
|
|
+ on like_a.video_id = v.video_id and like_a.action_type = 1
|
|
|
+ and like_a.user_id = #{userId}
|
|
|
+ left join fs_life_video_user_action fav_a
|
|
|
+ on fav_a.video_id = v.video_id and fav_a.action_type = 2
|
|
|
+ and fav_a.user_id = #{userId}
|
|
|
+ where v.is_del = 0 and v.is_show = 1
|
|
|
+ <if test="tab != null and tab == 'hot'">and v.is_hot = 1</if>
|
|
|
+ <if test="keyword != null and keyword != ''">
|
|
|
+ and v.title like concat('%', #{keyword}, '%')
|
|
|
+ </if>
|
|
|
+ order by v.shelf_time desc, v.video_id desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectFeedVideoDetail" resultMap="LifeVideoCardResult">
|
|
|
+ select v.video_id, v.vest_id, v.title, v.cover_url, v.video_url, v.duration,
|
|
|
+ v.views, v.likes, v.favorite_num, v.share_num, v.is_hot, v.shelf_time,
|
|
|
+ t.nick_name as vest_nick_name, t.avatar as vest_avatar,
|
|
|
+ case when like_a.id is null then 0 else 1 end as liked,
|
|
|
+ case when fav_a.id is null then 0 else 1 end as favorited,
|
|
|
+ (select count(1) from fs_life_video_product p where p.video_id = v.video_id) as product_count,
|
|
|
+ (select min(sp.price) from fs_life_video_product p
|
|
|
+ left join fs_store_product_scrm sp on sp.product_id = p.product_id and sp.is_del = 0
|
|
|
+ where p.video_id = v.video_id) as min_price
|
|
|
+ from fs_life_video v
|
|
|
+ left join fs_life_vest t on t.id = v.vest_id and t.is_del = 0
|
|
|
+ left join fs_life_video_user_action like_a
|
|
|
+ on like_a.video_id = v.video_id and like_a.action_type = 1
|
|
|
+ and like_a.user_id = #{userId}
|
|
|
+ left join fs_life_video_user_action fav_a
|
|
|
+ on fav_a.video_id = v.video_id and fav_a.action_type = 2
|
|
|
+ and fav_a.user_id = #{userId}
|
|
|
+ where v.video_id = #{videoId} and v.is_del = 0
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertFsLifeVideo" useGeneratedKeys="true" keyProperty="videoId">
|
|
|
+ insert into fs_life_video
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="vestId != null">vest_id,</if>
|
|
|
+ <if test="title != null">title,</if>
|
|
|
+ <if test="fileName != null">file_name,</if>
|
|
|
+ <if test="coverUrl != null">cover_url,</if>
|
|
|
+ <if test="videoUrl != null">video_url,</if>
|
|
|
+ <if test="duration != null">duration,</if>
|
|
|
+ <if test="isShow != null">is_show,</if>
|
|
|
+ <if test="isHot != null">is_hot,</if>
|
|
|
+ <if test="views != null">views,</if>
|
|
|
+ <if test="likes != null">likes,</if>
|
|
|
+ <if test="favoriteNum != null">favorite_num,</if>
|
|
|
+ <if test="shareNum != null">share_num,</if>
|
|
|
+ <if test="isDel != null">is_del,</if>
|
|
|
+ <if test="shelfTime != null">shelf_time,</if>
|
|
|
+ <if test="createBy != null">create_by,</if>
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
+ <if test="remark != null">remark,</if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="vestId != null">#{vestId},</if>
|
|
|
+ <if test="title != null">#{title},</if>
|
|
|
+ <if test="fileName != null">#{fileName},</if>
|
|
|
+ <if test="coverUrl != null">#{coverUrl},</if>
|
|
|
+ <if test="videoUrl != null">#{videoUrl},</if>
|
|
|
+ <if test="duration != null">#{duration},</if>
|
|
|
+ <if test="isShow != null">#{isShow},</if>
|
|
|
+ <if test="isHot != null">#{isHot},</if>
|
|
|
+ <if test="views != null">#{views},</if>
|
|
|
+ <if test="likes != null">#{likes},</if>
|
|
|
+ <if test="favoriteNum != null">#{favoriteNum},</if>
|
|
|
+ <if test="shareNum != null">#{shareNum},</if>
|
|
|
+ <if test="isDel != null">#{isDel},</if>
|
|
|
+ <if test="shelfTime != null">#{shelfTime},</if>
|
|
|
+ <if test="createBy != null">#{createBy},</if>
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
+ <if test="remark != null">#{remark},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateFsLifeVideo">
|
|
|
+ update fs_life_video
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="vestId != null">vest_id = #{vestId},</if>
|
|
|
+ <if test="title != null">title = #{title},</if>
|
|
|
+ <if test="fileName != null">file_name = #{fileName},</if>
|
|
|
+ <if test="coverUrl != null">cover_url = #{coverUrl},</if>
|
|
|
+ <if test="videoUrl != null">video_url = #{videoUrl},</if>
|
|
|
+ <if test="duration != null">duration = #{duration},</if>
|
|
|
+ <if test="isShow != null">is_show = #{isShow},</if>
|
|
|
+ <if test="isHot != null">is_hot = #{isHot},</if>
|
|
|
+ <if test="isDel != null">is_del = #{isDel},</if>
|
|
|
+ <if test="shelfTime != null">shelf_time = #{shelfTime},</if>
|
|
|
+ <if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
+ <if test="remark != null">remark = #{remark},</if>
|
|
|
+ </trim>
|
|
|
+ where video_id = #{videoId}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="incrViews">
|
|
|
+ update fs_life_video set views = ifnull(views,0) + 1 where video_id = #{videoId} and is_del = 0
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="incrShareNum">
|
|
|
+ update fs_life_video set share_num = ifnull(share_num,0) + 1 where video_id = #{videoId} and is_del = 0
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="incrLikes">
|
|
|
+ update fs_life_video set likes = greatest(ifnull(likes,0) + #{delta}, 0) where video_id = #{videoId} and is_del = 0
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="incrFavoriteNum">
|
|
|
+ update fs_life_video set favorite_num = greatest(ifnull(favorite_num,0) + #{delta}, 0) where video_id = #{videoId} and is_del = 0
|
|
|
+ </update>
|
|
|
+</mapper>
|