CompanyUserMapper.xml 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  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.company.mapper.CompanyUserMapper">
  6. <resultMap type="CompanyUser" id="CompanyUserResult">
  7. <result property="userId" column="user_id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="deptId" column="dept_id" />
  10. <result property="userName" column="user_name" />
  11. <result property="nickName" column="nick_name" />
  12. <result property="userType" column="user_type" />
  13. <result property="email" column="email" />
  14. <result property="phonenumber" column="phonenumber" />
  15. <result property="sex" column="sex" />
  16. <result property="avatar" column="avatar" />
  17. <result property="idCard" column="id_card" />
  18. <result property="password" column="password" />
  19. <result property="status" column="status" />
  20. <result property="delFlag" column="del_flag" />
  21. <result property="loginIp" column="login_ip" />
  22. <result property="loginDate" column="login_date" />
  23. <result property="createBy" column="create_by" />
  24. <result property="createTime" column="create_time" />
  25. <result property="updateBy" column="update_by" />
  26. <result property="updateTime" column="update_time" />
  27. <result property="token" column="token" />
  28. <result property="remark" column="remark" />
  29. <result property="openId" column="open_id" />
  30. <result property="qrCodeWeixin" column="qr_code_weixin" />
  31. <result property="qrCodeWecom" column="qr_code_wecom" />
  32. <result property="jpushId" column="jpush_id" />
  33. <result property="firstchar" column="firstchar" />
  34. <result property="postName" column="post_name" />
  35. <result property="deptName" column="dept_name" />
  36. <result property="qwUserId" column="qw_user_id" />
  37. <result property="qwStatus" column="qw_status" />
  38. <result property="voicePrintUrl" column="voice_print_url" />
  39. <result property="addressId" column="address_id" />
  40. <result property="domain" column="domain" />
  41. <result property="isAudit" column="is_audit" />
  42. <result property="isNeedRegisterMember" column="is_need_register_member" />
  43. <result property="isAllowedAllRegister" column="is_allowed_all_register" />
  44. <result property="doctorId" column="doctor_id" />
  45. <result property="bindCompanyUserId" column="bind_company_user_id" />
  46. <result property="unionId" column="union_id" />
  47. <result property="cidServerId" column="cid_server_id"/>
  48. <association property="dept" column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
  49. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  50. </resultMap>
  51. <resultMap id="CompanyUserQwListVOResult" type="com.fs.company.vo.CompanyUserQwListVO">
  52. <id property="userId" column="user_id"/>
  53. <result property="userName" column="user_name"/>
  54. <result property="nickName" column="nick_name"/>
  55. <result property="companyId" column="company_id"/>
  56. <result property="status" column="status"/>
  57. <result property="qwStatus" column="qw_status"/>
  58. <result property="qwUserId" column="qw_user_id"/>
  59. <result property="phonenumber" column="phonenumber"/>
  60. <result property="createTime" column="create_time"/>
  61. <result property="deptId" column="dept_id"/>
  62. <result property="deptName" column="dept_name"/>
  63. <result property="qrCodeWeixin" column="qr_code_weixin"/>
  64. <result property="postName" column="post_name"/>
  65. <result property="qrCodeWecom" column="qr_code_wecom"/>
  66. <result property="jpushId" column="jpush_id"/>
  67. <result property="callerNo" column="caller_no"/>
  68. <result property="isNeedRegisterMember" column="is_need_register_member" />
  69. <result property="isAllowedAllRegister" column="is_allowed_all_register" />
  70. <result property="cidServerId" column="cid_server_id"/>
  71. <collection property="roleNames" ofType="java.lang.String" javaType="java.util.ArrayList"
  72. select="selectUserRoles" column="user_id"/>
  73. </resultMap>
  74. <resultMap id="deptResult" type="CompanyDept">
  75. <id property="deptId" column="dept_id"/>
  76. <result property="parentId" column="parent_id"/>
  77. <result property="deptName" column="dept_name"/>
  78. <result property="orderNum" column="order_num"/>
  79. <result property="leader" column="leader"/>
  80. <result property="status" column="dept_status"/>
  81. </resultMap>
  82. <resultMap id="RoleResult" type="CompanyRole">
  83. <id property="roleId" column="role_id" />
  84. <result property="roleName" column="role_name" />
  85. <result property="roleKey" column="role_key" />
  86. <result property="roleSort" column="role_sort" />
  87. <result property="dataScope" column="data_scope" />
  88. <result property="status" column="role_status" />
  89. </resultMap>
  90. <select id="selectCompanyUserQwListVO" resultMap="CompanyUserQwListVOResult">
  91. select
  92. u.user_id, u.user_name, u.nick_name, u.company_id, u.status,
  93. u.qw_status, u.phonenumber, u.create_time, u.dept_id,
  94. u.qr_code_weixin, u.user_type, u.qr_code_wecom, u.jpush_id,
  95. u.is_need_register_member,u.is_allowed_all_register,
  96. u.avatar,u.address_id,
  97. u.qw_user_id,
  98. u.doctor_id,
  99. u.cid_server_id,
  100. d.dept_name,
  101. d.leader
  102. from
  103. company_user u
  104. left join
  105. company_dept d on u.dept_id = d.dept_id
  106. where
  107. u.del_flag = '0'
  108. <if test="userId != null ">
  109. AND u.user_id = #{userId}
  110. </if>
  111. <if test="userName != null and userName != ''">
  112. AND u.user_name like concat('%', #{userName}, '%')
  113. </if>
  114. <if test="nickName != null and nickName != ''">
  115. AND u.nick_name like concat( #{nickName}, '%')
  116. </if>
  117. <if test="companyId != null and companyId != ''">
  118. AND u.company_id = #{companyId}
  119. </if>
  120. <if test="status != null and status != ''">
  121. AND u.status = #{status}
  122. </if>
  123. <if test="qwStatus != null">
  124. AND u.qw_status = #{qwStatus}
  125. </if>
  126. <if test="phonenumber != null and phonenumber != ''">
  127. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  128. </if>
  129. <if test="beginTime != null and beginTime != ''">
  130. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  131. </if>
  132. <if test="endTime != null and endTime != ''">
  133. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  134. </if>
  135. <if test="deptId != null and deptId != 0">
  136. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  137. </if>
  138. <!-- 数据范围过滤 -->
  139. ${params.dataScope}
  140. </select>
  141. <!-- 角色子查询 -->
  142. <select id="selectUserRoles" resultType="java.lang.String">
  143. SELECT cr.role_name
  144. FROM company_user_role cur
  145. LEFT JOIN company_role cr ON cr.role_id = cur.role_id
  146. WHERE cur.user_id = #{userId}
  147. </select>
  148. <select id="selectCompanyUserList" parameterType="CompanyUser" resultMap="CompanyUserResult">
  149. select u.*, d.dept_name, d.leader from company_user u
  150. left join company_dept d on u.dept_id = d.dept_id
  151. where u.del_flag = '0'
  152. <if test="userName != null and userName != ''">
  153. AND u.user_name like concat( #{userName}, '%')
  154. </if>
  155. <if test="nickName != null and nickName != ''">
  156. AND u.nick_name like concat( #{nickName}, '%')
  157. </if>
  158. <if test="companyId != null and companyId != ''">
  159. AND u.company_id = #{companyId}
  160. </if>
  161. <if test="status != null and status != ''">
  162. AND u.status = #{status}
  163. </if>
  164. <if test="phonenumber != null and phonenumber != ''">
  165. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  166. </if>
  167. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  168. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  169. </if>
  170. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  171. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  172. </if>
  173. <if test="deptId != null and deptId != 0">
  174. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  175. </if>
  176. <if test="deptList != null and !deptList.isEmpty()">
  177. AND u.dept_id IN
  178. <foreach collection='deptList' item='item' open='(' separator=',' close=')'>
  179. #{item}
  180. </foreach>
  181. </if>
  182. <!-- 数据范围过滤 -->
  183. ${params.dataScope}
  184. </select>
  185. <select id="selectCompanyUserById" parameterType="Long" resultMap="CompanyUserResult">
  186. <include refid="selectUserVo"/>
  187. where u.user_id = #{userId}
  188. </select>
  189. <insert id="insertCompanyUser" parameterType="CompanyUser" useGeneratedKeys="true" keyProperty="userId">
  190. insert into company_user
  191. <trim prefix="(" suffix=")" suffixOverrides=",">
  192. <if test="companyId != null">company_id,</if>
  193. <if test="deptId != null">dept_id,</if>
  194. <if test="userName != null and userName != ''">user_name,</if>
  195. <if test="nickName != null and nickName != ''">nick_name,</if>
  196. <if test="userType != null">user_type,</if>
  197. <if test="email != null">email,</if>
  198. <if test="phonenumber != null">phonenumber,</if>
  199. <if test="sex != null">sex,</if>
  200. <if test="avatar != null">avatar,</if>
  201. <if test="idCard != null">id_card,</if>
  202. <if test="password != null">password,</if>
  203. <if test="status != null">status,</if>
  204. <if test="delFlag != null">del_flag,</if>
  205. <if test="loginIp != null">login_ip,</if>
  206. <if test="loginDate != null">login_date,</if>
  207. <if test="createBy != null">create_by,</if>
  208. <if test="createTime != null">create_time,</if>
  209. <if test="updateBy != null">update_by,</if>
  210. <if test="updateTime != null">update_time,</if>
  211. <if test="token != null">token,</if>
  212. <if test="remark != null">remark,</if>
  213. <if test="openId != null">open_id,</if>
  214. <if test="qrCodeWeixin != null">qr_code_weixin,</if>
  215. <if test="qrCodeWecom != null">qr_code_wecom,</if>
  216. <if test="jpushId != null">jpush_id,</if>
  217. <if test="qwUserId != null">qw_user_id,</if>
  218. <if test="qwStatus != null">qw_status,</if>
  219. <if test="voicePrintUrl != null">voice_print_url,</if>
  220. <if test="addressId != null">address_id,</if>
  221. <if test="domain != null">domain,</if>
  222. <if test="isAudit != null">`is_audit`,</if>
  223. </trim>
  224. <trim prefix="values (" suffix=")" suffixOverrides=",">
  225. <if test="companyId != null">#{companyId},</if>
  226. <if test="deptId != null">#{deptId},</if>
  227. <if test="userName != null and userName != ''">#{userName},</if>
  228. <if test="nickName != null and nickName != ''">#{nickName},</if>
  229. <if test="userType != null">#{userType},</if>
  230. <if test="email != null">#{email},</if>
  231. <if test="phonenumber != null">#{phonenumber},</if>
  232. <if test="sex != null">#{sex},</if>
  233. <if test="avatar != null">#{avatar},</if>
  234. <if test="idCard != null">#{idCard},</if>
  235. <if test="password != null">#{password},</if>
  236. <if test="status != null">#{status},</if>
  237. <if test="delFlag != null">#{delFlag},</if>
  238. <if test="loginIp != null">#{loginIp},</if>
  239. <if test="loginDate != null">#{loginDate},</if>
  240. <if test="createBy != null">#{createBy},</if>
  241. <if test="createTime != null">#{createTime},</if>
  242. <if test="updateBy != null">#{updateBy},</if>
  243. <if test="updateTime != null">#{updateTime},</if>
  244. <if test="token != null">#{token},</if>
  245. <if test="remark != null">#{remark},</if>
  246. <if test="openId != null">#{openId},</if>
  247. <if test="qrCodeWeixin != null">#{qrCodeWeixin},</if>
  248. <if test="qrCodeWecom != null">#{qrCodeWecom},</if>
  249. <if test="jpushId != null">#{jpushId},</if>
  250. <if test="qwUserId != null">#{qwUserId},</if>
  251. <if test="qwStatus != null">#{qwStatus},</if>
  252. <if test="voicePrintUrl != null">#{voicePrintUrl},</if>
  253. <if test="addressId != null">#{addressId},</if>
  254. <if test="domain != null">#{domain},</if>
  255. <if test="isAudit != null">#{isAudit},</if>
  256. </trim>
  257. </insert>
  258. <insert id="insertQwIpadTotal">
  259. insert into qw_ipad_total (company_id,company_name,bind_count,stat_time) values
  260. <foreach item="item" collection="list" separator=",">
  261. (#{item.companyId},#{item.companyName},#{item.bindCount},#{item.statTime})
  262. </foreach>
  263. </insert>
  264. <update id="uploadQrCode">
  265. update company_user set qr_code_weixin=#{url} where user_id=${userId}
  266. </update>
  267. <update id="updateCompanyUser" parameterType="CompanyUser">
  268. update company_user
  269. <trim prefix="SET" suffixOverrides=",">
  270. <if test="companyId != null">company_id = #{companyId},</if>
  271. <if test="deptId != null">dept_id = #{deptId},</if>
  272. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  273. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  274. <if test="userType != null">user_type = #{userType},</if>
  275. <if test="email != null">email = #{email},</if>
  276. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  277. <if test="sex != null">sex = #{sex},</if>
  278. <if test="avatar != null">avatar = #{avatar},</if>
  279. <if test="idCard != null">id_card = #{idCard},</if>
  280. <if test="password != null and password != '' ">password = #{password},</if>
  281. <if test="status != null">status = #{status},</if>
  282. <if test="delFlag != null">del_flag = #{delFlag},</if>
  283. <if test="loginIp != null">login_ip = #{loginIp},</if>
  284. <if test="loginDate != null">login_date = #{loginDate},</if>
  285. <if test="createBy != null">create_by = #{createBy},</if>
  286. <if test="createTime != null">create_time = #{createTime},</if>
  287. <if test="updateBy != null">update_by = #{updateBy},</if>
  288. <if test="updateTime != null">update_time = #{updateTime},</if>
  289. <if test="token != null">token = #{token},</if>
  290. <if test="remark != null">remark = #{remark},</if>
  291. <if test="qrCodeWeixin != null">qr_code_weixin = #{qrCodeWeixin},</if>
  292. <if test="qrCodeWecom != null">qr_code_wecom = #{qrCodeWecom},</if>
  293. <if test="jpushId != null">jpush_id = #{jpushId},</if>
  294. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  295. <if test="qwStatus != null">qw_status = #{qwStatus},</if>
  296. <if test="voicePrintUrl != null">voice_print_url = #{voicePrintUrl},</if>
  297. <if test="addressId != null">address_id = #{addressId},</if>
  298. <if test="domain != null">domain = #{domain},</if>
  299. <if test="isAudit != null">`is_audit` = #{isAudit},</if>
  300. <if test="doctorId != null">`doctor_id` = #{doctorId},</if>
  301. <if test="unionId != null">`union_id` = #{unionId},</if>
  302. <if test="cidServerId != null">`cid_server_id` = #{cidServerId},</if>
  303. </trim>
  304. where user_id = #{userId}
  305. </update>
  306. <update id="updateAllCompanyUser" parameterType="CompanyUser">
  307. update company_user
  308. <trim prefix="SET" suffixOverrides=",">
  309. <if test="companyId != null">company_id = #{companyId},</if>
  310. <if test="deptId != null">dept_id = #{deptId},</if>
  311. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  312. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  313. <if test="email != null">email = #{email},</if>
  314. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  315. <if test="sex != null">sex = #{sex},</if>
  316. <if test="avatar != null">avatar = #{avatar},</if>
  317. <if test="idCard != null">id_card = #{idCard},</if>
  318. <if test="password != null and password != '' ">password = #{password},</if>
  319. <if test="status != null">status = #{status},</if>
  320. <if test="delFlag != null">del_flag = #{delFlag},</if>
  321. <if test="loginIp != null">login_ip = #{loginIp},</if>
  322. <if test="loginDate != null">login_date = #{loginDate},</if>
  323. <if test="createBy != null">create_by = #{createBy},</if>
  324. <if test="createTime != null">create_time = #{createTime},</if>
  325. <if test="updateBy != null">update_by = #{updateBy},</if>
  326. <if test="updateTime != null">update_time = #{updateTime},</if>
  327. <if test="token != null">token = #{token},</if>
  328. <if test="remark != null">remark = #{remark},</if>
  329. <if test="qrCodeWeixin != null">qr_code_weixin = #{qrCodeWeixin},</if>
  330. <if test="qrCodeWecom != null">qr_code_wecom = #{qrCodeWecom},</if>
  331. <if test="jpushId != null">jpush_id = #{jpushId},</if>
  332. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  333. <if test="qwStatus != null">qw_status = #{qwStatus},</if>
  334. <if test="domain != null">`domain` = #{domain},</if>
  335. <if test="isAudit != null">`is_audit` = #{isAudit},</if>
  336. <if test="addressId != null">`address_id` = #{addressId},</if>
  337. <if test="maOpenId != null">`ma_open_id` = #{maOpenId},</if>
  338. </trim>
  339. where company_id = #{companyId}
  340. </update>
  341. <delete id="deleteCompanyUserById" parameterType="Long">
  342. delete from company_user where user_id = #{userId}
  343. </delete>
  344. <delete id="deleteCompanyUserByIds" parameterType="String">
  345. delete from company_user where user_id in
  346. <foreach item="userId" collection="array" open="(" separator="," close=")">
  347. #{userId}
  348. </foreach>
  349. </delete>
  350. <update id="updateUserAvatar" parameterType="SysUser">
  351. update company_user set avatar = #{avatar} where user_name = #{userName}
  352. </update>
  353. <update id="resetUserPwd" parameterType="SysUser">
  354. update company_user set password = #{password} where user_name = #{userName}
  355. </update>
  356. <select id="selectUserByUserName" parameterType="String" resultMap="CompanyUserResult">
  357. <include refid="selectUserVo"/>
  358. where u.user_name = #{userName}
  359. </select>
  360. <select id="selectCompanyQwUserByIds" resultType="com.fs.company.vo.CompanyQwUserByIdsVo">
  361. SELECT b.user_id,b.company_id,a.qw_user_id,a.qw_user_name,b.nick_name
  362. FROM qw_user a inner join company_user b on a.company_user_id = b.user_id
  363. where a.id in <foreach collection="ids" open="(" close=")" separator="," item="item">#{item}</foreach>
  364. and b.voice_print_url is not null
  365. </select>
  366. <select id="selectCompanyUserByIds" resultType="com.fs.company.domain.CompanyUser">
  367. select cu.*
  368. from company_user cu
  369. where cu.user_id in
  370. <foreach collection="ids" item="id" open="(" separator="," close=")">
  371. #{id}
  372. </foreach>
  373. </select>
  374. <select id="selectAllCompanyUserAndSelf" resultType="CompanyUser">
  375. SELECT
  376. *
  377. FROM
  378. company_user
  379. <where>
  380. del_flag = 0
  381. <if test="companyId == null">
  382. AND (company_user.user_id = #{userId} or company_user.parent_id = #{userId})
  383. </if>
  384. <if test="companyId != null">
  385. AND company_user.company_id = #{companyId}
  386. </if>
  387. </where>
  388. </select>
  389. <select id="getAllUserListLimit" resultType="com.fs.company.domain.CompanyUser">
  390. SELECT * FROM company_user
  391. <where>
  392. <if test="companyId != null">
  393. AND company_id != #{companyId}
  394. </if>
  395. <if test="keywords != null and keywords != ''">
  396. AND (
  397. phonenumber LIKE CONCAT(#{keywords}, '%')
  398. OR user_name LIKE CONCAT(#{keywords}, '%')
  399. OR nick_name LIKE CONCAT(#{keywords}, '%')
  400. )
  401. </if>
  402. </where>
  403. limit 10
  404. </select>
  405. <select id="selectCompanyUserByPhone" resultType="com.fs.company.domain.CompanyUser">
  406. select user_id, dept_id, user_name, nick_name, user_type, email, phonenumber, sex, avatar, password, status, del_flag, login_ip, login_date, create_by, create_time, update_by, update_time, remark, open_id, id_card, company_id, qr_code_weixin, qr_code_wecom, jpush_id, qw_user_id, qw_status, voice_print_url, address_id, `domain`, parent_id, bind_code from company_user where phonenumber=#{phone} and del_flag=0
  407. </select>
  408. <sql id="selectUserVo">
  409. select u.user_id,u.company_id,u.qw_user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar,
  410. u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by,
  411. u.create_time,u.id_card, u.remark,u.user_type,u.open_id,u.qr_code_weixin,u.qr_code_wecom,u.jpush_id,u.domain,u.is_audit,u.address_id,
  412. d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
  413. r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,
  414. u.is_need_register_member, u.is_allowed_all_register,u.doctor_id,u.union_id,u.cid_server_id
  415. from company_user u
  416. left join company_dept d on u.dept_id = d.dept_id
  417. left join company_user_role ur on u.user_id = ur.user_id
  418. left join company_role r on r.role_id = ur.role_id
  419. </sql>
  420. <select id="selectAllCompanyUserByCompanyIdAndDeptId" resultType="com.fs.company.domain.CompanyUser">
  421. select * from company_user where del_flag = '0'
  422. and company_id = #{companyId}
  423. <if test="deptId != null">
  424. and dept_id = #{deptId}
  425. </if>
  426. </select>
  427. <select id="selectCompanyUserListByMap" resultType="com.fs.his.vo.OptionsVO">
  428. select
  429. concat(cu.nick_name,'(',cu.user_id,')') as dictLabel,
  430. cu.user_id as dictValue
  431. from company_user cu
  432. <where>
  433. <if test="params.nickName != null and params.nickName != ''">
  434. and cu.nick_name like concat( '%',#{params.nickName}, '%')
  435. </if>
  436. <if test="params.companyId != null">
  437. and cu.company_id = #{params.companyId}
  438. </if>
  439. <if test="params.combinedDeptList != null and !params.combinedDeptList.isEmpty() ">
  440. AND cu.dept_id IN
  441. <foreach collection='params.combinedDeptList' item='item' open='(' separator=',' close=')'>
  442. #{item}
  443. </foreach>
  444. </if>
  445. </where>
  446. </select>
  447. <update id="setIsRegisterMember" parameterType="Long">
  448. update company_user
  449. set is_need_register_member = #{status} where user_id in
  450. <foreach item="userId" collection="userIds" open="(" separator="," close=")">
  451. #{userId}
  452. </foreach>
  453. </update>
  454. <update id="auditUsers">
  455. update company_user
  456. set is_audit = 1
  457. where user_id in
  458. <foreach collection="userIds" open="(" close=")" separator="," item="id">
  459. #{id}
  460. </foreach>
  461. </update>
  462. <select id="selectMyUserList" parameterType="com.fs.company.vo.CompanyUserVO" resultMap="CompanyUserVOResult">
  463. select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.open_id,u.id_card, d.dept_name, d.leader, u.is_audit,
  464. cr.role_id, cr.role_name
  465. from company_user u
  466. left join company_user_role cur on cur.user_id = u.user_id
  467. left join company_role cr on cr.role_id = cur.role_id
  468. left join company_dept d on u.dept_id = d.dept_id
  469. where u.del_flag = '0' and u.status=0
  470. <if test="companyId != null ">
  471. AND u.company_id = #{companyId}
  472. </if>
  473. <if test="nickName != null and nickName != ''">
  474. AND u.nick_name like concat('%', #{nickName}, '%')
  475. </if>
  476. <if test="phonenumber != null and phonenumber != ''">
  477. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  478. </if>
  479. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  480. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  481. </if>
  482. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  483. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  484. </if>
  485. <if test="deptId != null and deptId != 0">
  486. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  487. </if>
  488. <if test="isAudit != null">
  489. AND u.is_audit = #{isAudit}
  490. </if>
  491. </select>
  492. <resultMap type="com.fs.company.vo.CompanyUserVO" id="CompanyUserVOResult">
  493. <result property="userId" column="user_id" />
  494. <result property="companyId" column="company_id" />
  495. <result property="deptId" column="dept_id" />
  496. <result property="userName" column="user_name" />
  497. <result property="nickName" column="nick_name" />
  498. <result property="userType" column="user_type" />
  499. <result property="email" column="email" />
  500. <result property="phonenumber" column="phonenumber" />
  501. <result property="sex" column="sex" />
  502. <result property="avatar" column="avatar" />
  503. <result property="idCard" column="id_card" />
  504. <result property="password" column="password" />
  505. <result property="status" column="status" />
  506. <result property="delFlag" column="del_flag" />
  507. <result property="loginIp" column="login_ip" />
  508. <result property="loginDate" column="login_date" />
  509. <result property="createBy" column="create_by" />
  510. <result property="createTime" column="create_time" />
  511. <result property="updateBy" column="update_by" />
  512. <result property="updateTime" column="update_time" />
  513. <result property="token" column="token" />
  514. <result property="remark" column="remark" />
  515. <result property="openId" column="open_id" />
  516. <result property="nowDayCustomerCount" column="now_day_customer_count" />
  517. <result property="domain" column="domain" />
  518. <result property="isAudit" column="is_audit" />
  519. <result property="addressId" column="address_id" />
  520. <association property="dept" column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
  521. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  522. <collection property="posts" javaType="java.util.ArrayList" ofType="com.fs.company.domain.CompanyPost"
  523. select="com.fs.company.mapper.CompanyPostMapper.selectPostsByUserId" column="{user_id=user_id}" />
  524. </resultMap>
  525. <select id="getUserInfoByUserIds" resultType="com.fs.company.domain.CompanyUser">
  526. SELECT user_id,user_name FROM company_user WHERE user_id IN <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
  527. #{item}
  528. </foreach>
  529. </select>
  530. <select id="queryCompanyUserWatchCount" resultType="java.lang.Long">
  531. select count(1) from fs_course_watch_log
  532. <where>
  533. <if test="companyUserId != null">
  534. AND company_user_id = #{companyUserId}
  535. </if>
  536. <if test="previousDay != null">
  537. and camp_period_time = ${previousDay}
  538. </if>
  539. </where>
  540. </select>
  541. <select id="queryCompanyUserWatchCountCompleted" resultType="java.lang.Long">
  542. select count(1) from fs_course_watch_log
  543. <where>
  544. AND log_type = 2
  545. <if test="companyUserId != null">
  546. AND company_user_id = #{companyUserId}
  547. </if>
  548. <if test="previousDay != null">
  549. and camp_period_time = ${previousDay}
  550. </if>
  551. </where>
  552. </select>
  553. <select id="queryCompanyUserInterruptCount" resultType="java.lang.Long">
  554. select count(1) from fs_course_watch_log
  555. <where>
  556. AND log_type = 4
  557. <if test="companyUserId != null">
  558. AND company_user_id = #{companyUserId}
  559. </if>
  560. <if test="previousDay != null">
  561. and camp_period_time = ${previousDay}
  562. </if>
  563. </where>
  564. </select>
  565. <select id="getCompanyUserList" resultType="com.fs.company.domain.CompanyUser">
  566. SELECT
  567. u.user_id,
  568. u.user_name,
  569. u.phonenumber,
  570. cdbu.company_user_id
  571. FROM
  572. company_user u
  573. LEFT JOIN company_domain_bind_user cdbu ON u.user_id=cdbu.company_user_id
  574. WHERE
  575. u.del_flag = '0'
  576. AND cdbu.id IS NULL
  577. <if test="userName != null and userName != ''">
  578. AND u.user_name like concat( #{userName}, '%')
  579. </if>
  580. <if test="nickName != null and nickName != ''">
  581. AND u.nick_name like concat( #{nickName}, '%')
  582. </if>
  583. <if test="companyId != null and companyId != ''">
  584. AND u.company_id = #{companyId}
  585. </if>
  586. <if test="status != null and status != ''">
  587. AND u.status = #{status}
  588. </if>
  589. <if test="phonenumber != null and phonenumber != ''">
  590. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  591. </if>
  592. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  593. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  594. </if>
  595. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  596. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  597. </if>
  598. <!-- 数据范围过滤 -->
  599. ${params.dataScope}
  600. </select>
  601. <select id="selectQwUserListLikeName" resultType="com.fs.qw.vo.QwOptionsVO">
  602. select
  603. qw.qw_user_name as dictLabel,
  604. qw.id as dictValue
  605. from qw_user qw
  606. <where>
  607. <if test="params.qwUserName != null and params.qwUserName != ''">
  608. and qw.qw_user_name like concat(#{params.qwUserName}, '%')
  609. </if>
  610. <if test="params.companyId != null">
  611. and qw.company_id = #{params.companyId}
  612. </if>
  613. </where>
  614. </select>
  615. <select id="selectCompanyUserNameByIds" resultType="java.lang.String">
  616. select GROUP_CONCAT(DISTINCT nick_name ORDER BY nick_name SEPARATOR ',') as nick_name from company_user where user_id in
  617. <foreach collection="companyUserIds.split(',')" item="companyUserId" open="(" close=")" separator=",">
  618. #{companyUserId}
  619. </foreach>
  620. </select>
  621. <update id="batchUpdateUserDomain">
  622. update company_user set domain=#{domain} where user_id in <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">#{item}</foreach>
  623. </update>
  624. <update id="batchUpdateUserDept">
  625. UPDATE company_user
  626. SET dept_id = CASE user_id
  627. <foreach collection="companyUserList" item="item" separator=" ">
  628. WHEN #{item.userId} THEN #{item.deptId}
  629. </foreach>
  630. END
  631. WHERE user_id IN
  632. <foreach collection="companyUserList" item="item" open="(" separator="," close=")">
  633. #{item.userId}
  634. </foreach>
  635. </update>
  636. <select id="selectCompanyUserByCompanyUserId" resultMap="CompanyUserResult">
  637. select * from company_user where user_id = #{companyUserId}
  638. </select>
  639. <select id="selectCompanyByIpadStatus" resultType="com.fs.company.vo.QwIpadTotalVo">
  640. select company_id companyId,company_name companyName,
  641. sum(bind_count) bindCount,stat_time statTime from qw_ipad_total
  642. <where>
  643. <if test="dateTime != null">
  644. and stat_time like concat(#{dateTime}, '%')
  645. </if>
  646. </where>
  647. group by company_id,company_name
  648. </select>
  649. <select id="selectCompanyByIpadStatusCount" resultType="com.fs.company.vo.QwIpadTotalVo">
  650. SELECT qw.company_id companyId,c.company_name companyName,count(1) bindCount
  651. FROM `qw_user` qw left join company c on qw.company_id = c.company_id
  652. where qw.ipad_status is not null
  653. GROUP BY qw.company_id
  654. </select>
  655. <update id="updateAllowedAllRegister" parameterType="Long">
  656. update company_user
  657. set is_allowed_all_register = #{status} where user_id in
  658. <foreach item="userId" collection="userIds" open="(" separator="," close=")">
  659. #{userId}
  660. </foreach>
  661. </update>
  662. <select id="selectCompanyUserNameByIdsList" resultType="java.lang.String">
  663. SELECT nick_name from company_user where user_id in
  664. <foreach collection="companyUserIDs" item="id" open="(" separator="," close=")">
  665. #{id}
  666. </foreach>
  667. </select>
  668. <!-- 批量更新公司用户的绑定销售ID -->
  669. <update id="batchUpdateBindCompanyUserId">
  670. update fs_user
  671. set bind_company_user_id = #{bindCompanyUserId}
  672. where user_id in
  673. <foreach collection="userIds" item="userId" open="(" separator="," close=")">
  674. #{userId}
  675. </foreach>
  676. </update>
  677. <update id="updateVcCompanyUser">
  678. update vc_company_user
  679. set upload_url = #{vcCompanyUser.uploadUrl},
  680. times = #{vcCompanyUser.times},
  681. upload_time = #{vcCompanyUser.uploadTime},
  682. latest_text_to_speech_url = #{vcCompanyUser.latestTextToSpeechUrl}
  683. where company_user_id = #{vcCompanyUser.companyUserId}
  684. </update>
  685. <!-- 根据销售ID查询绑定的fs_user用户列表 -->
  686. <select id="selectBoundFsUsersByCompanyUserId" resultType="com.fs.hisStore.domain.FsUserScrm">
  687. SELECT *
  688. FROM fs_user
  689. WHERE bind_company_user_id = #{companyUserId}
  690. AND is_del = 0
  691. </select>
  692. <select id="selectCompanyUserByQwUserId" resultType="com.fs.company.domain.CompanyUser">
  693. SELECT * FROM company_user
  694. WHERE FIND_IN_SET(#{qwUserId}, qw_user_id) > 0
  695. order by create_time desc
  696. limit 1
  697. </select>
  698. <select id="selectVcCompanyUserByCompanyUserId" resultType="com.fs.company.param.VcCompanyUser">
  699. select
  700. id,times,speaker_id,upload_url,upload_time,company_user_id,latest_text_to_speech_url,version_id
  701. from
  702. vc_company_user
  703. where company_user_id = #{companyUserId}
  704. </select>
  705. <update id="unbindCidServer" parameterType="java.lang.Long" >
  706. update company_user
  707. set cid_server_id = null
  708. where user_id = #{companyUserId}
  709. </update>
  710. </mapper>