| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- <?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.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt">
- <insert id="insertGzhPlanReturnId" useGeneratedKeys="true" keyProperty="id">
- insert into content_platform_gzh_plan (`type`, publish_stage, account_id, scene, external_id,
- select_video_type, stage_publish_status,
- create_account_id, create_timestamp, update_timestamp)
- values (#{record.type}, #{record.publishStage}, #{record.accountId}, #{record.scene}, #{record.externalId},
- #{record.selectVideoType}, #{record.stagePublishStatus}, #{record.createAccountId},
- #{record.createTimestamp}, #{record.updateTimestamp})
- </insert>
- <select id="getGzhPlanCount" resultType="java.lang.Integer">
- select count(*)
- from content_platform_gzh_plan
- where create_account_id = #{createAccountId} and status = 1
- <if test="param.type != null">
- and type = #{param.type}
- </if>
- <if test="param.accountId != null">
- and account_id = #{param.accountId}
- </if>
- <if test="param.publishStage != null">
- and publish_stage = #{param.publishStage}
- </if>
- <if test="param.selectVideoType != null">
- and select_video_type = #{param.selectVideoType}
- </if>
- <if test="param.createTimestampStart != null">
- and create_timestamp > #{param.createTimestampStart}
- </if>
- <if test="param.createTimestampEnd != null">
- and create_timestamp < #{param.createTimestampEnd}
- </if>
- <if test="param.title != null and param.title != ''">
- and id in (select plan_id
- from content_platform_gzh_plan_video
- where (title like concat('%', #{param.title}, '%')
- or custom_title like concat('%', #{param.title}, '%'))
- and status = 1)
- </if>
- </select>
- <select id="getGzhPlanList"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlan">
- select *
- from content_platform_gzh_plan
- where create_account_id = #{createAccountId} and status = 1
- <if test="param.type != null">
- and type = #{param.type}
- </if>
- <if test="param.accountId != null">
- and account_id = #{param.accountId}
- </if>
- <if test="param.publishStage != null">
- and publish_stage = #{param.publishStage}
- </if>
- <if test="param.selectVideoType != null">
- and select_video_type = #{param.selectVideoType}
- </if>
- <if test="param.createTimestampStart != null">
- and create_timestamp > #{param.createTimestampStart}
- </if>
- <if test="param.createTimestampEnd != null">
- and create_timestamp < #{param.createTimestampEnd}
- </if>
- <if test="param.title != null and param.title != ''">
- and id in (select plan_id
- from content_platform_gzh_plan_video
- where (title like concat('%', #{param.title}, '%')
- or custom_title like concat('%', #{param.title}, '%'))
- and status = 1)
- </if>
- order by create_timestamp desc
- limit #{offset}, #{pageSize}
- </select>
- <select id="getGzhPlanExists"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlan">
- select *
- from content_platform_gzh_plan
- where account_id = #{accountId}
- and scene = #{scene}
- and type = #{type}
- and status = 1
- <if test="id != null">
- and id != #{id}
- </if>
- limit 1
- </select>
- <select id="getVideoMaxDt" resultType="java.lang.String">
- select max(dt)
- from content_platform_video_agg
- </select>
- <select id="getVideoDatastatMaxDt" resultType="java.lang.String">
- select max(dt)
- from content_platform_video_datastat_agg
- </select>
- <select id="getVideoCount" resultType="java.lang.Integer">
- select count(1)
- from content_platform_video_agg
- where dt = #{dt} and status = 1 and score > #{minScore}
- <if test="param.title!= null and param.title!= ''">
- and title like concat('%', #{param.title}, '%')
- </if>
- <if test="param.category!= null and param.category!= ''">
- and category = #{param.category}
- </if>
- </select>
- <select id="getApiVideoList" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
- select video.*
- from content_platform_video_agg video
- left join content_platform_video_datastat_agg datastat
- on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel}
- and datastat.strategy = #{strategy} and datastat.video_id = video.video_id
- where video.dt = #{dt} and video.status = 1 and video.score > #{minScore}
- <if test="param.title!= null and param.title!= ''">
- and video.title like concat('%', #{param.title}, '%')
- </if>
- <if test="param.category!= null and param.category!= ''">
- and video.category = #{param.category}
- </if>
- order by ${sort}
- limit #{offset}, #{pageSize}
- </select>
- <select id="getVideoList" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
- select video.*
- from content_platform_video_agg video
- left join content_platform_video_datastat_agg datastat
- on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel}
- and datastat.strategy = #{strategy} and datastat.video_id = video.video_id
- <if test="excludeVideoTime != null">
- left join content_platform_gzh_plan_video gzhPlanVideo
- on gzhPlanVideo.video_id = video.video_id and gzhPlanVideo.create_account_id = #{createAccountId}
- <if test="excludeVideoTime != 0">
- and gzhPlanVideo.create_timestamp > #{excludeVideoTime}
- </if>
- left join content_platform_qw_plan_video qwPlanVideo
- on qwPlanVideo.video_id = video.video_id and qwPlanVideo.create_account_id = #{createAccountId}
- <if test="excludeVideoTime != 0">
- and qwPlanVideo.create_timestamp > #{excludeVideoTime}
- </if>
- </if>
- <if test="param.tag != null">
- join content_platform_video_tag videoTag
- on videoTag.dt = video.dt and videoTag.video_id = video.video_id and ${videoTagFilter}
- </if>
- where video.dt = #{dt} and video.status = 1 and video.score > #{minScore}
- and (video.source = 1 or video.video_id in (select video_id
- from content_platform_video_account_rel
- where dt = #{dt} and account_id = #{createAccountId}))
- <if test="param.title!= null and param.title!= ''">
- and video.title like concat('%', #{param.title}, '%')
- </if>
- <if test="param.category!= null and param.category!= ''">
- and video.category = #{param.category}
- </if>
- <if test="excludeVideoTime != null">
- and gzhPlanVideo.video_id is null
- and qwPlanVideo.video_id is null
- </if>
- order by ${sort}
- limit #{offset}, #{pageSize}
- </select>
- <select id="getVideoMinScoreList" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
- select *
- from content_platform_video_agg video
- where video.dt = #{dt} and video.status = 1 and video.score > #{minScore}
- <if test="excludeVideoIds != null and excludeVideoIds.size() > 0">
- and video.video_id not in
- <foreach collection="excludeVideoIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- order by ${sort}
- limit #{offset}, #{pageSize}
- </select>
- <select id="getVideoMinDatastatScoreList" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
- select video.*
- from content_platform_video_agg video
- left join content_platform_video_datastat_agg datastat
- on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel}
- and datastat.strategy = #{strategy} and datastat.video_id = video.video_id
- where video.dt = #{dt} and video.status = 1 and datastat.fission_rate > #{minScore}
- <if test="excludeVideoIds != null and excludeVideoIds.size() > 0">
- and video.video_id not in
- <foreach collection="excludeVideoIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- order by ${sort}
- limit #{offset}, #{pageSize}
- </select>
- <select id="getVideoCategoryList" resultType="java.lang.String">
- select distinct category
- from content_platform_video_agg
- where dt = #{dt} and status = 1
- </select>
- <insert id="batchInsertContentPlatformVideo">
- insert into content_platform_video (dt, video_id, category, title, cover, video, score, create_timestamp)
- values
- <foreach collection="records" item="item" separator=",">
- (#{item.dt}, #{item.videoId}, #{item.category}, #{item.title}, #{item.cover}, #{item.video}, #{item.score},
- #{item.createTimestamp})
- </foreach>
- </insert>
- <insert id="batchInsertContentPlatformIllegalVideo">
- insert into content_platform_illegal_video (date_str, video_id, content, title, create_timestamp)
- values
- <foreach collection="records" item="item" separator=",">
- (#{item.dateStr}, #{item.videoId}, #{item.content}, #{item.title}, #{item.createTimestamp})
- </foreach>
- </insert>
- <insert id="batchInsertContentPlatformVideoAgg">
- insert into content_platform_video_agg (dt, last_dt, source, video_id, category, title, cover,
- video, score, create_timestamp)
- values
- <foreach collection="records" item="item" separator=",">
- (#{item.dt}, #{item.lastDt}, #{item.source}, #{item.videoId}, #{item.category}, #{item.title},
- #{item.cover}, #{item.video}, #{item.score}, #{item.createTimestamp})
- </foreach>
- </insert>
- <select id="getQwPlanCount" resultType="java.lang.Integer">
- select count(*)
- from content_platform_qw_plan
- where create_account_id = #{createAccountId}
- and type = #{param.type}
- and status = 1
- <if test="param.scene != null">
- and scene = #{param.scene}
- </if>
- <if test="param.subChannel != null and param.subChannel != ''">
- and sub_channel like concat('%', #{param.subChannel}, '%')
- </if>
- <if test="param.title != null and param.title != ''">
- and id in (select plan_id
- from content_platform_qw_plan_video
- where title like concat('%', #{param.title}, '%') and status = 1)
- </if>
- </select>
- <select id="getQwPlanList"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan">
- select *
- from content_platform_qw_plan
- where create_account_id = #{createAccountId}
- and type = #{param.type}
- and status = 1
- <if test="param.scene != null">
- and scene = #{param.scene}
- </if>
- <if test="param.subChannel != null and param.subChannel != ''">
- and sub_channel like concat('%', #{param.subChannel}, '%')
- </if>
- <if test="param.title != null and param.title != ''">
- and id in (select plan_id
- from content_platform_qw_plan_video
- where title like concat('%', #{param.title}, '%') and status = 1)
- </if>
- order by create_timestamp desc
- limit #{offset}, #{pageSize}
- </select>
- <insert id="batchInsertQwPlan">
- insert into content_platform_qw_plan (`type`, scene, page_url, root_source_id,
- create_account_id, create_timestamp, update_timestamp
- )
- values
- <foreach collection="records" item="item" separator=",">
- (#{item.type}, #{item.scene}, #{item.pageUrl}, #{item.rootSourceId},
- #{item.createAccountId}, #{item.createTimestamp}, #{item.updateTimestamp}
- )
- </foreach>
- </insert>
- <insert id="insertQwPlanReturnId" useGeneratedKeys="true" keyProperty="id">
- insert into content_platform_qw_plan (`type`, sub_channel, scene, page_url, root_source_id, create_account_id,
- create_timestamp, update_timestamp)
- values (#{record.type}, #{record.subChannel}, #{record.scene}, #{record.pageUrl}, #{record.rootSourceId},
- #{record.createAccountId}, #{record.createTimestamp}, #{record.updateTimestamp})
- </insert>
- <select id="getGzhPlanVideoListByCooperateAccountId"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlanVideo">
- select cpgpv.*
- from content_platform_gzh_plan_video cpgpv
- join content_platform_gzh_plan cpgp on cpgp.id = cpgpv.plan_id
- join content_platform_gzh_account cpgac on cpgac.id = cpgp.account_id
- where cpgac.gh_id = #{ghId}
- and cpgac.status = 1
- and cpgp.scene = 0
- and cpgp.status = 1
- and cpgpv.status = 1
- </select>
- <select id="getVideoAggList"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoAgg">
- SELECT t.video_id, t.category, t.title, t.cover, t.video, round(t.avg_score, 3) as score, t.dt
- FROM (
- SELECT video_id, category, title, cover, video, AVG(score) OVER (PARTITION BY video_id) AS avg_score,
- ROW_NUMBER() OVER (PARTITION BY video_id ORDER BY dt DESC) AS rn,
- MAX(dt) OVER (PARTITION BY video_id) AS dt
- FROM content_platform_video
- where dt in
- <foreach collection="dtList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- and status = 1
- and cover is not null
- ) AS t
- WHERE t.rn = 1;
- </select>
- <update id="updateVideoStatusWithOldStatus">
- update content_platform_video
- set status = #{status},
- update_timestamp = #{now}
- where video_id = #{videoId}
- and status = #{oldStatus}
- </update>
- <update id="updateVideoAggStatusWithOldStatus">
- update content_platform_video_agg
- set status = #{status},
- update_timestamp = #{now}
- where video_id = #{videoId}
- and status = #{oldStatus}
- </update>
- <select id="getVideoListByIds"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
- SELECT t1.*
- FROM content_platform_video t1
- INNER JOIN (
- SELECT video_id, MAX(dt) AS max_dt
- FROM content_platform_video
- WHERE video_id IN
- <foreach collection="videoIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- GROUP BY video_id
- ) t2 ON t1.video_id = t2.video_id AND t1.dt = t2.max_dt
- ORDER BY t1.dt DESC
- </select>
- <delete id="deleteContentPlatformVideo">
- delete from content_platform_video where dt = #{dt}
- </delete>
- <delete id="deleteContentPlatformVideoAgg">
- delete from content_platform_video_agg where dt = #{dt} and source = #{source}
- </delete>
- <delete id="deleteContentPlatformVideoDatastatAgg">
- delete
- from content_platform_video_datastat_agg
- where dt = #{dt}
- <if test="strategy != null and strategy != ''">
- and strategy = #{strategy}
- </if>
- </delete>
- <delete id="deleteContentPlatformVideoDatastat">
- delete from content_platform_video_datastat where dt = #{dt}
- </delete>
- <insert id="batchInsertContentPlatformVideoDatastat">
- insert into content_platform_video_datastat (dt, video_id, `type`, channel, first_level, fission0,
- fission_rate, create_timestamp)
- values
- <foreach collection="records" item="item" separator=",">
- (#{item.dt}, #{item.videoId}, #{item.type}, #{item.channel}, #{item.firstLevel},
- #{item.fission0}, #{item.fissionRate}, #{item.createTimestamp})
- </foreach>
- </insert>
- <insert id="batchInsertContentPlatformVideoDatastatAgg">
- insert into content_platform_video_datastat_agg (dt, video_id, `type`, channel, strategy, first_level, fission0,
- fission_rate, create_timestamp)
- values
- <foreach collection="records" item="item" separator=",">
- (#{item.dt}, #{item.videoId}, #{item.type}, #{item.channel}, #{item.strategy}, #{item.firstLevel},
- #{item.fission0}, #{item.fissionRate}, #{item.createTimestamp})
- </foreach>
- </insert>
- <update id="updateOtherVideoStatus">
- update content_platform_video
- set status = 0,
- update_timestamp = #{now}
- where dt = #{dt} and video_id not in
- <foreach collection="videoIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </update>
- <select id="getGzhPlanIllegalVideoList"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.PlanIllegalVideoDTO">
- select plan.create_account_id as account_id, plan.type, video.video_id, '公众号' as channel,
- coalesce(nullif(video.custom_title, ''), video.title) as title
- from content_platform_gzh_plan plan
- join content_platform_gzh_plan_video video on plan.id = video.plan_id
- where video.video_id = #{videoId} and plan.`status` = 1 and video.status = 1
- </select>
- <select id="getQwPlanIllegalVideoList"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.PlanIllegalVideoDTO">
- select plan.create_account_id as account_id, plan.type, video.video_id, '企微' as channel, video.title
- from content_platform_qw_plan plan
- join content_platform_qw_plan_video video on plan.id = video.plan_id
- where video.video_id = #{videoId} and plan.`status` = 1 and video.status = 1
- </select>
- <select id="getUploadVideoCount" resultType="java.lang.Integer">
- select count(1)
- from content_platform_upload_video
- where audit_status = 2 and create_account_id = #{createAccountId} and is_delete = 0
- <if test="param.title!= null and param.title!= ''">
- and title like concat('%', #{param.title}, '%')
- </if>
- </select>
- <select id="getUploadVideoList"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
- select video.*
- from content_platform_upload_video video
- left join content_platform_video_datastat_agg datastat
- on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel}
- and datastat.strategy = #{strategy} and datastat.video_id = video.video_id
- where video.audit_status = 2 and video.create_account_id = #{createAccountId} and video.is_delete = 0
- <if test="param.title!= null and param.title!= ''">
- and video.title like concat('%', #{param.title}, '%')
- </if>
- order by ${sort}
- limit #{offset}, #{pageSize}
- </select>
- <update id="updateUploadVideoStatusWithOldStatus">
- update content_platform_upload_video
- set audit_status = #{status},
- update_timestamp = #{now}
- where video_id = #{videoId}
- </update>
- <delete id="deleteContentPlatformVideoAccountRel">
- delete from content_platform_video_account_rel where dt = #{dt}
- </delete>
- <insert id="batchInsertContentPlatformVideoAccountRel">
- insert into content_platform_video_account_rel (dt, account_id, video_id, sim_score, create_timestamp)
- values
- <foreach collection="records" item="item" separator=",">
- (#{item.dt}, #{item.accountId}, #{item.videoId}, #{item.simScore}, #{item.createTimestamp})
- </foreach>
- </insert>
- <select id="getVideoTagList"
- resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoTag">
- select *
- from content_platform_video_tag
- where dt = #{dt} and video_id in
- <foreach collection="videoIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- and (platform = 1 or account_id = #{accountId} or type = #{type} or channel = #{channel})
- </select>
- <delete id="deleteContentPlatformVideoTag">
- delete from content_platform_video_tag where dt = #{dt}
- </delete>
- <insert id="batchInsertContentPlatformVideoTag">
- insert into content_platform_video_tag (dt, account_id, video_id, platform, type, channel, tag, create_timestamp)
- values
- <foreach collection="records" item="item" separator=",">
- (#{item.dt}, #{item.accountId}, #{item.videoId}, #{item.platform}, #{item.type}, #{item.channel}, #{item.tag}, #{item.createTimestamp})
- </foreach>
- </insert>
- </mapper>
|