QwGroupChatUserMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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.QwGroupChatUserMapper">
  6. <resultMap type="QwGroupChatUser" id="QwGroupChatUserResult">
  7. <result property="id" column="id" />
  8. <result property="chatId" column="chat_id" />
  9. <result property="userId" column="user_id" />
  10. <result property="type" column="type" />
  11. <result property="unionid" column="unionid" />
  12. <result property="joinTime" column="join_time" />
  13. <result property="joinScene" column="join_scene" />
  14. <result property="invitor" column="invitor" />
  15. <result property="groupNickname" column="group_nickname" />
  16. <result property="name" column="name" />
  17. <result property="companyId" column="company_id" />
  18. <result property="isOut" column="is_out" />
  19. <result property="corpId" column="corp_id" />
  20. <result property="outTime" column="out_time" />
  21. <result property="quitScene" column="quit_scene" />
  22. </resultMap>
  23. <sql id="selectQwGroupChatUserVo">
  24. select id, chat_id, user_id, type, unionid, join_time, join_scene, invitor, group_nickname, name, company_id, is_out, corp_id, out_time,quit_scene from qw_group_chat_user
  25. </sql>
  26. <select id="selectQwGroupChatUserList" parameterType="QwGroupChatUser" resultMap="QwGroupChatUserResult">
  27. <include refid="selectQwGroupChatUserVo"/>
  28. <where>
  29. <if test="chatId != null and chatId != ''"> and chat_id = #{chatId}</if>
  30. <if test="userId != null and userId != ''"> and user_id = #{userId}</if>
  31. <if test="type != null and type != ''"> and type = #{type}</if>
  32. <if test="unionid != null "> and unionid = #{unionid}</if>
  33. <if test="joinTime != null "> and join_time = #{joinTime}</if>
  34. <if test="joinScene != null and joinScene != ''"> and join_scene = #{joinScene}</if>
  35. <if test="invitor != null and invitor != ''"> and invitor = #{invitor}</if>
  36. <if test="groupNickname != null and groupNickname != ''"> and group_nickname like concat('%', #{groupNickname}, '%')</if>
  37. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  38. <if test="companyId != null "> and company_id = #{companyId}</if>
  39. <if test="isOut != null "> and is_out = #{isOut}</if>
  40. <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
  41. <if test="outTime != null "> and out_time = #{outTime}</if>
  42. <if test="quitScene != null "> and quit_scene = #{quitScene}</if>
  43. </where>
  44. order by join_time desc
  45. </select>
  46. <select id="selectQwGroupChatUserById" parameterType="Long" resultMap="QwGroupChatUserResult">
  47. <include refid="selectQwGroupChatUserVo"/>
  48. where id = #{id}
  49. </select>
  50. <select id="selectQwGroupChatUserByExternalUserId" parameterType="QwGroupChatUser" resultMap="QwGroupChatUserResult">
  51. <include refid="selectQwGroupChatUserVo"/>
  52. where chat_id = #{chatId} AND user_id=#{userId} AND corp_id=#{corpId}
  53. </select>
  54. <select id="selectQwGroupChatUserByChatIds" resultType="com.fs.qw.domain.QwGroupChatUser">
  55. select * from qw_group_chat_user where is_out = 1 and type = 2 and chat_id in <foreach collection="ids" open="(" separator="," close=")" item="item">#{item}</foreach>
  56. </select>
  57. <select id="selectUserIsChat" resultType="com.fs.qw.domain.QwGroupChatUser">
  58. select * from qw_group_chat_user a where a.user_id = #{externalUserId}
  59. </select>
  60. <select id="selectByChatId" resultType="com.fs.qw.domain.QwGroupChatUser">
  61. select * from qw_group_chat_user a where a.chat_id = #{chatId} and type = 2
  62. </select>
  63. <insert id="insertOrUpdateQwGroupChatUser" parameterType="QwGroupChatUser" useGeneratedKeys="true" keyProperty="id">
  64. insert into qw_group_chat_user
  65. <trim prefix="(" suffix=")" suffixOverrides=",">
  66. <if test="chatId != null">chat_id,</if>
  67. <if test="userId != null">user_id,</if>
  68. <if test="type != null">type,</if>
  69. <if test="unionid != null">unionid,</if>
  70. <if test="joinTime != null">join_time,</if>
  71. <if test="joinScene != null">join_scene,</if>
  72. <if test="invitor != null">invitor,</if>
  73. <if test="groupNickname != null">group_nickname,</if>
  74. <if test="name != null">name,</if>
  75. <if test="companyId != null">company_id,</if>
  76. <if test="isOut != null">is_out,</if>
  77. <if test="corpId != null">corp_id,</if>
  78. <if test="outTime != null">out_time,</if>
  79. <if test="quitScene != null">quit_scene,</if>
  80. </trim>
  81. <trim prefix="values (" suffix=")" suffixOverrides=",">
  82. <if test="chatId != null">#{chatId},</if>
  83. <if test="userId != null">#{userId},</if>
  84. <if test="type != null">#{type},</if>
  85. <if test="unionid != null">#{unionid},</if>
  86. <if test="joinTime != null">#{joinTime},</if>
  87. <if test="joinScene != null">#{joinScene},</if>
  88. <if test="invitor != null">#{invitor},</if>
  89. <if test="groupNickname != null">#{groupNickname},</if>
  90. <if test="name != null">#{name},</if>
  91. <if test="companyId != null">#{companyId},</if>
  92. <if test="isOut != null">#{isOut},</if>
  93. <if test="corpId != null">#{corpId},</if>
  94. <if test="outTime != null">#{outTime},</if>
  95. <if test="quitScene != null">#{quitScene},</if>
  96. </trim>
  97. on duplicate key update
  98. <trim suffixOverrides=",">
  99. <if test="type != null">type = #{type},</if>
  100. <if test="unionid != null">unionid = #{unionid},</if>
  101. <if test="joinTime != null">join_time = #{joinTime},</if>
  102. <if test="joinScene != null">join_scene = #{joinScene},</if>
  103. <if test="invitor != null">invitor = #{invitor},</if>
  104. <if test="groupNickname != null">group_nickname = #{groupNickname},</if>
  105. <if test="name != null">name = #{name},</if>
  106. <if test="companyId != null">company_id = #{companyId},</if>
  107. <if test="isOut != null">is_out = #{isOut},</if>
  108. <if test="corpId != null">corp_id = #{corpId},</if>
  109. <if test="outTime != null">out_time = #{outTime},</if>
  110. <if test="quitScene != null">quit_scene = #{quitScene},</if>
  111. </trim>
  112. </insert>
  113. <insert id="insertQwGroupChatUser" parameterType="QwGroupChatUser" useGeneratedKeys="true" keyProperty="id">
  114. insert into qw_group_chat_user
  115. <trim prefix="(" suffix=")" suffixOverrides=",">
  116. <if test="chatId != null">chat_id,</if>
  117. <if test="userId != null">user_id,</if>
  118. <if test="type != null">type,</if>
  119. <if test="unionid != null">unionid,</if>
  120. <if test="joinTime != null">join_time,</if>
  121. <if test="joinScene != null">join_scene,</if>
  122. <if test="invitor != null">invitor,</if>
  123. <if test="groupNickname != null">group_nickname,</if>
  124. <if test="name != null">name,</if>
  125. <if test="companyId != null">company_id,</if>
  126. <if test="isOut != null">is_out,</if>
  127. <if test="corpId != null">corp_id,</if>
  128. <if test="outTime != null">out_time,</if>
  129. <if test="quitScene != null">quit_scene,</if>
  130. </trim>
  131. <trim prefix="values (" suffix=")" suffixOverrides=",">
  132. <if test="chatId != null">#{chatId},</if>
  133. <if test="userId != null">#{userId},</if>
  134. <if test="type != null">#{type},</if>
  135. <if test="unionid != null">#{unionid},</if>
  136. <if test="joinTime != null">#{joinTime},</if>
  137. <if test="joinScene != null">#{joinScene},</if>
  138. <if test="invitor != null">#{invitor},</if>
  139. <if test="groupNickname != null">#{groupNickname},</if>
  140. <if test="name != null">#{name},</if>
  141. <if test="companyId != null">#{companyId},</if>
  142. <if test="isOut != null">#{isOut},</if>
  143. <if test="corpId != null">#{corpId},</if>
  144. <if test="outTime != null">#{outTime},</if>
  145. <if test="quitScene != null">#{quitScene},</if>
  146. </trim>
  147. </insert>
  148. <update id="updateQwGroupChatUser" parameterType="QwGroupChatUser">
  149. update qw_group_chat_user
  150. <trim prefix="SET" suffixOverrides=",">
  151. <if test="chatId != null">chat_id = #{chatId},</if>
  152. <if test="userId != null">user_id = #{userId},</if>
  153. <if test="type != null">type = #{type},</if>
  154. <if test="unionid != null">unionid = #{unionid},</if>
  155. <if test="joinTime != null">join_time = #{joinTime},</if>
  156. <if test="joinScene != null">join_scene = #{joinScene},</if>
  157. <if test="invitor != null">invitor = #{invitor},</if>
  158. <if test="groupNickname != null">group_nickname = #{groupNickname},</if>
  159. <if test="name != null">name = #{name},</if>
  160. <if test="companyId != null">company_id = #{companyId},</if>
  161. <if test="isOut != null">is_out = #{isOut},</if>
  162. <if test="corpId != null">corp_id = #{corpId},</if>
  163. <if test="outTime != null">out_time = #{outTime},</if>
  164. <if test="quitScene != null">quit_scene = #{quitScene},</if>
  165. </trim>
  166. where id = #{id}
  167. </update>
  168. <update id="upDateDelGroupChatUser" parameterType="QwGroupChatUser">
  169. update qw_group_chat_user
  170. <trim prefix="SET" suffixOverrides=",">
  171. <if test="type != null">type = #{type},</if>
  172. <if test="unionid != null">unionid = #{unionid},</if>
  173. <if test="joinTime != null">join_time = #{joinTime},</if>
  174. <if test="joinScene != null">join_scene = #{joinScene},</if>
  175. <if test="invitor != null">invitor = #{invitor},</if>
  176. <if test="groupNickname != null">group_nickname = #{groupNickname},</if>
  177. <if test="name != null">name = #{name},</if>
  178. <if test="companyId != null">company_id = #{companyId},</if>
  179. <if test="isOut != null">is_out = #{isOut},</if>
  180. <if test="corpId != null">corp_id = #{corpId},</if>
  181. <if test="outTime != null">out_time = #{outTime},</if>
  182. <if test="quitScene != null">quit_scene = #{quitScene},</if>
  183. </trim>
  184. where chat_id = #{chatId} and user_id=#{userId}
  185. </update>
  186. <update id="groupChatUserJoinAgain" parameterType="QwGroupChatUser">
  187. update qw_group_chat_user
  188. <trim prefix="SET" suffixOverrides=",">
  189. type = #{type},
  190. unionid = #{unionid},
  191. join_time = #{joinTime},
  192. join_scene = #{joinScene},
  193. invitor = #{invitor},
  194. group_nickname = #{groupNickname},
  195. name = #{name},
  196. company_id = #{companyId},
  197. is_out = #{isOut},
  198. corp_id = #{corpId},
  199. out_time = #{outTime},
  200. quit_scene = #{quitScene}
  201. </trim>
  202. where chat_id = #{chatId} and user_id = #{userId}
  203. </update>
  204. <delete id="deleteQwGroupChatUserById" parameterType="Long">
  205. delete from qw_group_chat_user where id = #{id}
  206. </delete>
  207. <delete id="deleteQwGroupChatUserByIds" parameterType="String">
  208. delete from qw_group_chat_user where id in
  209. <foreach item="id" collection="array" open="(" separator="," close=")">
  210. #{id}
  211. </foreach>
  212. </delete>
  213. </mapper>