LiveMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.live.mapper.LiveMapper">
  6. <resultMap type="Live" id="LiveResult">
  7. <result property="liveId" column="live_id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="companyUserId" column="company_user_id" />
  10. <result property="talentId" column="talent_id" />
  11. <result property="liveName" column="live_name" />
  12. <result property="liveDesc" column="live_desc" />
  13. <result property="showType" column="show_type" />
  14. <result property="status" column="status" />
  15. <result property="anchorId" column="anchor_id" />
  16. <result property="liveType" column="live_type" />
  17. <result property="startTime" column="start_time" />
  18. <result property="finishTime" column="finish_time" />
  19. <result property="liveImgUrl" column="live_img_url" />
  20. <result property="liveConfig" column="live_config" />
  21. <result property="isShow" column="is_show" />
  22. <result property="isDel" column="is_del" />
  23. <result property="qwQrCode" column="qw_qr_code" />
  24. <result property="rtmpUrl" column="rtmp_url" />
  25. <result property="createTime" column="create_time" />
  26. <result property="createBy" column="create_by" />
  27. <result property="updateBy" column="update_by" />
  28. <result property="updateTime" column="update_time" />
  29. <result property="remark" column="remark" />
  30. <result property="configJson" column="config_json" />
  31. <result property="isAudit" column="is_audit" />
  32. <result property="idCardUrl" column="id_card_url" />
  33. <result property="liveCodeUrl" column="live_code_url" />
  34. <result property="globalVisible" column="global_visible" />
  35. </resultMap>
  36. <sql id="selectLiveVo">
  37. select live_id, company_id, company_user_id,talent_id, live_name, is_audit, live_desc, show_type, status, anchor_id, live_type, start_time, finish_time,
  38. live_img_url, live_config, id_card_url, is_show, is_del, qw_qr_code, rtmp_url, flv_hls_url,
  39. create_time, create_by, update_by, update_time, remark,config_json,global_visible from live
  40. </sql>
  41. <select id="liveList" parameterType="Live" resultMap="LiveResult">
  42. select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
  43. a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
  44. a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name,b.file_size,a.global_visible
  45. from live
  46. a
  47. left join live_video b on a.live_id = b.live_id
  48. left join company c on a.company_id = c.company_id
  49. where 1=1 and a.is_del = 0 and a.is_audit = 1 and a.is_show = 1 and a.status in (2,4) and b.video_type in (1,2)
  50. order by create_time desc
  51. </select>
  52. <select id="selectReadyStartLiveList" parameterType="Live" resultMap="LiveResult">
  53. select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
  54. a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
  55. a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name,b.file_size,a.global_visible
  56. from live
  57. a
  58. left join live_video b on a.live_id = b.live_id
  59. left join company c on a.company_id = c.company_id
  60. where 1=1 and a.is_del = 0 and a.is_audit = 1 and a.is_show = 1 and a.status in (1) and b.video_type in (1,2)
  61. and a.start_time &lt;= NOW() + INTERVAL 5 MINUTE
  62. and a.start_time >= NOW()
  63. order by create_time desc
  64. </select>
  65. <select id="selectLiveList" parameterType="com.fs.live.domain.Live" resultMap="LiveResult">
  66. select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
  67. a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
  68. a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,a.global_visible
  69. ,c.live_code_url,IFNULL(d.company_name, '总台') AS company_name,b.file_size
  70. from live a
  71. left join live_video b on a.live_id = b.live_id
  72. left join live_company_code c on a.live_id = c.live_id
  73. and c.company_id = #{companyId}
  74. and c.company_user_id = #{companyUserId}
  75. left join company d on a.company_id = d.company_id
  76. where 1=1 and a.is_del = 0 and b.video_type in (1,2)
  77. <if test="companyId != null "> and (a.company_id = #{companyId} or a.company_id is null )</if>
  78. <if test="companyName != null and companyName != ''">
  79. and (
  80. (d.company_name like concat('%', #{companyName}, '%'))
  81. or
  82. (#{companyName} = '总台' and a.company_id is null)
  83. )
  84. </if>
  85. <if test="talentId != null "> and talent_id = #{talentId}</if>
  86. <if test="liveName != null and liveName != ''"> and live_name like concat('%', #{liveName}, '%')</if>
  87. <if test="liveDesc != null and liveDesc != ''"> and live_desc = #{liveDesc}</if>
  88. <if test="showType != null "> and show_type = #{showType}</if>
  89. <if test="status != null "> and a.status = #{status}</if>
  90. <if test="anchorId != null "> and anchor_id = #{anchorId}</if>
  91. <if test="liveType != null "> and live_type = #{liveType}</if>
  92. <if test="startTimeS != null "> and a.start_time &gt; STR_TO_DATE(#{startTimeS}, '%Y-%m-%d %H:%i:%s')</if>
  93. <if test="endTimeE != null "> and a.finish_time &lt; STR_TO_DATE(#{endTimeE}, '%Y-%m-%d %H:%i:%s')</if>
  94. <if test="finishTime != null "> and finish_time = #{finishTime}</if>
  95. <if test="liveImgUrl != null and liveImgUrl != ''"> and live_img_url = #{liveImgUrl}</if>
  96. <if test="liveConfig != null and liveConfig != ''"> and live_config = #{liveConfig}</if>
  97. <if test="isShow != null "> and a.is_show = #{isShow}</if>
  98. <if test="qwQrCode != null and qwQrCode != ''"> and qw_qr_code = #{qwQrCode}</if>
  99. <if test="rtmpUrl != null and rtmpUrl != ''"> and rtmp_url = #{rtmpUrl}</if>
  100. <if test="flvHlsUrl != null and flvHlsUrl != ''"> and flv_hls_url = #{flvHlsUrl}</if>
  101. <if test="isAudit != null "> and is_audit = #{isAudit}</if>
  102. order by create_time desc
  103. </select>
  104. <select id="selectLiveByLiveId" parameterType="Long" resultMap="LiveResult">
  105. <include refid="selectLiveVo"/>
  106. where live_id = #{liveId}
  107. </select>
  108. <select id="selectLiveByLiveIdAndCompanyIdAndCompanyUserId" resultMap="LiveResult">
  109. <include refid="selectLiveVo"/>
  110. where live_id = #{liveId} and company_id = #{companyId} and company_user_id = #{companyUserId}
  111. </select>
  112. <select id="selectLiveToStudent" resultType="com.fs.live.domain.Live">
  113. <include refid="selectLiveVo"/>
  114. where 1=1
  115. <if test="status != null and status != ''">
  116. AND status = #{status}
  117. </if>
  118. <if test="liveName != null and liveName != null">
  119. AND live_name like concat('%', #{liveName}, '%')
  120. </if>
  121. <if test="startTime != null and startTime != '' and finishTime != null and finishTime != ''">
  122. AND start_time BETWEEN #{startTime} AND #{finishTime}
  123. </if>
  124. </select>
  125. <insert id="insertLive" parameterType="Live" useGeneratedKeys="true" keyProperty="liveId">
  126. insert into live
  127. <trim prefix="(" suffix=")" suffixOverrides=",">
  128. <if test="companyId != null">company_id,</if>
  129. <if test="companyUserId != null">company_user_id,</if>
  130. <if test="talentId != null">talent_id,</if>
  131. <if test="liveName != null">live_name,</if>
  132. <if test="liveDesc != null">live_desc,</if>
  133. <if test="showType != null">show_type,</if>
  134. <if test="status != null">status,</if>
  135. <if test="anchorId != null">anchor_id,</if>
  136. <if test="liveType != null">live_type,</if>
  137. <if test="startTime != null">start_time,</if>
  138. <if test="finishTime != null">finish_time,</if>
  139. <if test="liveImgUrl != null">live_img_url,</if>
  140. <if test="liveConfig != null">live_config,</if>
  141. <if test="isShow != null">is_show,</if>
  142. <if test="isDel != null">is_del,</if>
  143. <if test="qwQrCode != null">qw_qr_code,</if>
  144. <if test="rtmpUrl != null">rtmp_url,</if>
  145. <if test="createTime != null">create_time,</if>
  146. <if test="createBy != null">create_by,</if>
  147. <if test="updateBy != null">update_by,</if>
  148. <if test="updateTime != null">update_time,</if>
  149. <if test="remark != null">remark,</if>
  150. <if test="configJson != null">config_json,</if>
  151. <if test="flvHlsUrl != null">flv_hls_url,</if>
  152. <if test="isAudit != null">is_audit,</if>
  153. <if test="idCardUrl != null">id_card_url,</if>
  154. <if test="globalVisible != null">global_visible,</if>
  155. </trim>
  156. <trim prefix="values (" suffix=")" suffixOverrides=",">
  157. <if test="companyId != null">#{companyId},</if>
  158. <if test="companyUserId != null">#{companyUserId},</if>
  159. <if test="talentId != null">#{talentId},</if>
  160. <if test="liveName != null">#{liveName},</if>
  161. <if test="liveDesc != null">#{liveDesc},</if>
  162. <if test="showType != null">#{showType},</if>
  163. <if test="status != null">#{status},</if>
  164. <if test="anchorId != null">#{anchorId},</if>
  165. <if test="liveType != null">#{liveType},</if>
  166. <if test="startTime != null">#{startTime},</if>
  167. <if test="finishTime != null">#{finishTime},</if>
  168. <if test="liveImgUrl != null">#{liveImgUrl},</if>
  169. <if test="liveConfig != null">#{liveConfig},</if>
  170. <if test="isShow != null">#{isShow},</if>
  171. <if test="isDel != null">#{isDel},</if>
  172. <if test="qwQrCode != null">#{qwQrCode},</if>
  173. <if test="rtmpUrl != null">#{rtmpUrl},</if>
  174. <if test="createTime != null">#{createTime},</if>
  175. <if test="createBy != null">#{createBy},</if>
  176. <if test="updateBy != null">#{updateBy},</if>
  177. <if test="updateTime != null">#{updateTime},</if>
  178. <if test="remark != null">#{remark},</if>
  179. <if test="configJson != null">#{configJson},</if>
  180. <if test="flvHlsUrl != null">#{flvHlsUrl},</if>
  181. <if test="isAudit != null">#{isAudit},</if>
  182. <if test="idCardUrl != null">#{idCardUrl},</if>
  183. <if test="globalVisible != null">#{globalVisible},</if>
  184. </trim>
  185. </insert>
  186. <update id="updateLive" parameterType="Live">
  187. update live
  188. <trim prefix="SET" suffixOverrides=",">
  189. <if test="talentId != null">talent_id = #{talentId},</if>
  190. <if test="liveName != null">live_name = #{liveName},</if>
  191. <if test="liveDesc != null">live_desc = #{liveDesc},</if>
  192. <if test="showType != null">show_type = #{showType},</if>
  193. <if test="status != null">status = #{status},</if>
  194. <if test="anchorId != null">anchor_id = #{anchorId},</if>
  195. <if test="liveType != null">live_type = #{liveType},</if>
  196. <if test="startTime != null">start_time = #{startTime},</if>
  197. <if test="finishTime != null">finish_time = #{finishTime},</if>
  198. <if test="finishTime == null">finish_time = NULL,</if>
  199. <if test="liveImgUrl != null">live_img_url = #{liveImgUrl},</if>
  200. <if test="liveConfig != null">live_config = #{liveConfig},</if>
  201. <if test="isShow != null">is_show = #{isShow},</if>
  202. <if test="isDel != null">is_del = #{isDel},</if>
  203. <if test="qwQrCode != null">qw_qr_code = #{qwQrCode},</if>
  204. <if test="rtmpUrl != null">rtmp_url = #{rtmpUrl},</if>
  205. <if test="createTime != null">create_time = #{createTime},</if>
  206. <if test="createBy != null">create_by = #{createBy},</if>
  207. <if test="updateBy != null">update_by = #{updateBy},</if>
  208. <if test="updateTime != null">update_time = #{updateTime},</if>
  209. <if test="remark != null">remark = #{remark},</if>
  210. <if test="configJson != null">config_json = #{configJson},</if>
  211. <if test="flvHlsUrl != null">flv_hls_url = #{flvHlsUrl},</if>
  212. <if test="isAudit != null">is_audit = #{isAudit},</if>
  213. <if test="idCardUrl != null">id_card_url = #{idCardUrl},</if>
  214. <if test="globalVisible != null">global_visible = #{globalVisible},</if>
  215. </trim>
  216. where live_id = #{liveId}
  217. </update>
  218. <delete id="deleteLiveByLiveId" parameterType="Long">
  219. delete from live where live_id = #{liveId}
  220. </delete>
  221. <delete id="deleteLiveByLiveIds" parameterType="String">
  222. delete from live where live_id in
  223. <foreach item="liveId" collection="array" open="(" separator="," close=")">
  224. #{liveId}
  225. </foreach>
  226. <if test="live != null">
  227. <if test="live.companyId != null"> and company_id = #{live.companyId}</if>
  228. </if>
  229. </delete>
  230. <update id="updateBatchLiveList" parameterType="com.fs.live.vo.LiveListVo">
  231. update live set is_show = #{liveVo.isShow},status = 3,finish_time = NOW() where live_id in
  232. <foreach item="liveId" collection="liveVo.liveIds" open="(" separator="," close=")">
  233. #{liveId}
  234. </foreach>
  235. <if test="liveVo.companyId != null">
  236. <if test="liveVo.companyId != null"> and company_id = #{liveVo.companyId}</if>
  237. </if>
  238. </update>
  239. <update id="deleteBatchLiveList" parameterType="com.fs.live.vo.LiveListVo">
  240. update live set is_del = 1
  241. WHERE company_id = #{liveVo.companyId} and company_user_id = #{liveVo.companyUserId} and live_id IN
  242. <foreach item="liveId" collection="liveVo.liveIds" open="(" separator="," close=")">
  243. #{liveId}
  244. </foreach>
  245. <if test="liveVo.companyId != null">
  246. <if test="liveVo.companyId != null"> and company_id = #{liveVo.companyId}</if>
  247. </if>
  248. </update>
  249. <update id="handleShelfOrUnAdmin" parameterType="com.fs.live.vo.LiveListVo">
  250. update live set is_show = #{liveVo.isShow},status = 3,finish_time = NOW() where live_id in
  251. <foreach item="liveId" collection="liveVo.liveIds" open="(" separator="," close=")">
  252. #{liveId}
  253. </foreach>
  254. <if test="liveVo.companyId != null">
  255. <if test="liveVo.companyId != null"> and company_id = #{liveVo.companyId}</if>
  256. </if>
  257. </update>
  258. <update id="handleDeleteSelectedAdmin" parameterType="com.fs.live.vo.LiveListVo">
  259. update live set is_del = 1
  260. WHERE live_id IN
  261. <foreach item="liveId" collection="liveVo.liveIds" open="(" separator="," close=")">
  262. #{liveId}
  263. </foreach>
  264. <if test="liveVo.companyId != null">
  265. <if test="liveVo.companyId != null"> and company_id = #{liveVo.companyId}</if>
  266. </if>
  267. </update>
  268. <update id="updateLiveList">
  269. <foreach collection="liveList" item="live" separator=";">
  270. UPDATE live
  271. <set>
  272. <if test="live.liveName != null and live.liveName != ''">live_name = #{live.liveName},</if>
  273. <if test="live.liveType != null">live_type = #{live.liveType},</if>
  274. <if test="live.status != null">status = #{live.status},</if>
  275. <if test="live.startTime != null">start_time = #{live.startTime},</if>
  276. <if test="live.finishTime != null">finish_time = #{live.finishTime},</if>
  277. <if test="live.rtmpUrl != null and live.rtmpUrl != ''">rtmp_url = #{live.rtmpUrl},</if>
  278. <if test="live.flvHlsUrl != null and live.flvHlsUrl != ''">flv_hls_url = #{live.flvHlsUrl},</if>
  279. <if test="live.videoUrl != null and live.videoUrl != ''">video_url = #{live.videoUrl},</if>
  280. <if test="live.duration != null and live.duration != ''">duration = #{live.duration},</if>
  281. <if test="live.companyId != null">company_id = #{live.companyId},</if>
  282. <if test="live.companyUserId != null">company_user_id = #{live.companyUserId},</if>
  283. <if test="live.isAudit != null">is_audit = #{live.isAudit},</if>
  284. <if test="live.isShow != null">is_show = #{live.isShow},</if>
  285. <if test="live.isDel != null">is_del = #{live.isDel},</if>
  286. <if test="live.liveConfig != null and live.liveConfig != ''">live_config = #{live.liveConfig},</if>
  287. <if test="live.remark != null and live.remark != ''">remark = #{live.remark},</if>
  288. <if test="live.globalVisible != null and live.globalVisible != ''">global_visible = #{live.globalVisible},</if>
  289. update_time = NOW()
  290. </set>
  291. WHERE live_id = #{live.liveId}
  292. </foreach>
  293. </update>
  294. <update id="updateStatusAndTimeBatchById">
  295. <foreach collection="liveList" item="live" separator=";">
  296. UPDATE live
  297. <set>
  298. <if test="live.status != null">status = #{live.status},</if>
  299. update_time = NOW()
  300. </set>
  301. WHERE live_id = #{live.liveId}
  302. </foreach>
  303. </update>
  304. <select id="liveShowList" resultMap="LiveResult">
  305. select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
  306. a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
  307. a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name,b.file_size
  308. from live
  309. a
  310. left join live_video b on a.live_id = b.live_id
  311. left join company c on a.company_id = c.company_id
  312. where 1=1 and a.is_del = 0 and a.is_audit = 1 and a.is_show = 1 and a.status in (2,4) and b.video_type in (1,2)
  313. and (
  314. <if test="companyIds != null and companyIds.size() > 0">
  315. a.company_id in
  316. <foreach collection="companyIds" item="id" open="(" separator="," close=")">
  317. #{id}
  318. </foreach>
  319. or
  320. </if>
  321. a.company_id is null)
  322. order by create_time desc
  323. </select>
  324. <select id="selectLiveShowReadyStartLiveList" resultMap="LiveResult">
  325. select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
  326. a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
  327. a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name,b.file_size
  328. from live
  329. a
  330. left join live_video b on a.live_id = b.live_id
  331. left join company c on a.company_id = c.company_id
  332. where 1=1 and a.is_del = 0 and a.is_audit = 1 and a.is_show = 1 and a.status in (1) and b.video_type in (1,2)
  333. and a.start_time &lt;= NOW() + INTERVAL 5 MINUTE
  334. and a.start_time >= NOW()
  335. and (
  336. <if test="companyIds != null and companyIds.size() > 0">
  337. a.company_id in
  338. <foreach collection="companyIds" item="id" open="(" separator="," close=")">
  339. #{id}
  340. </foreach>
  341. or
  342. </if>
  343. a.company_id is null)
  344. order by create_time desc
  345. </select>
  346. </mapper>