CompanyUserMapper.xml 33 KB

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