ContentPlatformPlanMapperExt.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt">
  4. <insert id="insertGzhPlanReturnId" useGeneratedKeys="true" keyProperty="id">
  5. insert into content_platform_gzh_plan (`type`, publish_stage, account_id, scene, external_id,
  6. select_video_type, stage_publish_status,
  7. create_account_id, create_timestamp, update_timestamp)
  8. values (#{record.type}, #{record.publishStage}, #{record.accountId}, #{record.scene}, #{record.externalId},
  9. #{record.selectVideoType}, #{record.stagePublishStatus}, #{record.createAccountId},
  10. #{record.createTimestamp}, #{record.updateTimestamp})
  11. </insert>
  12. <select id="getGzhPlanCount" resultType="java.lang.Integer">
  13. select count(*)
  14. from content_platform_gzh_plan
  15. where create_account_id = #{createAccountId} and status = 1
  16. <if test="param.type != null">
  17. and type = #{param.type}
  18. </if>
  19. <if test="param.accountId != null">
  20. and account_id = #{param.accountId}
  21. </if>
  22. <if test="param.publishStage != null">
  23. and publish_stage = #{param.publishStage}
  24. </if>
  25. <if test="param.selectVideoType != null">
  26. and select_video_type = #{param.selectVideoType}
  27. </if>
  28. <if test="param.createTimestampStart != null">
  29. and create_timestamp > #{param.createTimestampStart}
  30. </if>
  31. <if test="param.createTimestampEnd != null">
  32. and create_timestamp &lt; #{param.createTimestampEnd}
  33. </if>
  34. <if test="param.title != null and param.title != ''">
  35. and id in (select plan_id
  36. from content_platform_gzh_plan_video
  37. where title like concat('%', #{param.title}, '%')
  38. or custom_title like concat('%', #{param.title}, '%'))
  39. </if>
  40. </select>
  41. <select id="getGzhPlanList"
  42. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlan">
  43. select *
  44. from content_platform_gzh_plan
  45. where create_account_id = #{createAccountId} and status = 1
  46. <if test="param.type != null">
  47. and type = #{param.type}
  48. </if>
  49. <if test="param.accountId != null">
  50. and account_id = #{param.accountId}
  51. </if>
  52. <if test="param.publishStage != null">
  53. and publish_stage = #{param.publishStage}
  54. </if>
  55. <if test="param.selectVideoType != null">
  56. and select_video_type = #{param.selectVideoType}
  57. </if>
  58. <if test="param.createTimestampStart != null">
  59. and create_timestamp > #{param.createTimestampStart}
  60. </if>
  61. <if test="param.createTimestampEnd != null">
  62. and create_timestamp &lt; #{param.createTimestampEnd}
  63. </if>
  64. <if test="param.title != null and param.title != ''">
  65. and id in (select plan_id
  66. from content_platform_gzh_plan_video
  67. where title like concat('%', #{param.title}, '%')
  68. or custom_title like concat('%', #{param.title}, '%'))
  69. </if>
  70. order by create_timestamp desc
  71. limit #{offset}, #{pageSize}
  72. </select>
  73. <select id="getGzhPlanExists"
  74. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlan">
  75. select *
  76. from content_platform_gzh_plan
  77. where account_id = #{accountId}
  78. and scene = #{scene}
  79. and type = #{type}
  80. and status = 1
  81. <if test="id != null">
  82. and id != #{id}
  83. </if>
  84. limit 1
  85. </select>
  86. <select id="getVideoMaxDt" resultType="java.lang.String">
  87. select max(dt)
  88. from content_platform_video_agg
  89. </select>
  90. <select id="getVideoCount" resultType="java.lang.Integer">
  91. select count(1)
  92. from content_platform_video_agg
  93. where dt = #{dt} and status = 1 and score > #{minScore}
  94. <if test="param.title!= null and param.title!= ''">
  95. and title like concat('%', #{param.title}, '%')
  96. </if>
  97. <if test="param.category!= null and param.category!= ''">
  98. and category = #{param.category}
  99. </if>
  100. </select>
  101. <select id="getVideoList" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
  102. select *
  103. from content_platform_video_agg
  104. where dt = #{dt} and status = 1 and score > #{minScore}
  105. <if test="param.title!= null and param.title!= ''">
  106. and title like concat('%', #{param.title}, '%')
  107. </if>
  108. <if test="param.category!= null and param.category!= ''">
  109. and category = #{param.category}
  110. </if>
  111. order by score desc
  112. limit #{offset}, #{pageSize}
  113. </select>
  114. <select id="getVideoCategoryList" resultType="java.lang.String">
  115. select distinct category
  116. from content_platform_video_agg
  117. where dt = #{dt} and status = 1
  118. </select>
  119. <insert id="batchInsertContentPlatformVideo">
  120. insert into content_platform_video (dt, video_id, category, title, cover, video, score, create_timestamp)
  121. values
  122. <foreach collection="records" item="item" separator=",">
  123. (#{item.dt}, #{item.videoId}, #{item.category}, #{item.title}, #{item.cover}, #{item.video}, #{item.score},
  124. #{item.createTimestamp})
  125. </foreach>
  126. </insert>
  127. <insert id="batchInsertContentPlatformVideoAgg">
  128. insert into content_platform_video_agg (dt, video_id, category, title, cover, video, score, create_timestamp)
  129. values
  130. <foreach collection="records" item="item" separator=",">
  131. (#{item.dt}, #{item.videoId}, #{item.category}, #{item.title}, #{item.cover}, #{item.video}, #{item.score},
  132. #{item.createTimestamp})
  133. </foreach>
  134. </insert>
  135. <select id="getQwPlanCount" resultType="java.lang.Integer">
  136. select count(*)
  137. from content_platform_qw_plan
  138. where create_account_id = #{createAccountId}
  139. and type = #{param.type}
  140. and status = 1
  141. <if test="param.scene != null">
  142. and scene = #{param.scene}
  143. </if>
  144. <if test="param.title != null and param.title != ''">
  145. and id in (select plan_id from content_platform_qw_plan_video where title like concat('%', #{param.title},
  146. '%'))
  147. </if>
  148. </select>
  149. <select id="getQwPlanList"
  150. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan">
  151. select *
  152. from content_platform_qw_plan
  153. where create_account_id = #{createAccountId}
  154. and type = #{param.type}
  155. and status = 1
  156. <if test="param.scene != null">
  157. and scene = #{param.scene}
  158. </if>
  159. <if test="param.title != null and param.title != ''">
  160. and id in (select plan_id from content_platform_qw_plan_video where title like concat('%', #{param.title},
  161. '%'))
  162. </if>
  163. order by create_timestamp desc
  164. limit #{offset}, #{pageSize}
  165. </select>
  166. <insert id="batchInsertQwPlan">
  167. insert into content_platform_qw_plan (`type`, scene, page_url, root_source_id,
  168. create_account_id, create_timestamp, update_timestamp
  169. )
  170. values
  171. <foreach collection="records" item="item" separator=",">
  172. (#{item.type}, #{item.scene}, #{item.pageUrl}, #{item.rootSourceId},
  173. #{item.createAccountId}, #{item.createTimestamp}, #{item.updateTimestamp}
  174. )
  175. </foreach>
  176. </insert>
  177. <insert id="insertQwPlanReturnId" useGeneratedKeys="true" keyProperty="id">
  178. insert into content_platform_qw_plan (`type`, scene, page_url, root_source_id, create_account_id,
  179. create_timestamp, update_timestamp)
  180. values ( #{record.type}, #{record.scene}, #{record.pageUrl}, #{record.rootSourceId},
  181. #{record.createAccountId}, #{record.createTimestamp}, #{record.updateTimestamp})
  182. </insert>
  183. <select id="getGzhPlanVideoListByCooperateAccountId"
  184. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlanVideo">
  185. select cpgpv.*
  186. from content_platform_gzh_plan_video cpgpv
  187. join content_platform_gzh_plan cpgp on cpgp.id = cpgpv.plan_id
  188. join content_platform_gzh_account cpgac on cpgac.id = cpgp.account_id
  189. where cpgac.gh_id = #{ghId}
  190. and cpgac.status = 1
  191. and cpgp.scene = 0
  192. and cpgp.status = 1
  193. </select>
  194. <select id="getVideoAggList"
  195. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoAgg">
  196. SELECT t.video_id, t.category, t.title, t.cover, t.video, round(t.avg_score, 3) as score
  197. FROM (
  198. SELECT video_id, category, title, cover, video, AVG(score) OVER (PARTITION BY video_id) AS avg_score,
  199. ROW_NUMBER() OVER (PARTITION BY video_id ORDER BY dt DESC) AS rn
  200. FROM content_platform_video
  201. where dt in
  202. <foreach collection="dtList" item="item" open="(" close=")" separator=",">
  203. #{item}
  204. </foreach>
  205. and status = 1
  206. ) AS t
  207. WHERE t.rn = 1;
  208. </select>
  209. <update id="updateVideoStatus">
  210. update content_platform_video
  211. set status = 0,
  212. update_timestamp = #{now}
  213. where video_id = #{videoId}
  214. </update>
  215. <update id="updateVideoAggStatus">
  216. update content_platform_video_agg
  217. set status = 0,
  218. update_timestamp = #{now}
  219. where video_id = #{videoId}
  220. </update>
  221. </mapper>