LiveWatchLogMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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.LiveWatchLogMapper">
  6. <resultMap type="LiveWatchLog" id="LiveWatchLogResult">
  7. <result property="logId" column="log_id" />
  8. <result property="userId" column="user_id" />
  9. <result property="liveId" column="live_id" />
  10. <result property="logType" column="log_type" />
  11. <result property="createTime" column="create_time" />
  12. <result property="updateTime" column="update_time" />
  13. <result property="externalContactId" column="external_contact_id" />
  14. <result property="companyUserId" column="company_user_id" />
  15. <result property="companyId" column="company_id" />
  16. <result property="finishTime" column="finish_time" />
  17. <result property="createBy" column="create_by" />
  18. <result property="sopCreateTime" column="sop_create_time" />
  19. <result property="sendAppId" column="send_app_id" />
  20. <result property="logSource" column="log_source" />
  21. <result property="qwUserId" column="qw_user_id" />
  22. <result property="watchType" column="watch_type" />
  23. <result property="corpId" column="corp_id" />
  24. <result property="liveBuy" column="live_buy" />
  25. <result property="replayBuy" column="replay_buy" />
  26. </resultMap>
  27. <sql id="selectLiveWatchLogVo">
  28. select log_id, user_id, live_id, log_type, create_time, update_time, external_contact_id, company_user_id, company_id, finish_time, create_by, sop_create_time,live_buy,replay_buy,
  29. send_app_id, log_source, qw_user_id,watch_type,corp_id from live_watch_log
  30. </sql>
  31. <select id="selectLiveWatchLogList" parameterType="LiveWatchLog" resultMap="LiveWatchLogResult">
  32. <include refid="selectLiveWatchLogVo"/>
  33. <where>
  34. <if test="userId != null "> and user_id = #{userId}</if>
  35. <if test="liveId != null "> and live_id = #{liveId}</if>
  36. <if test="logType != null "> and log_type = #{logType}</if>
  37. <if test="externalContactId != null "> and external_contact_id = #{externalContactId}</if>
  38. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  39. <if test="companyId != null "> and company_id = #{companyId}</if>
  40. <if test="finishTime != null "> and finish_time = #{finishTime}</if>
  41. <if test="sopCreateTime != null "> and sop_create_time = #{sopCreateTime}</if>
  42. <if test="sendAppId != null and sendAppId != ''"> and send_app_id = #{sendAppId}</if>
  43. <if test="logSource != null "> and log_source = #{logSource}</if>
  44. <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
  45. <if test="watchType != null">and watch_type = #{watchType} </if>
  46. <if test="corpId != null">and corp_id = #{corpId} </if>
  47. <if test="liveBuy != null">and live_buy = #{liveBuy} </if>
  48. <if test="replayBuy != null">and replay_buy = #{replayBuy} </if>
  49. </where>
  50. </select>
  51. <select id="selectLiveWatchLogByLogId" parameterType="Long" resultMap="LiveWatchLogResult">
  52. <include refid="selectLiveWatchLogVo"/>
  53. where log_id = #{logId}
  54. </select>
  55. <insert id="insertLiveWatchLog" parameterType="LiveWatchLog" useGeneratedKeys="true" keyProperty="logId">
  56. insert into live_watch_log
  57. <trim prefix="(" suffix=")" suffixOverrides=",">
  58. <if test="userId != null">user_id,</if>
  59. <if test="liveId != null">live_id,</if>
  60. <if test="logType != null">log_type,</if>
  61. <if test="createTime != null">create_time,</if>
  62. <if test="updateTime != null">update_time,</if>
  63. <if test="externalContactId != null">external_contact_id,</if>
  64. <if test="companyUserId != null">company_user_id,</if>
  65. <if test="companyId != null">company_id,</if>
  66. <if test="finishTime != null">finish_time,</if>
  67. <if test="createBy != null">create_by,</if>
  68. <if test="sopCreateTime != null">sop_create_time,</if>
  69. <if test="sendAppId != null">send_app_id,</if>
  70. <if test="logSource != null">log_source,</if>
  71. <if test="qwUserId != null">qw_user_id,</if>
  72. <if test="watchType != null">watch_type,</if>
  73. <if test="corpId != null">corp_id,</if>
  74. <if test="liveBuy != null">live_buy,</if>
  75. <if test="replayBuy != null">replay_buy,</if>
  76. </trim>
  77. <trim prefix="values (" suffix=")" suffixOverrides=",">
  78. <if test="userId != null">#{userId},</if>
  79. <if test="liveId != null">#{liveId},</if>
  80. <if test="logType != null">#{logType},</if>
  81. <if test="createTime != null">#{createTime},</if>
  82. <if test="updateTime != null">#{updateTime},</if>
  83. <if test="externalContactId != null">#{externalContactId},</if>
  84. <if test="companyUserId != null">#{companyUserId},</if>
  85. <if test="companyId != null">#{companyId},</if>
  86. <if test="finishTime != null">#{finishTime},</if>
  87. <if test="createBy != null">#{createBy},</if>
  88. <if test="sopCreateTime != null">#{sopCreateTime},</if>
  89. <if test="sendAppId != null">#{sendAppId},</if>
  90. <if test="logSource != null">#{logSource},</if>
  91. <if test="qwUserId != null">#{qwUserId},</if>
  92. <if test="watchType != null">#{watchType},</if>
  93. <if test="corpId != null">#{corpId},</if>
  94. <if test="liveBuy != null">#{liveBuy},</if>
  95. <if test="replayBuy != null">#{replayBuy},</if>
  96. </trim>
  97. </insert>
  98. <update id="updateLiveWatchLog" parameterType="LiveWatchLog">
  99. update live_watch_log
  100. <trim prefix="SET" suffixOverrides=",">
  101. <if test="userId != null">user_id = #{userId},</if>
  102. <if test="liveId != null">live_id = #{liveId},</if>
  103. <if test="logType != null">log_type = #{logType},</if>
  104. <if test="createTime != null">create_time = #{createTime},</if>
  105. <if test="updateTime != null">update_time = #{updateTime},</if>
  106. <if test="externalContactId != null">external_contact_id = #{externalContactId},</if>
  107. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  108. <if test="companyId != null">company_id = #{companyId},</if>
  109. <if test="finishTime != null">finish_time = #{finishTime},</if>
  110. <if test="createBy != null">create_by = #{createBy},</if>
  111. <if test="sopCreateTime != null">sop_create_time = #{sopCreateTime},</if>
  112. <if test="sendAppId != null">send_app_id = #{sendAppId},</if>
  113. <if test="logSource != null">log_source = #{logSource},</if>
  114. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  115. <if test="watchType != null">watch_type = #{watchType},</if>
  116. <if test="corpId != null">corp_id = #{corpId},</if>
  117. <if test="liveBuy != null">live_buy = #{liveBuy},</if>
  118. <if test="replayBuy != null">replay_buy = #{replayBuy},</if>
  119. </trim>
  120. where log_id = #{logId}
  121. </update>
  122. <delete id="deleteLiveWatchLogByLogId" parameterType="Long">
  123. delete from live_watch_log where log_id = #{logId}
  124. </delete>
  125. <delete id="deleteLiveWatchLogByLogIds" parameterType="String">
  126. delete from live_watch_log where log_id in
  127. <foreach item="logId" collection="array" open="(" separator="," close=")">
  128. #{logId}
  129. </foreach>
  130. </delete>
  131. <insert id="insertLiveWatchLogBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="logId">
  132. INSERT INTO live_watch_log
  133. <trim prefix="(" suffix=")" suffixOverrides=",">
  134. <if test="liveWatchLogs != null and liveWatchLogs.size() &gt; 0">
  135. <foreach collection="liveWatchLogs" item="item" index="index" open="" close="" separator="">
  136. <if test="index == 0">
  137. <if test="item.userId != null">user_id,</if>
  138. <if test="item.liveId != null">live_id,</if>
  139. <if test="item.logType != null">log_type,</if>
  140. <if test="item.createTime != null">create_time,</if>
  141. <if test="item.updateTime != null">update_time,</if>
  142. <if test="item.externalContactId != null">external_contact_id,</if>
  143. <if test="item.companyUserId != null">company_user_id,</if>
  144. <if test="item.companyId != null">company_id,</if>
  145. <if test="item.finishTime != null">finish_time,</if>
  146. <if test="item.createBy != null">create_by,</if>
  147. <if test="item.sopCreateTime != null">sop_create_time,</if>
  148. <if test="item.sendAppId != null">send_app_id,</if>
  149. <if test="item.logSource != null">log_source,</if>
  150. <if test="item.qwUserId != null">qw_user_id,</if>
  151. <if test="item.watchType != null">watch_type,</if>
  152. <if test="item.corpId != null">corp_id,</if>
  153. <if test="item.liveBuy != null">live_buy,</if>
  154. <if test="item.replayBuy != null">replay_buy,</if>
  155. </if>
  156. </foreach>
  157. </if>
  158. </trim>
  159. <trim prefix="VALUES">
  160. <foreach collection="liveWatchLogs" item="item" separator=",">
  161. (<trim suffixOverrides=",">
  162. <if test="item.userId != null">#{item.userId},</if>
  163. <if test="item.liveId != null">#{item.liveId},</if>
  164. <if test="item.logType != null">#{item.logType},</if>
  165. <if test="item.createTime != null">#{item.createTime},</if>
  166. <if test="item.updateTime != null">#{item.updateTime},</if>
  167. <if test="item.externalContactId != null">#{item.externalContactId},</if>
  168. <if test="item.companyUserId != null">#{item.companyUserId},</if>
  169. <if test="item.companyId != null">#{item.companyId},</if>
  170. <if test="item.finishTime != null">#{item.finishTime},</if>
  171. <if test="item.createBy != null">#{item.createBy},</if>
  172. <if test="item.sopCreateTime != null">#{item.sopCreateTime},</if>
  173. <if test="item.sendAppId != null">#{item.sendAppId},</if>
  174. <if test="item.logSource != null">#{item.logSource},</if>
  175. <if test="item.qwUserId != null">#{item.qwUserId},</if>
  176. <if test="item.watchType != null">#{item.watchType},</if>
  177. <if test="item.corpId != null">#{item.corpId},</if>
  178. <if test="item.liveBuy != null">#{item.liveBuy},</if>
  179. <if test="item.replayBuy != null">#{item.replayBuy},</if>
  180. </trim>)
  181. </foreach>
  182. </trim>
  183. </insert>
  184. <update id="updateLiveWatchLogCondition" parameterType="com.fs.live.domain.LiveWatchLog" >
  185. update live_watch_log
  186. set update_time = NOW(),
  187. sop_create_time = NOW(),
  188. send_app_id = #{liveWatchLog.sendAppId},
  189. log_source = #{liveWatchLog.logSource}
  190. where external_contact_id = #{liveWatchLog.externalContactId}
  191. and live_id = #{liveWatchLog.liveId}
  192. and qw_user_id = #{liveWatchLog.qwUserId}
  193. </update>
  194. <select id="selectOneLogByLiveIdAndQwUserIdAndExternalId" resultType="com.fs.live.domain.LiveWatchLog">
  195. select * from live_watch_log where live_id = #{liveId} and qw_user_id = #{qwUserId} and external_contact_id = #{externalContactId}
  196. </select>
  197. <!-- todo lmx-->
  198. <select id="selectLiveWatchLogByLiveId" resultType="com.fs.live.domain.LiveWatchLog">
  199. select * from live_watch_log where live_id = #{liveId}
  200. </select>
  201. <select id="selectLiveWatchLogListInfo" parameterType="LiveWatchLog" resultType="com.fs.live.vo.LiveWatchLogListVO">
  202. select
  203. t2.nick_name as userName,
  204. t2.avatar as userAvatar,
  205. t3.live_name,
  206. t4.name as qwExternalName,
  207. t4.avatar as qwExternalAvatar,
  208. t5.nick_name as companyUserName,
  209. t6.qw_user_name,
  210. t1.*
  211. from live_watch_log t1
  212. left join fs_user t2 on t1.user_id = t2.user_id
  213. left join live t3 on t3.live_id = t1.live_id
  214. left join qw_external_contact t4 on t4.id = t1.external_contact_id
  215. left join company_user t5 on t5.user_id = t1.company_user_id
  216. left join qw_user t6 on t6.id = t1.qw_user_id
  217. <where>
  218. <if test="userId != null "> and t1.user_id = #{userId}</if>
  219. <if test="liveId != null "> and t1.live_id = #{liveId}</if>
  220. <if test="logType != null "> and t1.log_type = #{logType}</if>
  221. <if test="externalContactId != null "> and t1.external_contact_id = #{externalContactId}</if>
  222. <if test="companyId != null "> and t1.company_id = #{companyId}</if>
  223. <if test="companyUserId != null "> and t1.company_user_id = #{companyUserId}</if>
  224. <if test="finishTime != null "> and t1.finish_time = #{finishTime}</if>
  225. <if test="sopCreateTime != null "> and t1.sop_create_time = #{sopCreateTime}</if>
  226. <if test="sendAppId != null and sendAppId != ''"> and t1.send_app_id = #{sendAppId}</if>
  227. <if test="logSource != null "> and t1.log_source = #{logSource}</if>
  228. <if test="qwUserId != null and qwUserId != ''"> and t1.qw_user_id = #{qwUserId}</if>
  229. <if test="watchType != null">and t1.watch_type = #{watchType} </if>
  230. <if test="corpId != null">and t1.corp_id = #{corpId} </if>
  231. <if test="liveBuy != null">and t1.live_buy = #{liveBuy} </if>
  232. <if test="replayBuy != null">and t1.replay_buy = #{replayBuy} </if>
  233. </where>
  234. </select>
  235. <!-- 批量更新直播看课记录 -->
  236. <update id="batchUpdateLiveWatchLog" parameterType="java.util.List">
  237. UPDATE live_watch_log
  238. <set>
  239. <if test="list != null and list.size() > 0 and list[0].logType != null">
  240. log_type = CASE log_id
  241. <foreach collection="list" item="item">
  242. WHEN #{item.logId} THEN #{item.logType}
  243. </foreach>
  244. ELSE log_type
  245. END,
  246. </if>
  247. <if test="list != null and list.size() > 0 and list[0].updateTime != null">
  248. update_time = CASE log_id
  249. <foreach collection="list" item="item">
  250. WHEN #{item.logId} THEN #{item.updateTime}
  251. </foreach>
  252. ELSE update_time
  253. END,
  254. </if>
  255. <if test="list != null and list.size() > 0 and list[0].finishTime != null">
  256. finish_time = CASE log_id
  257. <foreach collection="list" item="item">
  258. WHEN #{item.logId} THEN #{item.finishTime}
  259. </foreach>
  260. ELSE finish_time
  261. END,
  262. </if>
  263. <if test="list != null and list.size() > 0 and list[0].sopCreateTime != null">
  264. sop_create_time = CASE log_id
  265. <foreach collection="list" item="item">
  266. WHEN #{item.logId} THEN #{item.sopCreateTime}
  267. </foreach>
  268. ELSE sop_create_time
  269. END,
  270. </if>
  271. <if test="list != null and list.size() > 0 and list[0].sendAppId != null">
  272. send_app_id = CASE log_id
  273. <foreach collection="list" item="item">
  274. WHEN #{item.logId} THEN #{item.sendAppId}
  275. </foreach>
  276. ELSE send_app_id
  277. END,
  278. </if>
  279. <if test="list != null and list.size() > 0 and list[0].logSource != null">
  280. log_source = CASE log_id
  281. <foreach collection="list" item="item">
  282. WHEN #{item.logId} THEN #{item.logSource}
  283. </foreach>
  284. ELSE log_source
  285. END,
  286. </if>
  287. <if test="list != null and list.size() > 0 and list[0].watchType != null">
  288. watch_type = CASE log_id
  289. <foreach collection="list" item="item">
  290. WHEN #{item.logId} THEN #{item.watchType}
  291. </foreach>
  292. ELSE watch_type
  293. END,
  294. </if>
  295. <if test="list != null and list.size() > 0 and list[0].corpId != null">
  296. corp_id = CASE log_id
  297. <foreach collection="list" item="item">
  298. WHEN #{item.logId} THEN #{item.corpId}
  299. </foreach>
  300. ELSE corp_id
  301. END,
  302. </if>
  303. <if test="list != null and list.size() > 0 and list[0].liveBuy != null">
  304. live_buy = CASE log_id
  305. <foreach collection="list" item="item">
  306. WHEN #{item.logId} THEN #{item.liveBuy}
  307. </foreach>
  308. ELSE live_buy
  309. END,
  310. </if>
  311. <if test="list != null and list.size() > 0 and list[0].replayBuy != null">
  312. replay_buy = CASE log_id
  313. <foreach collection="list" item="item">
  314. WHEN #{item.logId} THEN #{item.replayBuy}
  315. </foreach>
  316. ELSE replay_buy
  317. END
  318. </if>
  319. </set>
  320. WHERE log_id IN
  321. <foreach collection="list" item="item" open="(" separator="," close=")">
  322. #{item.logId}
  323. </foreach>
  324. </update>
  325. </mapper>