| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- <?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="cn.reghao.tnb.content.app.vod.db.mapper.VideoPostMapper">
- <insert id="save" useGeneratedKeys="true" keyProperty="id">
- insert into vod_video_post
- (`video_id`,`title`,`description`,`category_pid`,`category_id`,`cover_url`,`scope`,`status`,`horizontal`,`duration`,`publish_at`,`publish_by`)
- values
- (#{videoId},#{title},#{description},#{categoryPid},#{categoryId},#{coverUrl},#{scope},#{status},#{horizontal},#{duration},#{publishAt},#{publishBy})
- </insert>
- <update id="updateVideoScope">
- update vod_video_post
- set update_time=now(),scope=#{scope}
- where video_id=#{videoId}
- </update>
- <update id="updateVideoInfo">
- update vod_video_post
- set update_time=now(),title=#{title},`description`=#{description}
- where video_id=#{videoId}
- </update>
- <update id="updateVideoCover">
- update vod_video_post
- set update_time=now(),cover_url=#{coverUrl}
- where video_id=#{videoId}
- </update>
- <update id="updateVideoFile">
- update vod_video_post
- set update_time=now(),duration=#{videoInfo.duration},quality=#{videoInfo.quality}
- where video_id=#{videoId}
- </update>
- <update id="updateVideoStatus">
- update vod_video_post
- set update_time=now(),`status`=#{status}
- where video_id=#{videoId}
- </update>
- <update id="updateVideoPublish">
- update vod_video_post
- set update_time=now(),`title`=#{title},`description`=#{description},`category_pid`=#{categoryPid},`category_id`=#{categoryId},`cover_url`=#{coverUrl},`scope`=#{scope},`status`=#{status},`publish_at`=#{publishAt}
- where video_id=#{videoId}
- </update>
- <update id="updateVideoCached">
- update vod_video_post
- set update_time=now(),duration=#{videoInfo.duration},`status`=2
- where video_id=#{videoId}
- </update>
- <delete id="deleteByVideoId">
- delete from vod_video_post
- where video_id=#{videoId}
- </delete>
- <select id="countByCriteria" resultType="java.lang.Integer">
- select count(*)
- from vod_video_post
- <where>
- deleted=0
- <if test="status != null">
- and `status` in
- <foreach collection="status" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="scope != null">
- and scope in
- <foreach collection="scope" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="categoryPid != null">
- and category_pid=#{categoryPid}
- </if>
- <if test="categoryId != null">
- and category_id=#{categoryId}
- </if>
- <if test="userId != null">
- and publish_by=#{userId}
- </if>
- <if test="horizontal != null">
- and horizontal=#{horizontal}
- </if>
- <if test="videoId != null">
- and video_id=#{videoId}
- </if>
- </where>
- </select>
- <select id="findVideoPostByPage" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
- select *
- from vod_video_post post
- <where>
- deleted=0
- <if test="videoQuery.status != null">
- and post.status in
- <foreach collection="videoQuery.status" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="videoQuery.scope != null">
- and post.scope in
- <foreach collection="videoQuery.scope" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="videoQuery.categoryPid != null">
- and post.category_pid=#{videoQuery.categoryPid}
- </if>
- <if test="videoQuery.categoryId != null">
- and post.category_id=#{videoQuery.categoryId}
- </if>
- <if test="videoQuery.userId != null">
- and post.publish_by=#{videoQuery.userId}
- </if>
- <if test="videoQuery.horizontal != null">
- and post.horizontal=#{videoQuery.horizontal}
- </if>
- </where>
- order by post.publish_at desc
- </select>
- <select id="findVideoCardByPage" resultMap="videoPostCard">
- select post.id,post.video_id,post.title,post.cover_url,post.duration,post.horizontal,post.publish_at,post.publish_by,post.status,
- statistic.view,statistic.comment
- from vod_video_post post
- inner join vod_video_statistic statistic
- on statistic.video_id=post.video_id
- <where>
- and post.deleted=0
- <if test="videoQuery.status != null">
- and post.status in
- <foreach collection="videoQuery.status" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="videoQuery.scope != null">
- and post.scope in
- <foreach collection="videoQuery.scope" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="videoQuery.categoryPid != null">
- and post.category_pid=#{videoQuery.categoryPid}
- </if>
- <if test="videoQuery.categoryId != null">
- and post.category_id=#{videoQuery.categoryId}
- </if>
- <if test="videoQuery.userId != null">
- and post.publish_by=#{videoQuery.userId}
- </if>
- <if test="videoQuery.horizontal != null">
- and post.horizontal=#{videoQuery.horizontal}
- </if>
- <if test="videoQuery.duration != null">
- and post.duration < #{videoQuery.duration}
- </if>
- </where>
- order by post.publish_at desc
- </select>
- <select id="countAdminVideo" resultType="java.lang.Integer">
- select count(*)
- from vod_video_post
- <where>
- deleted=0
- <if test="status != null">
- and `status` in
- <foreach collection="status" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="scope != null">
- and scope in
- <foreach collection="scope" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="categoryPid != null">
- and category_pid=#{categoryPid}
- </if>
- <if test="categoryId != null">
- and category_id=#{categoryId}
- </if>
- <if test="userId != null">
- and publish_by=#{userId}
- </if>
- <if test="horizontal != null">
- and horizontal=#{horizontal}
- </if>
- <if test="videoId != null">
- and video_id=#{videoId}
- </if>
- <if test="title != null">
- and match(title) against(#{title})
- </if>
- </where>
- </select>
- <select id="findAdminVideoByPage" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
- select *
- from vod_video_post
- <where>
- deleted=0
- <if test="videoQuery.status != null">
- and `status` in
- <foreach collection="videoQuery.status" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="videoQuery.scope != null">
- and scope in
- <foreach collection="videoQuery.scope" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="videoQuery.categoryPid != null">
- and category_pid=#{videoQuery.categoryPid}
- </if>
- <if test="videoQuery.categoryId != null">
- and category_id=#{videoQuery.categoryId}
- </if>
- <if test="videoQuery.userId != null">
- and publish_by=#{videoQuery.userId}
- </if>
- <if test="videoQuery.horizontal != null">
- and horizontal=#{videoQuery.horizontal}
- </if>
- <if test="videoQuery.title != null">
- and match(title) against(#{videoQuery.title})
- </if>
- </where>
- order by #{videoQuery.orderBy} #{videoQuery.orderDirection}
- </select>
- <resultMap id="videoPostCard" type="cn.reghao.tnb.content.api.dto.VideoPostCard">
- <id column="video_id" property="videoId"/>
- <result column="title" property="title"/>
- <result column="cover_url" property="coverUrl"/>
- <result column="duration" property="duration"/>
- <result column="horizontal" property="horizontal"/>
- <result column="status" property="status"/>
- <result column="publish_at" property="publishAt"/>
- <result column="publish_by" property="publishBy"/>
- <result column="view" property="view"/>
- <result column="comment" property="comment"/>
- </resultMap>
- <select id="findVideoCardByVideoIds" resultMap="videoPostCard">
- select post.id,post.video_id,post.title,post.cover_url,post.duration,post.horizontal,post.publish_at as publish_at,post.publish_by,post.status,
- statistic.view,statistic.comment
- from vod_video_post post
- inner join vod_video_statistic statistic
- on post.deleted=0 and statistic.video_id=post.video_id and post.status in (2,5,6,7) and post.video_id in
- <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </select>
- <select id="findByUserIds" resultMap="videoPostCard">
- select post.id,post.video_id,post.title,post.cover_url,post.duration,post.horizontal,post.publish_at as publish_at,post.publish_by,post.status,
- statistic.view,statistic.comment
- from vod_video_post post
- inner join vod_video_statistic statistic
- on statistic.video_id=post.video_id and post.status in (2,5,6,7) and post.publish_by in
- <foreach collection="userIds" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- where post.deleted=0 and post.id < #{nextId}
- order by post.publish_at desc
- limit #{pageSize}
- </select>
- <resultMap id="videoDetail" type="cn.reghao.tnb.content.app.vod.model.vo.VideoDetail">
- <id column="video_id" property="videoId"/>
- <result column="title" property="title"/>
- <result column="description" property="description"/>
- <result column="cover_url" property="coverUrl"/>
- <result column="duration" property="duration"/>
- <result column="publish_at" property="pubDate"/>
- <result column="scope" property="scope"/>
- <result column="status" property="status"/>
- <result column="publish_by" property="userId"/>
- <result column="view" property="view"/>
- <result column="thumb_up" property="thumbUp"/>
- <result column="favorite" property="favorite"/>
- <result column="share" property="share"/>
- <result column="comment" property="comment"/>
- <!--<collection column="tag_name" property="tags" ofType="java.lang.String" select="findVideoTags"/>-->
- </resultMap>
- <select id="findVideoPostDetail" resultMap="videoDetail">
- select post.publish_by,post.video_id,post.title,post.description,post.cover_url,post.duration,post.publish_at,post.scope,post.status,
- statistic.view,statistic.danmaku,statistic.comment,statistic.thumb_up,
- statistic.favorite,statistic.share
- from vod_video_post post
- inner join vod_video_statistic statistic
- on statistic.video_id=post.video_id
- <where>
- post.deleted=0
- <if test="status != null">
- and post.status in
- <foreach collection="status" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="scope != null">
- and post.scope in
- <foreach collection="scope" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="videoId != null">
- and post.video_id=#{videoId}
- </if>
- </where>
- </select>
- <select id="findVideoTags" resultType="java.lang.String">
- select tag_name
- from vod_post_tag
- inner join vod_video_tag
- on vod_post_tag.tag_id=vod_video_tag.tag_id and vod_video_tag.video_id=#{videoId}
- </select>
- <select id="findByNextVideos" resultMap="videoPostCard">
- select post.id,post.video_id,post.title,post.cover_url,post.duration,post.horizontal,post.publish_at,post.publish_by,post.status,
- statistic.view,statistic.comment
- from vod_video_post post
- inner join vod_video_statistic statistic
- on statistic.video_id=post.video_id
- <where>
- post.deleted=0
- <if test="videoQuery.status != null">
- and post.status in
- <foreach collection="videoQuery.status" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="videoQuery.scope != null">
- and post.scope in
- <foreach collection="videoQuery.scope" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="videoQuery.userId != null">
- and post.publish_by=#{videoQuery.userId}
- </if>
- and post.publish_at > #{publishAt}
- </where>
- order by post.publish_at asc
- limit 4
- </select>
- <select id="countBySearchCriteria" resultType="java.lang.Integer">
- select count(*)
- from vod_video_post
- <where>
- deleted=0
- <if test="status != null">
- and `status` in
- <foreach collection="status" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="scope != null">
- and scope in
- <foreach collection="scope" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="title != null">
- and match(title) against(#{title})
- </if>
- </where>
- </select>
- <select id="findSearchCriteriaByPage" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
- select *
- from vod_video_post
- <where>
- deleted=0
- <if test="searchCriteria.status != null">
- and status in
- <foreach collection="searchCriteria.status" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="searchCriteria.scope != null">
- and scope in
- <foreach collection="searchCriteria.scope" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="searchCriteria.title != null">
- and match(title) against(#{searchCriteria.title})
- </if>
- </where>
- </select>
- <select id="findByVideoId" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
- select *
- from vod_video_post
- where deleted=0 and video_id=#{videoId}
- </select>
- <select id="findAll" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
- select *
- from vod_video_post
- where deleted=0 and `status`=2 and category_pid=11
- </select>
- <select id="findAllById" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
- select *
- from vod_video_post
- where deleted=0 and `status` in (2,5) and id > #{nextId}
- order by id asc
- limit #{pageSize}
- </select>
- <select id="findBannerVideos" resultType="cn.reghao.tnb.content.app.vod.model.po.BannerVideo">
- select post.video_id,post.cover_url,post.title
- from vod_video_post post
- where deleted=0
- order by publish_at desc
- limit 10
- </select>
- <select id="findPublishByPost" resultType="cn.reghao.tnb.common.db.GroupCount">
- select publish_by as id,count(*) total
- from vod_video_post
- where deleted=0 and category_pid=11
- group by publish_by
- order by total desc
- </select>
- <select id="findPublishByImage" resultType="cn.reghao.tnb.common.db.GroupCount">
- select user_id as id,count(*) as total
- from image_post
- where user_id not in
- (
- select publish_by
- from vod_video_post
- where category_pid=11
- group by publish_by
- )
- group by user_id
- order by total desc
- </select>
- <select id="findPublishByVideo" resultType="cn.reghao.tnb.common.db.GroupCount">
- select publish_by as id,count(*) total
- from vod_video_post
- where category_pid=11
- group by publish_by
- order by total desc
- </select>
- <select id="findRandomVideoIds" resultType="java.lang.String">
- SELECT t1.video_id
- FROM vod_video_post AS t1
- JOIN (SELECT ROUND(RAND()*(SELECT MAX(id) FROM vod_video_post)) AS id) AS t2
- WHERE t1.id>=t2.id and t1.scope in
- <foreach collection="scopes" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- ORDER BY t1.id
- LIMIT #{size}
- </select>
- <select id="findShortVideo" resultType="java.lang.String">
- SELECT video_id
- FROM vod_video_post AS t1
- WHERE t1.duration<=120 and t1.`status`=2 and t1.`horizontal`=0 and t1.scope in
- <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
- #{id}
- </foreach>
- limit 100000
- </select>
- <select id="findGroupByUserAndCategory" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
- select *
- from vod_video_post
- where `deleted`=0 and `status`=2 and category_pid=#{categoryPid}
- group by publish_by,category_id
- </select>
- <select id="findUserAndCategory" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
- select *
- from vod_video_post
- where `deleted`=0 and `status`=2 and publish_by=#{publishBy} and category_id=#{categoryId}
- order by publish_at desc
- limit 1
- </select>
- <select id="findByTitle" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
- select *
- from vod_video_post
- where `deleted`=0 and `status`=2 and category_pid=11 and title like concat(#{title},'%')
- </select>
- </mapper>
|