CompanyUserMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  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="domain" column="domain" />
  39. <result property="isAudit" column="is_audit" />
  40. <result property="addressId" column="address_id" />
  41. <result property="isNeedRegisterMember" column="is_need_register_member" />
  42. <association property="dept" column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
  43. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  44. </resultMap>
  45. <resultMap id="deptResult" type="CompanyDept">
  46. <id property="deptId" column="dept_id" />
  47. <result property="parentId" column="parent_id" />
  48. <result property="deptName" column="dept_name" />
  49. <result property="orderNum" column="order_num" />
  50. <result property="leader" column="leader" />
  51. <result property="status" column="dept_status" />
  52. </resultMap>
  53. <resultMap id="RoleResult" type="CompanyRole">
  54. <id property="roleId" column="role_id" />
  55. <result property="roleName" column="role_name" />
  56. <result property="roleKey" column="role_key" />
  57. <result property="roleSort" column="role_sort" />
  58. <result property="dataScope" column="data_scope" />
  59. <result property="status" column="role_status" />
  60. </resultMap>
  61. <select id="selectCompanyUserList" parameterType="CompanyUser" resultMap="CompanyUserResult">
  62. select u.*, d.dept_name, d.leader from company_user u
  63. left join company_dept d on u.dept_id = d.dept_id
  64. where u.del_flag = '0'
  65. <if test="userName != null and userName != ''">
  66. AND u.user_name like concat('%', #{userName}, '%')
  67. </if>
  68. <if test="nickName != null and nickName != ''">
  69. AND u.nick_name like concat('%', #{nickName}, '%')
  70. </if>
  71. <if test="companyId != null and companyId != ''">
  72. AND u.company_id = #{companyId}
  73. </if>
  74. <if test="status != null and status != ''">
  75. AND u.status = #{status}
  76. </if>
  77. <if test="phonenumber != null and phonenumber != ''">
  78. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  79. </if>
  80. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  81. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  82. </if>
  83. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  84. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  85. </if>
  86. <if test="deptId != null and deptId != 0">
  87. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  88. </if>
  89. <!-- 数据范围过滤 -->
  90. ${params.dataScope}
  91. </select>
  92. <select id="selectCompanyUserById" parameterType="Long" resultMap="CompanyUserResult">
  93. <include refid="selectUserVo"/>
  94. where u.user_id = #{userId}
  95. </select>
  96. <insert id="insertCompanyUser" parameterType="CompanyUser" useGeneratedKeys="true" keyProperty="userId">
  97. insert into company_user
  98. <trim prefix="(" suffix=")" suffixOverrides=",">
  99. <if test="companyId != null">company_id,</if>
  100. <if test="deptId != null">dept_id,</if>
  101. <if test="userName != null and userName != ''">user_name,</if>
  102. <if test="nickName != null and nickName != ''">nick_name,</if>
  103. <if test="userType != null">user_type,</if>
  104. <if test="email != null">email,</if>
  105. <if test="phonenumber != null">phonenumber,</if>
  106. <if test="sex != null">sex,</if>
  107. <if test="avatar != null">avatar,</if>
  108. <if test="idCard != null">id_card,</if>
  109. <if test="password != null">password,</if>
  110. <if test="status != null">status,</if>
  111. <if test="delFlag != null">del_flag,</if>
  112. <if test="loginIp != null">login_ip,</if>
  113. <if test="loginDate != null">login_date,</if>
  114. <if test="createBy != null">create_by,</if>
  115. <if test="createTime != null">create_time,</if>
  116. <if test="updateBy != null">update_by,</if>
  117. <if test="updateTime != null">update_time,</if>
  118. <if test="token != null">token,</if>
  119. <if test="remark != null">remark,</if>
  120. <if test="openId != null">open_id,</if>
  121. <if test="qrCodeWeixin != null">qr_code_weixin,</if>
  122. <if test="qrCodeWecom != null">qr_code_wecom,</if>
  123. <if test="jpushId != null">jpush_id,</if>
  124. <if test="qwUserId != null">qw_user_id,</if>
  125. <if test="qwStatus != null">qw_status,</if>
  126. <if test="domain != null">`domain`,</if>
  127. <if test="isAudit != null">`is_audit`,</if>
  128. <if test="addressId != null">`address_id`,</if>
  129. <if test="maOpenId != null">`ma_open_id`,</if>
  130. </trim>
  131. <trim prefix="values (" suffix=")" suffixOverrides=",">
  132. <if test="companyId != null">#{companyId},</if>
  133. <if test="deptId != null">#{deptId},</if>
  134. <if test="userName != null and userName != ''">#{userName},</if>
  135. <if test="nickName != null and nickName != ''">#{nickName},</if>
  136. <if test="userType != null">#{userType},</if>
  137. <if test="email != null">#{email},</if>
  138. <if test="phonenumber != null">#{phonenumber},</if>
  139. <if test="sex != null">#{sex},</if>
  140. <if test="avatar != null">#{avatar},</if>
  141. <if test="idCard != null">#{idCard},</if>
  142. <if test="password != null">#{password},</if>
  143. <if test="status != null">#{status},</if>
  144. <if test="delFlag != null">#{delFlag},</if>
  145. <if test="loginIp != null">#{loginIp},</if>
  146. <if test="loginDate != null">#{loginDate},</if>
  147. <if test="createBy != null">#{createBy},</if>
  148. <if test="createTime != null">#{createTime},</if>
  149. <if test="updateBy != null">#{updateBy},</if>
  150. <if test="updateTime != null">#{updateTime},</if>
  151. <if test="token != null">#{token},</if>
  152. <if test="remark != null">#{remark},</if>
  153. <if test="openId != null">#{openId},</if>
  154. <if test="qrCodeWeixin != null">#{qrCodeWeixin},</if>
  155. <if test="qrCodeWecom != null">#{qrCodeWecom},</if>
  156. <if test="jpushId != null">#{jpushId},</if>
  157. <if test="qwUserId != null">#{qwUserId},</if>
  158. <if test="qwStatus != null">#{qwStatus},</if>
  159. <if test="domain != null">#{domain},</if>
  160. <if test="isAudit != null">#{isAudit},</if>
  161. <if test="addressId != null">#{addressId},</if>
  162. <if test="maOpenId != null">#{maOpenId},</if>
  163. </trim>
  164. </insert>
  165. <update id="updateCompanyUser" parameterType="CompanyUser">
  166. update company_user
  167. <trim prefix="SET" suffixOverrides=",">
  168. <if test="companyId != null">company_id = #{companyId},</if>
  169. <if test="deptId != null">dept_id = #{deptId},</if>
  170. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  171. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  172. <if test="userType != null">user_type = #{userType},</if>
  173. <if test="email != null">email = #{email},</if>
  174. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  175. <if test="sex != null">sex = #{sex},</if>
  176. <if test="avatar != null">avatar = #{avatar},</if>
  177. <if test="idCard != null">id_card = #{idCard},</if>
  178. <if test="password != null and password != '' ">password = #{password},</if>
  179. <if test="status != null">status = #{status},</if>
  180. <if test="delFlag != null">del_flag = #{delFlag},</if>
  181. <if test="loginIp != null">login_ip = #{loginIp},</if>
  182. <if test="loginDate != null">login_date = #{loginDate},</if>
  183. <if test="createBy != null">create_by = #{createBy},</if>
  184. <if test="createTime != null">create_time = #{createTime},</if>
  185. <if test="updateBy != null">update_by = #{updateBy},</if>
  186. <if test="updateTime != null">update_time = #{updateTime},</if>
  187. <if test="token != null">token = #{token},</if>
  188. <if test="remark != null">remark = #{remark},</if>
  189. <if test="qrCodeWeixin != null">qr_code_weixin = #{qrCodeWeixin},</if>
  190. <if test="qrCodeWecom != null">qr_code_wecom = #{qrCodeWecom},</if>
  191. <if test="jpushId != null">jpush_id = #{jpushId},</if>
  192. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  193. <if test="qwStatus != null">qw_status = #{qwStatus},</if>
  194. <if test="domain != null">`domain` = #{domain},</if>
  195. <if test="isAudit != null">`is_audit` = #{isAudit},</if>
  196. <if test="addressId != null">`address_id` = #{addressId},</if>
  197. <if test="maOpenId != null">`ma_open_id` = #{maOpenId},</if>
  198. </trim>
  199. where user_id = #{userId}
  200. </update>
  201. <update id="updateAllCompanyUser" parameterType="CompanyUser">
  202. update company_user
  203. <trim prefix="SET" suffixOverrides=",">
  204. <if test="companyId != null">company_id = #{companyId},</if>
  205. <if test="deptId != null">dept_id = #{deptId},</if>
  206. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  207. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  208. <if test="email != null">email = #{email},</if>
  209. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  210. <if test="sex != null">sex = #{sex},</if>
  211. <if test="avatar != null">avatar = #{avatar},</if>
  212. <if test="idCard != null">id_card = #{idCard},</if>
  213. <if test="password != null and password != '' ">password = #{password},</if>
  214. <if test="status != null">status = #{status},</if>
  215. <if test="delFlag != null">del_flag = #{delFlag},</if>
  216. <if test="loginIp != null">login_ip = #{loginIp},</if>
  217. <if test="loginDate != null">login_date = #{loginDate},</if>
  218. <if test="createBy != null">create_by = #{createBy},</if>
  219. <if test="createTime != null">create_time = #{createTime},</if>
  220. <if test="updateBy != null">update_by = #{updateBy},</if>
  221. <if test="updateTime != null">update_time = #{updateTime},</if>
  222. <if test="token != null">token = #{token},</if>
  223. <if test="remark != null">remark = #{remark},</if>
  224. <if test="qrCodeWeixin != null">qr_code_weixin = #{qrCodeWeixin},</if>
  225. <if test="qrCodeWecom != null">qr_code_wecom = #{qrCodeWecom},</if>
  226. <if test="jpushId != null">jpush_id = #{jpushId},</if>
  227. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  228. <if test="qwStatus != null">qw_status = #{qwStatus},</if>
  229. <if test="domain != null">`domain` = #{domain},</if>
  230. <if test="isAudit != null">`is_audit` = #{isAudit},</if>
  231. <if test="addressId != null">`address_id` = #{addressId},</if>
  232. <if test="maOpenId != null">`ma_open_id` = #{maOpenId},</if>
  233. </trim>
  234. where company_id = #{companyId}
  235. </update>
  236. <delete id="deleteCompanyUserById" parameterType="Long">
  237. delete from company_user where user_id = #{userId}
  238. </delete>
  239. <delete id="deleteCompanyUserByIds" parameterType="String">
  240. delete from company_user where user_id in
  241. <foreach item="userId" collection="array" open="(" separator="," close=")">
  242. #{userId}
  243. </foreach>
  244. </delete>
  245. <update id="updateUserAvatar" parameterType="SysUser">
  246. update company_user set avatar = #{avatar} where user_name = #{userName}
  247. </update>
  248. <update id="resetUserPwd" parameterType="SysUser">
  249. update company_user set password = #{password} where user_name = #{userName}
  250. </update>
  251. <select id="selectUserByUserName" parameterType="String" resultMap="CompanyUserResult">
  252. <include refid="selectUserVo"/>
  253. where u.user_name = #{userName}
  254. </select>
  255. <sql id="selectUserVo">
  256. select u.user_id,u.company_id,u.qw_user_id, u.dept_id, u.user_name, u.nick_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.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,
  257. d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
  258. r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,
  259. u.is_need_register_member
  260. from company_user u
  261. left join company_dept d on u.dept_id = d.dept_id
  262. left join company_user_role ur on u.user_id = ur.user_id
  263. left join company_role r on r.role_id = ur.role_id
  264. </sql>
  265. <select id="selectMyUserList" parameterType="com.fs.company.vo.CompanyUserVO" resultMap="CompanyUserVOResult">
  266. 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
  267. from company_user u
  268. left join company_dept d on u.dept_id = d.dept_id
  269. where u.del_flag = '0' and u.status=0
  270. <if test="companyId != null ">
  271. AND u.company_id = #{companyId}
  272. </if>
  273. <if test="nickName != null and nickName != ''">
  274. AND u.nick_name like concat('%', #{nickName}, '%')
  275. </if>
  276. <if test="phonenumber != null and phonenumber != ''">
  277. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  278. </if>
  279. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  280. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  281. </if>
  282. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  283. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  284. </if>
  285. <if test="deptId != null and deptId != 0">
  286. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  287. </if>
  288. <if test="isAudit != null">
  289. AND u.is_audit = #{isAudit}
  290. </if>
  291. </select>
  292. <select id="selecCompanyAllUsersList" parameterType="com.fs.company.vo.CompanyUserVO" resultMap="CompanyUserVOResult">
  293. 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 ,
  294. (select count(1) from crm_customer cc where u.user_id= cc.receive_user_id and date_format(cc.receive_time,'%y%m%d') = date_format(now(),'%y%m%d') ) as now_day_customer_count
  295. from company_user u
  296. left join company_dept d on u.dept_id = d.dept_id
  297. where u.del_flag = '0' and u.status=0
  298. <if test="companyId != null ">
  299. AND u.company_id = #{companyId}
  300. </if>
  301. <if test="nickName != null and nickName != ''">
  302. AND u.nick_name like concat('%', #{nickName}, '%')
  303. </if>
  304. <if test="phonenumber != null and phonenumber != ''">
  305. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  306. </if>
  307. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  308. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  309. </if>
  310. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  311. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  312. </if>
  313. <if test="deptId != null and deptId != 0">
  314. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  315. </if>
  316. </select>
  317. <select id="selectCompanyQwUserByIds" resultType="com.fs.company.vo.CompanyQwUserByIdsVo">
  318. SELECT b.user_id,b.company_id,a.qw_user_id,a.qw_user_name,b.nick_name
  319. FROM qw_user a inner join company_user b on a.company_user_id = b.user_id
  320. where a.id in <foreach collection="ids" open="(" close=")" separator="," item="item">#{item}</foreach>
  321. and b.voice_print_url is not null
  322. </select>
  323. <select id="selectCompanyUserByIds" resultType="com.fs.company.domain.CompanyUser">
  324. select cu.*
  325. from company_user cu
  326. where cu.user_id in
  327. <foreach collection="ids" item="id" open="(" separator="," close=")">
  328. #{id}
  329. </foreach>
  330. </select>
  331. <resultMap type="com.fs.company.vo.CompanyUserVO" id="CompanyUserVOResult">
  332. <result property="userId" column="user_id" />
  333. <result property="companyId" column="company_id" />
  334. <result property="deptId" column="dept_id" />
  335. <result property="userName" column="user_name" />
  336. <result property="nickName" column="nick_name" />
  337. <result property="userType" column="user_type" />
  338. <result property="email" column="email" />
  339. <result property="phonenumber" column="phonenumber" />
  340. <result property="sex" column="sex" />
  341. <result property="avatar" column="avatar" />
  342. <result property="idCard" column="id_card" />
  343. <result property="password" column="password" />
  344. <result property="status" column="status" />
  345. <result property="delFlag" column="del_flag" />
  346. <result property="loginIp" column="login_ip" />
  347. <result property="loginDate" column="login_date" />
  348. <result property="createBy" column="create_by" />
  349. <result property="createTime" column="create_time" />
  350. <result property="updateBy" column="update_by" />
  351. <result property="updateTime" column="update_time" />
  352. <result property="token" column="token" />
  353. <result property="remark" column="remark" />
  354. <result property="openId" column="open_id" />
  355. <result property="nowDayCustomerCount" column="now_day_customer_count" />
  356. <result property="domain" column="domain" />
  357. <result property="isAudit" column="is_audit" />
  358. <result property="addressId" column="address_id" />
  359. <association property="dept" column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
  360. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  361. <collection property="posts" javaType="java.util.ArrayList" ofType="com.fs.company.domain.CompanyPost"
  362. select="com.fs.company.mapper.CompanyPostMapper.selectPostsByUserId" column="{user_id=user_id}" />
  363. </resultMap>
  364. <select id="selectAllCompanyUserByParentId" resultType="CompanyUser">
  365. SELECT
  366. *
  367. FROM
  368. company_user
  369. WHERE
  370. del_flag = 0
  371. AND parent_id = #{parentId}
  372. </select>
  373. <select id="getAllUserListLimit" resultType="com.fs.company.domain.CompanyUser">
  374. SELECT * FROM company_user
  375. <where>
  376. <if test="companyId != null">
  377. AND company_id != #{companyId}
  378. </if>
  379. <if test="keywords != null and keywords != ''">
  380. AND (
  381. phonenumber LIKE CONCAT(#{keywords}, '%')
  382. OR user_name LIKE CONCAT(#{keywords}, '%')
  383. OR nick_name LIKE CONCAT(#{keywords}, '%')
  384. )
  385. </if>
  386. </where>
  387. limit 10
  388. </select>
  389. <update id="auditUsers">
  390. update company_user
  391. set is_audit = 1
  392. where user_id in
  393. <foreach collection="userIds" open="(" close=")" separator="," item="id">
  394. #{id}
  395. </foreach>
  396. </update>
  397. <update id="uploadQrCode">
  398. update company_user set qr_code_weixin=#{url} where user_id=${userId}
  399. </update>
  400. <select id="selectAllCompanyUserAndSelf" resultType="CompanyUser">
  401. SELECT
  402. *
  403. FROM
  404. company_user
  405. WHERE
  406. del_flag = 0
  407. AND (company_user.user_id = #{userId} or company_user.parent_id = #{userId})
  408. </select>
  409. <select id="selectQwWatchLogStatisticsListVONewCount" resultType="java.lang.Long">
  410. </select>
  411. <select id="selectCompanyUserListByMap" resultType="com.fs.his.vo.OptionsVO">
  412. select
  413. cu.user_id dictValue,
  414. cu.nick_name dictLabel
  415. from company_user cu
  416. <where>
  417. <if test="params.companyUserName != null and params.companyUserName != ''">
  418. and cu.nick_name like concat('%', #{params.companyUserName}, '%')
  419. </if>
  420. <if test="params.companyId != null">
  421. and cu.company_id = #{params.companyId}
  422. </if>
  423. </where>
  424. </select>
  425. <select id="selectUserAllCompanyUserId" resultType="java.lang.Long">
  426. select distinct user_id from company_user where parent_id=${companyUserId}
  427. </select>
  428. <select id="selectCompanyUserNameUserById" resultType="java.lang.String">
  429. select concat(nick_name,'_',user_name) from company_user where user_id=${userId} limit 1
  430. </select>
  431. <select id="selectCompanyUserQwListVO" resultType="com.fs.company.vo.CompanyUserQwListVO">
  432. select u.*, d.dept_name, d.leader from company_user u
  433. left join company_dept d on u.dept_id = d.dept_id
  434. where u.del_flag = '0'
  435. <if test="userName != null and userName != ''">
  436. AND u.user_name like concat(#{userName}, '%')
  437. </if>
  438. <if test="nickName != null and nickName != ''">
  439. AND u.nick_name like concat( #{nickName}, '%')
  440. </if>
  441. <if test="companyId != null and companyId != ''">
  442. AND u.company_id = #{companyId}
  443. </if>
  444. <if test="status != null and status != ''">
  445. AND u.status = #{status}
  446. </if>
  447. <if test="qwStatus != null ">
  448. AND u.qw_status = #{qwStatus}
  449. </if>
  450. <if test="phonenumber != null and phonenumber != ''">
  451. AND u.phonenumber like concat(#{phonenumber}, '%')
  452. </if>
  453. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  454. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  455. </if>
  456. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  457. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  458. </if>
  459. <if test="deptId != null and deptId != 0">
  460. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  461. </if>
  462. <!-- 数据范围过滤 -->
  463. ${params.dataScope}
  464. </select>
  465. <update id="setIsRegisterMember" parameterType="Long">
  466. update company_user
  467. set is_need_register_member = #{status} where user_id in
  468. <foreach item="userId" collection="userIds" open="(" separator="," close=")">
  469. #{userId}
  470. </foreach>
  471. </update>
  472. </mapper>