xkrs_ms/stdiet-custom/src/main/resources/mapper/custom/SysNutritionalVideoMapper.xml
2021-06-15 18:48:45 +08:00

176 lines
8.9 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.stdiet.custom.mapper.SysNutritionalVideoMapper">
<resultMap type="SysNutritionalVideo" id="SysNutritionalVideoResult">
<result property="id" column="id" />
<result property="cateId" column="cate_id" />
<result property="videoId" column="video_id" />
<result property="coverUrl" column="cover_url" />
<result property="title" column="title" />
<result property="description" column="description" />
<result property="videoSize" column="video_size" />
<result property="tags" column="tags" />
<result property="showFlag" column="show_flag" />
<result property="priorityLevel" column="priority_level" />
<result property="payLevel" column="pay_level" />
<result property="playNum" column="play_num" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
<result property="payLevelName" column="pay_level_name"></result>
<result property="cateName" column="cate_name"></result>
</resultMap>
<sql id="selectSysNutritionalVideoVo">
select id, cate_id, video_id, cover_url, title, description, priority_level,pay_level,play_num,video_size, tags, show_flag, create_time, create_by, update_time, update_by, del_flag from sys_nutritional_video
</sql>
<select id="selectSysNutritionalVideoList" parameterType="SysNutritionalVideo" resultMap="SysNutritionalVideoResult">
select snv.id, snv.cate_id, snv.video_id, snv.cover_url, snv.title, snv.description, snv.priority_level,snv.pay_level,snv.play_num,snv.video_size, snv.tags, snv.show_flag, snv.create_time,
pay.dict_label as pay_level_name, svc.cate_name
from sys_nutritional_video snv
left join (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'video_pay_level') AS pay ON pay.dict_value = snv.pay_level
left join sys_video_classify svc on svc.id = snv.cate_id and svc.del_flag = 0
where snv.del_flag = 0
<if test="showFlag != null">
and snv.show_flag = #{showFlag}
</if>
<if test="cateId != null">
and snv.cate_id in (
select id from sys_video_classify where del_flag = 0
and (id = #{cateId} or id in (select s.id from sys_video_classify s where s.parent_id = #{cateId} and s.del_flag = 0)
or id in (select ss.id from sys_video_classify ss where ss.del_flag = 0 and ss.parent_id in (select a.id from sys_video_classify a where a.parent_id = #{cateId} and a.del_flag = 0 )))
)
</if>
<if test="payLevel != null">
and snv.pay_level = #{payLevel}
</if>
<if test="userType != null">
<if test="userType == 0">
and pay_level = 0
</if>
<if test="userType == 1">
and (pay_level = 0 or pay_level = 1)
</if>
</if>
<if test="key != null and key != ''">
and (snv.title like concat('%',#{key},'%') or snv.description like concat('%',#{key},'%'))
</if>
<if test="sortType == null or sortType == 1">
order by snv.create_time DESC
</if>
<if test="sortType != null and sortType == 2">
order by snv.priority_level DESC,snv.create_time DESC
</if>
</select>
<select id="selectSysNutritionalVideoById" parameterType="Long" resultMap="SysNutritionalVideoResult">
<include refid="selectSysNutritionalVideoVo"/>
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysNutritionalVideo" parameterType="SysNutritionalVideo" useGeneratedKeys="true" keyProperty="id">
insert into sys_nutritional_video
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="cateId != null">cate_id,</if>
<if test="videoId != null">video_id,</if>
<if test="coverUrl != null">cover_url,</if>
<if test="title != null">title,</if>
<if test="description != null">description,</if>
<if test="videoSize != null">video_size,</if>
<if test="tags != null">tags,</if>
<if test="showFlag != null">show_flag,</if>
<if test="priorityLevel != null">priority_level,</if>
<if test="playNum != null">play_num,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="payLevel != null">pay_level,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="cateId != null">#{cateId},</if>
<if test="videoId != null">#{videoId},</if>
<if test="coverUrl != null">#{coverUrl},</if>
<if test="title != null">#{title},</if>
<if test="description != null">#{description},</if>
<if test="videoSize != null">#{videoSize},</if>
<if test="tags != null">#{tags},</if>
<if test="showFlag != null">#{showFlag},</if>
<if test="priorityLevel != null">#{priorityLevel},</if>
<if test="playNum != null">#{playNum},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="payLevel != null">#{payLevel},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateSysNutritionalVideo" parameterType="SysNutritionalVideo">
update sys_nutritional_video
<trim prefix="SET" suffixOverrides=",">
<if test="cateId != null">cate_id = #{cateId},</if>
<if test="videoId != null">video_id = #{videoId},</if>
<if test="coverUrl != null">cover_url = #{coverUrl},</if>
<if test="title != null">title = #{title},</if>
<if test="description != null">description = #{description},</if>
<if test="videoSize != null">video_size = #{videoSize},</if>
<if test="tags != null">tags = #{tags},</if>
<if test="showFlag != null">show_flag = #{showFlag},</if>
<if test="priorityLevel != null">priority_level = #{priorityLevel},</if>
<if test="playNum != null">play_num = #{playNum},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="payLevel != null">pay_level = #{payLevel},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<update id="deleteSysNutritionalVideoById" parameterType="Long">
update sys_nutritional_video set del_flag = 1 where id = #{id}
</update>
<update id="deleteSysNutritionalVideoByIds" parameterType="String">
update sys_nutritional_video set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="selectSysNutritionalVideByVideoId" parameterType="String" resultMap="SysNutritionalVideoResult">
<include refid="selectSysNutritionalVideoVo"/> where video_id = #{videoId} and del_flag = 0 limit 1
</select>
<update id="updateWxshowByIds" parameterType="String">
update sys_nutritional_video set show_flag = #{wxShow} where del_flag = 0 and id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 查询视频的阿里云ID包含已删除的 -->
<select id="getVideoIdByIds" parameterType="String" resultType="String">
select video_id from sys_nutritional_video where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<!-- 更新视频播放量 -->
<update id="updateVideoPlayNum" parameterType="String">
update sys_nutritional_video set play_num = play_num + 1 where video_id = #{videoId} and del_flag = 0
</update>
</mapper>