QwUserMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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.QwUserMapper">
  6. <resultMap type="QwUser" id="QwUserResult">
  7. <result property="id" column="id" />
  8. <result property="qwUserId" column="qw_user_id" />
  9. <result property="qwUserName" column="qw_user_name" />
  10. <result property="department" column="department" />
  11. <result property="openid" column="openid" />
  12. <result property="companyId" column="company_id" />
  13. <result property="companyUserId" column="company_user_id" />
  14. <result property="corpId" column="corp_id" />
  15. <result property="status" column="status" />
  16. <result property="isDel" column="is_del" />
  17. <result property="welcomeText" column="welcome_text" />
  18. <result property="welcomeImage" column="welcome_image" />
  19. <result property="isSendMsg" column="is_send_msg" />
  20. <result property="appKey" column="app_key" />
  21. <result property="contactWay" column="contact_way" />
  22. <result property="configId" column="config_id" />
  23. <result property="qwHookId" column="qw_hook_id" />
  24. <result property="fastGptRoleId" column="fastGpt_role_id" />
  25. <result property="loginStatus" column="login_status" />
  26. <result property="toolStatus" column="tool_status" />
  27. <result property="loginCodeUrl" column="login_code_url" />
  28. <result property="version" column="version" />
  29. <result property="vid" column="vid" />
  30. <result property="uid" column="uid" />
  31. <result property="ipadStatus" column="ipad_status" />
  32. <result property="serverId" column="server_id" />
  33. <result property="serverStatus" column="server_status" />
  34. <result property="isAuto" column="is_auto" />
  35. <result property="videoGetStatus" column="video_get_status" />
  36. <result property="avatar" column="avatar" />
  37. </resultMap>
  38. <sql id="selectQwUserVo">
  39. select id,is_auto, video_get_status, qw_user_id,server_id,server_status,ipad_status,config_id,vid,uid,contact_way,app_key, qw_user_name, department, openid, company_id, company_user_id, corp_id, status, is_del, welcome_text, welcome_image, is_send_msg,app_key,qw_hook_id,fastGpt_role_id,login_status,tool_status,login_code_url,version,avatar from qw_user
  40. </sql>
  41. <select id="selectQwUserList" parameterType="QwUser" resultMap="QwUserResult">
  42. <include refid="selectQwUserVo"/>
  43. <where>
  44. <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
  45. <if test="qwUserName != null and qwUserName != ''"> and qw_user_name like concat('%', #{qwUserName}, '%')</if>
  46. <if test="department != null and department != ''"> and department = #{department}</if>
  47. <if test="openid != null and openid != ''"> and openid = #{openid}</if>
  48. <if test="companyId != null "> and company_id = #{companyId}</if>
  49. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  50. <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
  51. <if test="status != null "> and status = #{status}</if>
  52. <if test="isDel != null "> and is_del = #{isDel}</if>
  53. <if test="welcomeText != null and welcomeText != ''"> and welcome_text = #{welcomeText}</if>
  54. <if test="welcomeImage != null and welcomeImage != ''"> and welcome_image = #{welcomeImage}</if>
  55. <if test="isSendMsg != null "> and is_send_msg = #{isSendMsg}</if>
  56. <if test="fastGptRoleId != null "> and fastGpt_role_id = #{fastGptRoleId}</if>
  57. <if test="loginStatus != null "> and login_status = #{loginStatus}</if>
  58. <if test="toolStatus != null "> and tool_status = #{toolStatus}</if>
  59. <if test="loginCodeUrl != null "> and login_code_url = #{loginCodeUrl}</if>
  60. <if test="version != null "> and version = #{version}</if>
  61. <if test="isAuto != null "> and is_auto = #{isAuto}</if>
  62. <if test="avatar != null "> and avatar = #{avatar}</if>
  63. </where>
  64. </select>
  65. <select id="selectQwUserById" parameterType="Long" resultMap="QwUserResult">
  66. <include refid="selectQwUserVo"/>
  67. where id = #{id}
  68. </select>
  69. <select id="batchGetQwUser" resultType="QwUser">
  70. SELECT
  71. qw_user_id,
  72. corp_id,
  73. qw_user_name
  74. FROM
  75. qw_user
  76. WHERE
  77. (qw_user_id, corp_id) IN
  78. <foreach item="item" collection="list" separator="," open="(" close=")">
  79. (#{item.qwUserid}, #{item.corpId})
  80. </foreach>
  81. </select>
  82. <insert id="insertQwUser" parameterType="QwUser" useGeneratedKeys="true" keyProperty="id">
  83. insert into qw_user
  84. <trim prefix="(" suffix=")" suffixOverrides=",">
  85. <if test="qwUserId != null">qw_user_id,</if>
  86. <if test="qwUserName != null">qw_user_name,</if>
  87. <if test="department != null">department,</if>
  88. <if test="openid != null">openid,</if>
  89. <if test="companyId != null">company_id,</if>
  90. <if test="companyUserId != null">company_user_id,</if>
  91. <if test="corpId != null">corp_id,</if>
  92. <if test="status != null">status,</if>
  93. <if test="isDel != null">is_del,</if>
  94. <if test="welcomeText != null">welcome_text,</if>
  95. <if test="welcomeImage != null">welcome_image,</if>
  96. <if test="isSendMsg != null">is_send_msg,</if>
  97. <if test="contactWay != null">contact_way,</if>
  98. <if test="configId != null">config_id,</if>
  99. <if test="appKey != null">app_key,</if>
  100. <if test="qwHookId != null">qw_hook_id,</if>
  101. <if test="fastGptRoleId != null">fastGpt_role_id,</if>
  102. <if test="loginStatus != null">login_status,</if>
  103. <if test="toolStatus != null">tool_status,</if>
  104. <if test="loginCodeUrl != null">login_code_url,</if>
  105. <if test="version != null">version,</if>
  106. <if test="vid != null">vid,</if>
  107. <if test="uid != null">uid,</if>
  108. <if test="ipadStatus != null">ipad_status,</if>
  109. <if test="serverId != null">server_id,</if>
  110. <if test="serverStatus != null">server_status,</if>
  111. <if test="isAuto != null">is_auto,</if>
  112. <if test="videoGetStatus != null">video_get_status,</if>
  113. <if test="avatar != null">avatar,</if>
  114. </trim>
  115. <trim prefix="values (" suffix=")" suffixOverrides=",">
  116. <if test="qwUserId != null">#{qwUserId},</if>
  117. <if test="qwUserName != null">#{qwUserName},</if>
  118. <if test="department != null">#{department},</if>
  119. <if test="openid != null">#{openid},</if>
  120. <if test="companyId != null">#{companyId},</if>
  121. <if test="companyUserId != null">#{companyUserId},</if>
  122. <if test="corpId != null">#{corpId},</if>
  123. <if test="status != null">#{status},</if>
  124. <if test="isDel != null">#{isDel},</if>
  125. <if test="welcomeText != null">#{welcomeText},</if>
  126. <if test="welcomeImage != null">#{welcomeImage},</if>
  127. <if test="isSendMsg != null">#{isSendMsg},</if>
  128. <if test="contactWay != null">#{contactWay},</if>
  129. <if test="configId != null">#{configId},</if>
  130. <if test="appKey != null">#{appKey},</if>
  131. <if test="qwHookId != null">#{qwHookId},</if>
  132. <if test="fastGptRoleId != null">#{fastGptRoleId},</if>
  133. <if test="loginStatus != null">#{loginStatus},</if>
  134. <if test="toolStatus != null">#{tool_status},</if>
  135. <if test="version != null">#{version},</if>
  136. <if test="vid != null">#{vid},</if>
  137. <if test="uid != null">#{uid},</if>
  138. <if test="ipadStatus != null">#{ipadStatus},</if>
  139. <if test="serverId != null">#{serverId},</if>
  140. <if test="isAuto != null">#{isAuto},</if>
  141. <if test="videoGetStatus != null">#{videoGetStatus},</if>
  142. <if test="avatar != null">#{avatar},</if>
  143. </trim>
  144. </insert>
  145. <update id="updateQwUser" parameterType="QwUser">
  146. update qw_user
  147. <trim prefix="SET" suffixOverrides=",">
  148. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  149. <if test="qwUserName != null">qw_user_name = #{qwUserName},</if>
  150. <if test="department != null">department = #{department},</if>
  151. <if test="openid != null">openid = #{openid},</if>
  152. <if test="companyId != null">company_id = #{companyId},</if>
  153. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  154. <if test="corpId != null">corp_id = #{corpId},</if>
  155. <if test="status != null">status = #{status},</if>
  156. <if test="isDel != null">is_del = #{isDel},</if>
  157. <if test="welcomeText != null">welcome_text = #{welcomeText},</if>
  158. <if test="welcomeImage != null">welcome_image = #{welcomeImage},</if>
  159. <if test="isSendMsg != null">is_send_msg = #{isSendMsg},</if>
  160. <if test="contactWay != null">contact_way = #{contactWay},</if>
  161. <if test="configId != null">config_id = #{configId},</if>
  162. <if test="appKey != null">app_key = #{appKey},</if>
  163. <if test="qwHookId != null">qw_hook_id = #{qwHookId},</if>
  164. <if test="fastGptRoleId != null">fastGpt_role_id = #{fastGptRoleId},</if>
  165. <if test="loginStatus != null">login_status = #{loginStatus},</if>
  166. <if test="toolStatus != null">tool_status = #{toolStatus},</if>
  167. <if test="loginCodeUrl != null">login_code_url = #{loginCodeUrl},</if>
  168. <if test="version != null">version = #{version},</if>
  169. <if test="vid != null">`vid` = #{vid},</if>
  170. <if test="uid != null">uid = #{uid},</if>
  171. <if test="ipadStatus != null">ipad_status = #{ipadStatus},</if>
  172. <if test="serverId != null">server_id = #{serverId},</if>
  173. <if test="serverStatus != null">server_status = #{serverStatus},</if>
  174. <if test="isAuto != null">is_auto = #{isAuto},</if>
  175. <if test="videoGetStatus != null">video_get_status = #{videoGetStatus},</if>
  176. <if test="avatar != null">avatar = #{avatar},</if>
  177. </trim>
  178. where id = #{id}
  179. </update>
  180. <update id="updateQwUserByAppKey" parameterType="QwUser">
  181. update qw_user set login_status = #{loginStatus},remark = NULL
  182. <if test="version != null">,version = #{version} </if>
  183. where app_key = #{appKey}
  184. </update>
  185. <update id="updateQwUserByAppKeyTool" parameterType="QwUser">
  186. update qw_user set tool_status = #{toolStatus}
  187. where app_key = #{appKey}
  188. </update>
  189. <update id="updateQwUserByAppKeyToUrl" parameterType="QwUser">
  190. update qw_user set login_code_url = #{loginCodeUrl}
  191. where app_key = #{appKey}
  192. </update>
  193. <update id="updateQwUserByCompanyUserId" parameterType="String">
  194. update qw_user set status = 0 , is_del= 2 , company_user_id=null where company_user_id in
  195. <foreach item="userId" collection="array" open="(" separator="," close=")">
  196. #{userId}
  197. </foreach>
  198. </update>
  199. <delete id="deleteQwUserById" parameterType="Long">
  200. delete from qw_user where id = #{id}
  201. </delete>
  202. <delete id="deleteQwUserByIds" parameterType="String">
  203. delete from qw_user where id in
  204. <foreach item="id" collection="array" open="(" separator="," close=")">
  205. #{id}
  206. </foreach>
  207. </delete>
  208. <select id="selectQwUserByUserIds" parameterType="java.util.List" resultMap="QwUserResult">
  209. <include refid="selectQwUserVo"/>
  210. WHERE id IN
  211. <foreach item="userId" collection="list" open="(" separator="," close=")">
  212. #{userId}
  213. </foreach>
  214. </select>
  215. <select id="selectQwWorkTaskList" resultType="com.fs.qw.domain.QwWorkTask">
  216. select
  217. qwt.id,qwt.ext_id, qwt.qw_user_id, qwt.status, qwt.track_type, qwt.type, qwt.title, qwt.remark, qwt.score, qwt.sop_id,
  218. qwt.company_id, qwt.company_user_id, qwt.duration, qwt.create_time, qwt.update_time
  219. from qw_work_task qwt
  220. where qwt.qw_user_id = #{userId}
  221. and date(qwt.create_time) = #{date}
  222. and qwt.status = 0
  223. </select>
  224. <select id="selectQwUserByFsUserId" resultType="com.fs.qw.vo.sidebar.ExternalContactQwUserVO">
  225. SELECT
  226. qw_user.id,
  227. qw_user.qw_user_id,
  228. qw_user.qw_user_name,
  229. qw_user.department,
  230. qw_user.company_user_id,
  231. qw_user.company_id,
  232. company.company_name,
  233. company_user.nick_name as companyUserName
  234. FROM
  235. qw_user
  236. LEFT JOIN company_user ON company_user.user_id = qw_user.company_user_id
  237. LEFT JOIN company ON company.company_id = qw_user.company_id
  238. WHERE
  239. qw_user.qw_user_id IN ( SELECT user_id FROM qw_external_contact WHERE fs_user_id = #{fsUserId} )
  240. </select>
  241. <update id="updateSendType">
  242. update qw_user set send_msg_type = #{type} where id in <foreach collection="ids" open="(" close=")" separator="," item="item">#{item}</foreach>
  243. </update>
  244. <select id="selectOfflineUser" resultType="com.fs.qw.domain.QwUser">
  245. select * from qw_user where send_msg_type = 2 and server_id is not null and server_status = 1 and ipad_status = 1 limit 1
  246. </select>
  247. <select id="batchSelectQwUserByQwUserIdAndCorpId" resultType="QwUser">
  248. SELECT qw_user_id, corp_id, qw_user_name
  249. FROM qw_user
  250. WHERE
  251. <foreach collection="data" item="query" open="(" separator=" OR " close=")">
  252. (qw_user_id = #{query.qwUserId} AND corp_id = #{query.corpId})
  253. </foreach>
  254. </select>
  255. <select id="selectQwUserListVOByCompanyIdAndCorpIdAndNickName" resultType="com.fs.qw.vo.QwUserVO">
  256. select
  257. qu.*,
  258. cu.nick_name,
  259. cu.user_name,
  260. qd.dept_name as departmentName,
  261. c.company_name
  262. from qw_user qu
  263. left join company_user cu on cu.user_id = qu.company_user_id
  264. right join qw_dept qd on qu.department = qd.dept_id and qd.corp_id = qu.corp_id
  265. left join company c on qu.company_id = c.company_id
  266. where qu.company_id = #{companyId} and qu.corp_id = #{corpId}
  267. <if test="nickName != null and nickName != ''">
  268. and qu.qw_user_name like concat('%', #{nickName}, '%')
  269. </if>
  270. </select>
  271. </mapper>