LiveWatchLogMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. </mapper>