CompanyUserMapper.xml 33 KB

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