ContentPlatformPlanMapperExt.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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, `status`, create_account_id,
  7. create_timestamp, update_timestamp)
  8. values (#{record.type}, #{record.publishStage}, #{record.accountId}, #{record.scene}, #{erecord.xternalId},
  9. #{record.selectVideoType}, #{record.status}, #{record.createAccountId}, #{record.createTimestamp},
  10. #{record.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} and status = 1
  79. <if test="id != null">
  80. and id != #{id}
  81. </if>
  82. limit 1
  83. </select>
  84. <select id="getVideoMaxDt" resultType="java.lang.String">
  85. select max(dt)
  86. from content_platform_video_agg
  87. </select>
  88. <select id="getVideoCount" resultType="java.lang.Integer">
  89. select count(1)
  90. from content_platform_video_agg
  91. where dt = #{dt} and status = 1 and score > #{minScore}
  92. <if test="param.title!= null and param.title!= ''">
  93. and title like concat('%', #{param.title}, '%')
  94. </if>
  95. <if test="param.category!= null and param.category!= ''">
  96. and category = #{param.category}
  97. </if>
  98. </select>
  99. <select id="getVideoList" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
  100. select *
  101. from content_platform_video_agg
  102. where dt = #{dt} and status = 1 and score > #{minScore}
  103. <if test="param.title!= null and param.title!= ''">
  104. and title like concat('%', #{param.title}, '%')
  105. </if>
  106. <if test="param.category!= null and param.category!= ''">
  107. and category = #{param.category}
  108. </if>
  109. order by score desc
  110. limit #{offset}, #{pageSize}
  111. </select>
  112. <select id="getVideoCategoryList" resultType="java.lang.String">
  113. select distinct category
  114. from content_platform_video_agg
  115. where dt = #{dt} and status = 1
  116. </select>
  117. <insert id="batchInsertContentPlatformVideo">
  118. insert into content_platform_video (dt, video_id, category, title, cover, video, score, create_timestamp)
  119. values
  120. <foreach collection="records" item="item" separator=",">
  121. (#{item.dt}, #{item.videoId}, #{item.category}, #{item.title}, #{item.cover}, #{item.video}, #{item.score},
  122. #{item.createTimestamp})
  123. </foreach>
  124. </insert>
  125. <insert id="batchInsertContentPlatformVideoAgg">
  126. insert into content_platform_video_agg (dt, video_id, category, title, cover, video, score, create_timestamp)
  127. values
  128. <foreach collection="records" item="item" separator=",">
  129. (#{item.dt}, #{item.videoId}, #{item.category}, #{item.title}, #{item.cover}, #{item.video}, #{item.score},
  130. #{item.createTimestamp})
  131. </foreach>
  132. </insert>
  133. <select id="getQwPlanCount" resultType="java.lang.Integer">
  134. select count(*)
  135. from content_platform_qw_plan
  136. where create_account_id = #{createAccountId}
  137. and type = #{param.type}
  138. and status = 1
  139. <if test="param.scene != null">
  140. and scene = #{param.scene}
  141. </if>
  142. <if test="param.title != null and param.title != ''">
  143. and id in (select plan_id from content_platform_qw_plan_video where title like concat('%', #{param.title},
  144. '%'))
  145. </if>
  146. </select>
  147. <select id="getQwPlanList"
  148. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan">
  149. select *
  150. from content_platform_qw_plan
  151. where create_account_id = #{createAccountId}
  152. and type = #{param.type}
  153. and status = 1
  154. <if test="param.scene != null">
  155. and scene = #{param.scene}
  156. </if>
  157. <if test="param.title != null and param.title != ''">
  158. and id in (select plan_id from content_platform_qw_plan_video where title like concat('%', #{param.title},
  159. '%'))
  160. </if>
  161. order by create_timestamp desc
  162. limit #{offset}, #{pageSize}
  163. </select>
  164. <insert id="batchInsertQwPlan">
  165. insert into content_platform_qw_plan (`type`, scene, page_url, root_source_id,
  166. create_account_id, create_timestamp, update_timestamp
  167. )
  168. values
  169. <foreach collection="records" item="item" separator=",">
  170. (#{item.type}, #{item.scene}, #{item.pageUrl}, #{item.rootSourceId},
  171. #{item.createAccountId}, #{item.createTimestamp}, #{item.updateTimestamp}
  172. )
  173. </foreach>
  174. </insert>
  175. <insert id="insertQwPlanReturnId" useGeneratedKeys="true" keyProperty="id">
  176. insert into content_platform_qw_plan (`type`, scene, page_url, root_source_id, create_account_id,
  177. create_timestamp, update_timestamp)
  178. values ( #{record.type}, #{record.scene}, #{record.pageUrl}, #{record.rootSourceId},
  179. #{record.createAccountId}, #{record.createTimestamp}, #{record.updateTimestamp})
  180. </insert>
  181. <select id="getGzhPlanVideoListByCooperateAccountId"
  182. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlanVideo">
  183. select cpgpv.*
  184. from content_platform_gzh_plan_video cpgpv
  185. join content_platform_gzh_plan cpgp on cpgp.id = cpgpv.plan_id
  186. join content_platform_gzh_account cpgac on cpgac.id = cpgp.account_id
  187. where cpgac.gh_id = #{ghId}
  188. and cpgac.status = 1
  189. and cpgp.scene = 0
  190. and cpgp.status = 1
  191. </select>
  192. <select id="getVideoAggList"
  193. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoAgg">
  194. SELECT t.video_id, t.category, t.title, t.cover, t.video, round(t.avg_score, 3) as score
  195. FROM (
  196. SELECT video_id, category, title, cover, video, AVG(score) OVER (PARTITION BY video_id) AS avg_score,
  197. ROW_NUMBER() OVER (PARTITION BY video_id ORDER BY dt DESC) AS rn
  198. FROM content_platform_video
  199. where dt in
  200. <foreach collection="dtList" item="item" open="(" close=")" separator=",">
  201. #{item}
  202. </foreach>
  203. and status = 1
  204. ) AS t
  205. WHERE t.rn = 1;
  206. </select>
  207. <update id="updateVideoStatus">
  208. update content_platform_video
  209. set status = 0,
  210. update_timestamp = #{now}
  211. where video_id = #{videoId}
  212. </update>
  213. <update id="updateVideoAggStatus">
  214. update content_platform_video_agg
  215. set status = 0,
  216. update_timestamp = #{now}
  217. where video_id = #{videoId}
  218. </update>
  219. </mapper>