QwMsgAuditMessageMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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.qw.mapper.QwMsgAuditMessageMapper">
  6. <resultMap type="QwMsgAuditMessage" id="QwMsgAuditMessageResult">
  7. <result property="id" column="id" />
  8. <result property="corpId" column="corp_id" />
  9. <result property="seq" column="seq" />
  10. <result property="msgId" column="msg_id" />
  11. <result property="msgTime" column="msg_time" />
  12. <result property="msgType" column="msg_type" />
  13. <result property="fromUser" column="from_user" />
  14. <result property="toList" column="to_list" />
  15. <result property="roomId" column="room_id" />
  16. <result property="conversationKey" column="conversation_key" />
  17. <result property="fromUserRole" column="from_user_role" />
  18. <result property="textContent" column="text_content" />
  19. <result property="mediaSdkfileid" column="media_sdkfileid" />
  20. <result property="mediaMd5sum" column="media_md5sum" />
  21. <result property="mediaSize" column="media_size" />
  22. <result property="mediaPlayLength" column="media_play_length" />
  23. <result property="mediaWidth" column="media_width" />
  24. <result property="mediaHeight" column="media_height" />
  25. <result property="mediaFileName" column="media_file_name" />
  26. <result property="mediaFileExt" column="media_file_ext" />
  27. <result property="mediaOssUrl" column="media_oss_url" />
  28. <result property="rawId" column="raw_id" />
  29. <result property="createTime" column="create_time" />
  30. </resultMap>
  31. <sql id="selectQwMsgAuditMessageVo">
  32. select id, corp_id, seq, msg_id, msg_time, msg_type, from_user, to_list, room_id, conversation_key, from_user_role, text_content, media_sdkfileid, media_md5sum, media_size, media_play_length, media_width, media_height, media_file_name, media_file_ext, media_oss_url, raw_id, create_time from qw_msg_audit_message
  33. </sql>
  34. <select id="selectQwMsgAuditMessageList" parameterType="QwMsgAuditMessage" resultMap="QwMsgAuditMessageResult">
  35. <include refid="selectQwMsgAuditMessageVo"/>
  36. <where>
  37. <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
  38. <if test="seq != null "> and seq = #{seq}</if>
  39. <if test="msgId != null and msgId != ''"> and msg_id = #{msgId}</if>
  40. <if test="msgTime != null "> and msg_time = #{msgTime}</if>
  41. <if test="msgType != null and msgType != ''"> and msg_type = #{msgType}</if>
  42. <if test="fromUser != null and fromUser != ''"> and from_user = #{fromUser}</if>
  43. <if test="toList != null and toList != ''"> and to_list = #{toList}</if>
  44. <if test="roomId != null and roomId != ''"> and room_id = #{roomId}</if>
  45. <if test="conversationKey != null and conversationKey != ''"> and conversation_key = #{conversationKey}</if>
  46. <if test="fromUserRole != null "> and from_user_role = #{fromUserRole}</if>
  47. <if test="textContent != null and textContent != ''"> and text_content = #{textContent}</if>
  48. <if test="mediaSdkfileid != null and mediaSdkfileid != ''"> and media_sdkfileid = #{mediaSdkfileid}</if>
  49. <if test="mediaMd5sum != null and mediaMd5sum != ''"> and media_md5sum = #{mediaMd5sum}</if>
  50. <if test="mediaSize != null "> and media_size = #{mediaSize}</if>
  51. <if test="mediaPlayLength != null "> and media_play_length = #{mediaPlayLength}</if>
  52. <if test="mediaWidth != null "> and media_width = #{mediaWidth}</if>
  53. <if test="mediaHeight != null "> and media_height = #{mediaHeight}</if>
  54. <if test="mediaFileName != null and mediaFileName != ''"> and media_file_name like concat('%', #{mediaFileName}, '%')</if>
  55. <if test="mediaFileExt != null and mediaFileExt != ''"> and media_file_ext = #{mediaFileExt}</if>
  56. <if test="rawId != null "> and raw_id = #{rawId}</if>
  57. </where>
  58. order by msg_time desc
  59. </select>
  60. <select id="selectQwMsgAuditMessageById" parameterType="Long" resultMap="QwMsgAuditMessageResult">
  61. <include refid="selectQwMsgAuditMessageVo"/>
  62. where id = #{id}
  63. </select>
  64. <insert id="insertQwMsgAuditMessage" parameterType="QwMsgAuditMessage" useGeneratedKeys="true" keyProperty="id">
  65. insert into qw_msg_audit_message
  66. <trim prefix="(" suffix=")" suffixOverrides=",">
  67. <if test="corpId != null and corpId != ''">corp_id,</if>
  68. <if test="seq != null">seq,</if>
  69. <if test="msgId != null">msg_id,</if>
  70. <if test="msgTime != null">msg_time,</if>
  71. <if test="msgType != null">msg_type,</if>
  72. <if test="fromUser != null">from_user,</if>
  73. <if test="toList != null">to_list,</if>
  74. <if test="roomId != null">room_id,</if>
  75. <if test="conversationKey != null">conversation_key,</if>
  76. <if test="fromUserRole != null">from_user_role,</if>
  77. <if test="textContent != null">text_content,</if>
  78. <if test="mediaSdkfileid != null">media_sdkfileid,</if>
  79. <if test="mediaMd5sum != null">media_md5sum,</if>
  80. <if test="mediaSize != null">media_size,</if>
  81. <if test="mediaPlayLength != null">media_play_length,</if>
  82. <if test="mediaWidth != null">media_width,</if>
  83. <if test="mediaHeight != null">media_height,</if>
  84. <if test="mediaFileName != null">media_file_name,</if>
  85. <if test="mediaFileExt != null">media_file_ext,</if>
  86. <if test="mediaOssUrl != null">media_oss_url,</if>
  87. <if test="rawId != null">raw_id,</if>
  88. <if test="createTime != null">create_time,</if>
  89. </trim>
  90. <trim prefix="values (" suffix=")" suffixOverrides=",">
  91. <if test="corpId != null and corpId != ''">#{corpId},</if>
  92. <if test="seq != null">#{seq},</if>
  93. <if test="msgId != null">#{msgId},</if>
  94. <if test="msgTime != null">#{msgTime},</if>
  95. <if test="msgType != null">#{msgType},</if>
  96. <if test="fromUser != null">#{fromUser},</if>
  97. <if test="toList != null">#{toList},</if>
  98. <if test="roomId != null">#{roomId},</if>
  99. <if test="conversationKey != null">#{conversationKey},</if>
  100. <if test="fromUserRole != null">#{fromUserRole},</if>
  101. <if test="textContent != null">#{textContent},</if>
  102. <if test="mediaSdkfileid != null">#{mediaSdkfileid},</if>
  103. <if test="mediaMd5sum != null">#{mediaMd5sum},</if>
  104. <if test="mediaSize != null">#{mediaSize},</if>
  105. <if test="mediaPlayLength != null">#{mediaPlayLength},</if>
  106. <if test="mediaWidth != null">#{mediaWidth},</if>
  107. <if test="mediaHeight != null">#{mediaHeight},</if>
  108. <if test="mediaFileName != null">#{mediaFileName},</if>
  109. <if test="mediaFileExt != null">#{mediaFileExt},</if>
  110. <if test="mediaOssUrl != null">#{mediaOssUrl},</if>
  111. <if test="rawId != null">#{rawId},</if>
  112. <if test="createTime != null">#{createTime},</if>
  113. </trim>
  114. </insert>
  115. <update id="updateQwMsgAuditMessage" parameterType="QwMsgAuditMessage">
  116. update qw_msg_audit_message
  117. <trim prefix="SET" suffixOverrides=",">
  118. <if test="corpId != null and corpId != ''">corp_id = #{corpId},</if>
  119. <if test="seq != null">seq = #{seq},</if>
  120. <if test="msgId != null">msg_id = #{msgId},</if>
  121. <if test="msgTime != null">msg_time = #{msgTime},</if>
  122. <if test="msgType != null">msg_type = #{msgType},</if>
  123. <if test="fromUser != null">from_user = #{fromUser},</if>
  124. <if test="toList != null">to_list = #{toList},</if>
  125. <if test="roomId != null">room_id = #{roomId},</if>
  126. <if test="conversationKey != null">conversation_key = #{conversationKey},</if>
  127. <if test="fromUserRole != null">from_user_role = #{fromUserRole},</if>
  128. <if test="textContent != null">text_content = #{textContent},</if>
  129. <if test="mediaSdkfileid != null">media_sdkfileid = #{mediaSdkfileid},</if>
  130. <if test="mediaMd5sum != null">media_md5sum = #{mediaMd5sum},</if>
  131. <if test="mediaSize != null">media_size = #{mediaSize},</if>
  132. <if test="mediaPlayLength != null">media_play_length = #{mediaPlayLength},</if>
  133. <if test="mediaWidth != null">media_width = #{mediaWidth},</if>
  134. <if test="mediaHeight != null">media_height = #{mediaHeight},</if>
  135. <if test="mediaFileName != null">media_file_name = #{mediaFileName},</if>
  136. <if test="mediaFileExt != null">media_file_ext = #{mediaFileExt},</if>
  137. <if test="mediaOssUrl != null">media_oss_url = #{mediaOssUrl},</if>
  138. <if test="rawId != null">raw_id = #{rawId},</if>
  139. <if test="createTime != null">create_time = #{createTime},</if>
  140. </trim>
  141. where id = #{id}
  142. </update>
  143. <delete id="deleteQwMsgAuditMessageById" parameterType="Long">
  144. delete from qw_msg_audit_message where id = #{id}
  145. </delete>
  146. <delete id="deleteQwMsgAuditMessageByIds" parameterType="String">
  147. delete from qw_msg_audit_message where id in
  148. <foreach item="id" collection="array" open="(" separator="," close=")">
  149. #{id}
  150. </foreach>
  151. </delete>
  152. <!-- 单聊会话列表 -->
  153. <select id="selectSingleConversationList" resultType="com.fs.qw.dto.QwMsgAuditConversationDTO">
  154. SELECT m.conversation_key AS conversationKey,
  155. MAX(m.msg_time) AS lastMsgTime
  156. FROM qw_msg_audit_message m
  157. WHERE m.corp_id = #{corpId}
  158. AND (m.room_id IS NULL OR m.room_id = '')
  159. AND m.conversation_key IS NOT NULL
  160. AND m.conversation_key &lt;&gt; ''
  161. AND m.conversation_key LIKE CONCAT(#{corpId}, ':p2p:%')
  162. AND (
  163. m.from_user = #{qwUserId}
  164. OR (
  165. m.to_list IS NOT NULL AND m.to_list &lt;&gt; '' AND m.to_list &lt;&gt; '[]'
  166. AND JSON_CONTAINS(CAST(m.to_list AS JSON), JSON_QUOTE(#{qwUserId}), '$')
  167. )
  168. )
  169. GROUP BY m.conversation_key
  170. ORDER BY lastMsgTime DESC
  171. </select>
  172. <!-- <insert id="batchInsertMessage" parameterType="com.fs.qw.domain.audit.QwMsgAuditMessage" useGeneratedKeys="true" keyProperty="id">-->
  173. <!-- insert into qw_msg_audit_message-->
  174. <!-- (corp_id, seq, msg_id, msg_time, msg_type, text_content,-->
  175. <!-- media_sdkfileid, media_md5sum, media_size, media_play_length,-->
  176. <!-- media_width, media_height, media_file_name, media_file_ext,-->
  177. <!-- raw_id, create_time)-->
  178. <!-- values-->
  179. <!-- (#{corpId}, #{seq}, #{msgId}, #{msgTime}, #{msgType}, #{textContent},-->
  180. <!-- #{mediaSdkfileid}, #{mediaMd5sum}, #{mediaSize}, #{mediaPlayLength},-->
  181. <!-- #{mediaWidth}, #{mediaHeight}, #{mediaFileName}, #{mediaFileExt},-->
  182. <!-- #{rawId}, #{createTime})-->
  183. <!-- </insert>-->
  184. </mapper>