QwGroupChatMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.QwGroupChatMapper">
  6. <resultMap type="QwGroupChat" id="QwGroupChatResult">
  7. <result property="chatId" column="chat_id" />
  8. <result property="name" column="name" />
  9. <result property="owner" column="owner" />
  10. <result property="notice" column="notice" />
  11. <result property="memberVersion" column="member_version" />
  12. <result property="status" column="status" />
  13. <result property="companyId" column="company_id" />
  14. <result property="corpId" column="corp_id" />
  15. <result property="createTime" column="create_time" />
  16. <result property="updateTime" column="update_time" />
  17. <result property="createAt" column="create_at" />
  18. <result property="groupSize" column="group_size" />
  19. <result property="todayJoin" column="today_join" />
  20. <result property="todayOut" column="today_out" />
  21. <result property="allOutGroup" column="all_out_group" />
  22. </resultMap>
  23. <sql id="selectQwGroupChatVo">
  24. select chat_id, name, owner, notice, member_version, status, company_id, corp_id, create_time, update_time, create_at, group_size, today_join, today_out, all_out_group from qw_group_chat
  25. </sql>
  26. <select id="selectQwGroupChatList" parameterType="QwGroupChat" resultMap="QwGroupChatResult">
  27. <include refid="selectQwGroupChatVo"/>
  28. <where>
  29. <if test="chatId != null and chatId != ''"> and chat_id like concat('%', #{chatId}, '%')</if>
  30. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  31. <if test="owner != null and owner != ''"> and owner = #{owner}</if>
  32. <if test="notice != null and notice != ''"> and notice like concat('%', #{notice}, '%')</if>
  33. <if test="memberVersion != null and memberVersion != ''"> and member_version = #{memberVersion}</if>
  34. <if test="status != null and status != ''"> and status = #{status}</if>
  35. <if test="companyId != null "> and company_id = #{companyId}</if>
  36. <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
  37. <if test="createAt != null and createAt != ''"> and create_at = #{createAt}</if>
  38. <if test="groupSize != null "> and group_size = #{groupSize}</if>
  39. <if test="todayJoin != null "> and today_join = #{todayJoin}</if>
  40. <if test="todayOut != null "> and today_out = #{todayOut}</if>
  41. <if test="allOutGroup != null "> and all_out_group = #{allOutGroup}</if>
  42. </where>
  43. </select>
  44. <select id="selectQwGroupChatByChatId" parameterType="String" resultMap="QwGroupChatResult">
  45. <include refid="selectQwGroupChatVo"/>
  46. where chat_id = #{chatId}
  47. </select>
  48. <select id="selectQwGroupChatByChatIds" resultType="com.fs.qw.domain.QwGroupChat">
  49. select * from qw_group_chat where chat_id in <foreach collection="ids" open="(" separator="," close=")" item="item">#{item}</foreach>
  50. </select>
  51. <select id="selectQwGroupChatTransferList" resultType="com.fs.qw.vo.QwGroupChatTransferVO">
  52. select
  53. gc.*,
  54. qu.id qwId,
  55. qu.qw_user_name,
  56. cu.nick_name ownerName
  57. from qw_group_chat gc
  58. left join qw_user qu on qu.qw_user_id = gc.owner and qu.is_del = 0 and qu.corp_id = gc.corp_id
  59. left join company_user cu on cu.user_id = qu.company_user_id
  60. <where>
  61. <if test="corpId != null and corpId != ''">
  62. and gc.corp_id = #{corpId}
  63. </if>
  64. <if test="name != null and name != ''">
  65. and gc.name like concat('%', #{name}, '%')
  66. </if>
  67. <if test="ownerName != null and ownerName != ''">
  68. and cu.nick_name like concat('%', #{ownerName}, '%')
  69. </if>
  70. <if test="qwName != null and qwName != ''">
  71. and qu.qw_user_name like concat('%', #{qwName}, '%')
  72. </if>
  73. <if test="statusList != null and statusList.size() > 0">
  74. and gc.status in
  75. <foreach collection="statusList" separator="," item="item" open="(" close=")">
  76. #{item}
  77. </foreach>
  78. </if>
  79. </where>
  80. order by gc.update_time desc
  81. </select>
  82. <insert id="insertOrUpdateQwGroupChat" parameterType="QwGroupChat">
  83. insert into qw_group_chat
  84. <trim prefix="(" suffix=")" suffixOverrides=",">
  85. <if test="chatId != null">chat_id,</if>
  86. <if test="name != null">name,</if>
  87. <if test="owner != null">owner,</if>
  88. <if test="notice != null">notice,</if>
  89. <if test="memberVersion != null">member_version,</if>
  90. <if test="status != null">status,</if>
  91. <if test="companyId != null">company_id,</if>
  92. <if test="corpId != null">corp_id,</if>
  93. <if test="createTime != null">create_time,</if>
  94. <if test="updateTime != null">update_time,</if>
  95. <if test="createAt != null">create_at,</if>
  96. <if test="groupSize != null">group_size,</if>
  97. <if test="todayJoin != null">today_join,</if>
  98. <if test="todayOut != null">today_out,</if>
  99. <if test="allOutGroup != null">all_out_group,</if>
  100. <if test="sopId != null">sop_id,</if>
  101. <if test="qwUserId != null">qw_user_id,</if>
  102. <if test="roomid != null">roomid,</if>
  103. </trim>
  104. <trim prefix="values (" suffix=")" suffixOverrides=",">
  105. <if test="chatId != null">#{chatId},</if>
  106. <if test="name != null">#{name},</if>
  107. <if test="owner != null">#{owner},</if>
  108. <if test="notice != null">#{notice},</if>
  109. <if test="memberVersion != null">#{memberVersion},</if>
  110. <if test="status != null">#{status},</if>
  111. <if test="companyId != null">#{companyId},</if>
  112. <if test="corpId != null">#{corpId},</if>
  113. <if test="createTime != null">#{createTime},</if>
  114. <if test="updateTime != null">#{updateTime},</if>
  115. <if test="createAt != null">#{createAt},</if>
  116. <if test="groupSize != null">#{groupSize},</if>
  117. <if test="todayJoin != null">#{todayJoin},</if>
  118. <if test="todayOut != null">#{todayOut},</if>
  119. <if test="allOutGroup != null">#{allOutGroup},</if>
  120. <if test="sopId != null">#{sopId},</if>
  121. <if test="qwUserId != null">#{qwUserId},</if>
  122. <if test="roomid != null">#{roomid},</if>
  123. </trim>
  124. on duplicate key update
  125. <trim suffixOverrides=",">
  126. <if test="name != null">name = #{name},</if>
  127. <if test="owner != null">owner = #{owner},</if>
  128. <if test="notice != null">notice = #{notice},</if>
  129. <if test="memberVersion != null">member_version = #{memberVersion},</if>
  130. <if test="status != null">status = #{status},</if>
  131. <if test="companyId != null">company_id = #{companyId},</if>
  132. <if test="corpId != null">corp_id = #{corpId},</if>
  133. <if test="createTime != null">create_time = #{createTime},</if>
  134. <if test="updateTime != null">update_time = #{updateTime},</if>
  135. <if test="createAt != null">create_at = #{createAt},</if>
  136. <if test="groupSize != null">group_size = #{groupSize},</if>
  137. <if test="todayJoin != null">today_join = #{todayJoin},</if>
  138. <if test="todayOut != null">today_out = #{todayOut},</if>
  139. <if test="allOutGroup != null">all_out_group = #{allOutGroup},</if>
  140. <if test="sopId != null">sop_id = #{sopId},</if>
  141. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  142. <if test="roomid != null">roomid = #{roomid},</if>
  143. </trim>
  144. </insert>
  145. <insert id="insertQwGroupChat" parameterType="QwGroupChat">
  146. insert into qw_group_chat
  147. <trim prefix="(" suffix=")" suffixOverrides=",">
  148. <if test="chatId != null">chat_id,</if>
  149. <if test="name != null">name,</if>
  150. <if test="owner != null">owner,</if>
  151. <if test="notice != null">notice,</if>
  152. <if test="memberVersion != null">member_version,</if>
  153. <if test="status != null">status,</if>
  154. <if test="companyId != null">company_id,</if>
  155. <if test="corpId != null">corp_id,</if>
  156. <if test="createTime != null">create_time,</if>
  157. <if test="updateTime != null">update_time,</if>
  158. <if test="createAt != null">create_at,</if>
  159. <if test="groupSize != null">group_size,</if>
  160. <if test="todayJoin != null">today_join,</if>
  161. <if test="todayOut != null">today_out,</if>
  162. <if test="allOutGroup != null">all_out_group,</if>
  163. </trim>
  164. <trim prefix="values (" suffix=")" suffixOverrides=",">
  165. <if test="chatId != null">#{chatId},</if>
  166. <if test="name != null">#{name},</if>
  167. <if test="owner != null">#{owner},</if>
  168. <if test="notice != null">#{notice},</if>
  169. <if test="memberVersion != null">#{memberVersion},</if>
  170. <if test="status != null">#{status},</if>
  171. <if test="companyId != null">#{companyId},</if>
  172. <if test="corpId != null">#{corpId},</if>
  173. <if test="createTime != null">#{createTime},</if>
  174. <if test="updateTime != null">#{updateTime},</if>
  175. <if test="createAt != null">#{createAt},</if>
  176. <if test="groupSize != null">#{groupSize},</if>
  177. <if test="todayJoin != null">#{todayJoin},</if>
  178. <if test="todayOut != null">#{todayOut},</if>
  179. <if test="allOutGroup != null">#{allOutGroup},</if>
  180. </trim>
  181. </insert>
  182. <update id="updateQwGroupChat" parameterType="QwGroupChat">
  183. update qw_group_chat
  184. <trim prefix="SET" suffixOverrides=",">
  185. <if test="name != null">name = #{name},</if>
  186. <if test="owner != null">owner = #{owner},</if>
  187. <if test="notice != null">notice = #{notice},</if>
  188. <if test="memberVersion != null">member_version = #{memberVersion},</if>
  189. <if test="status != null">status = #{status},</if>
  190. <if test="companyId != null">company_id = #{companyId},</if>
  191. <if test="corpId != null">corp_id = #{corpId},</if>
  192. <if test="createTime != null">create_time = #{createTime},</if>
  193. <if test="updateTime != null">update_time = #{updateTime},</if>
  194. <if test="createAt != null">create_at = #{createAt},</if>
  195. <if test="groupSize != null">group_size = #{groupSize},</if>
  196. <if test="todayJoin != null">today_join = #{todayJoin},</if>
  197. <if test="todayOut != null">today_out = #{todayOut},</if>
  198. <if test="allOutGroup != null">all_out_group = #{allOutGroup},</if>
  199. </trim>
  200. where chat_id = #{chatId}
  201. </update>
  202. <delete id="deleteQwGroupChatByChatId" parameterType="String">
  203. delete from qw_group_chat where chat_id = #{chatId}
  204. </delete>
  205. <delete id="deleteQwGroupChatByChatIds" parameterType="String">
  206. delete from qw_group_chat where chat_id in
  207. <foreach item="chatId" collection="array" open="(" separator="," close=")">
  208. #{chatId}
  209. </foreach>
  210. </delete>
  211. <select id="selectSopAndQwUser" resultType="com.fs.qw.domain.QwGroupChat">
  212. select * from qw_group_chat where owner = #{qwUserId} and sop_id = #{sopId}
  213. order by create_time desc limit 1
  214. </select>
  215. </mapper>