SysUserMapper.xml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.platform.dao.mapper.upms.SysUserMapper">
  4. <!-- <select id="selectVOByKeyword" resultType="com.platform.dao.vo.SysUserVO"-->
  5. <!-- parameterType="com.platform.dao.dto.upms.SysUserDTO">-->
  6. <!-- select u.* from t_sys_user u-->
  7. <!-- join t_sys_user_role role-->
  8. <!-- on u.user_id=role.user_id-->
  9. <!-- where 1=1-->
  10. <!-- <if test="keyword !=null and keyword !=''">-->
  11. <!-- and (u.username like CONCAT('%',#{keyword},'%')-->
  12. <!-- or u.real_name like CONCAT('%',#{keyword},'%'))-->
  13. <!-- </if>-->
  14. <!-- <if test="deptId !=null and deptId !=''">-->
  15. <!-- and exists (select 1 from t_sys_user_dept t where t.user_id = u.user_id and t.dept_id = #{deptId}-->
  16. <!-- union select 1 from t_sys_dept t where t.dept_id = #{deptId} and t.parent_id = '0')-->
  17. <!-- </if>-->
  18. <!-- <if test="phone !=null and phone !=''">-->
  19. <!-- and u.phone = #{phone}-->
  20. <!-- </if>-->
  21. <!-- <if test="username !=null and username !=''">-->
  22. <!-- and u.username = #{username}-->
  23. <!-- </if>-->
  24. <!-- <if test="teamId !=null and teamId !=''">-->
  25. <!-- and exists (select 1 from t_sys_user_team t where t.user_id = u.user_id and t.team_id = #{teamId})-->
  26. <!-- </if>-->
  27. <!-- <if test="identityType !=null">-->
  28. <!-- and u.identity_type = #{identityType}-->
  29. <!-- </if>-->
  30. <!-- <if test="roleId!=null and roleId!=''">-->
  31. <!-- and role.role_id=#{roleId}-->
  32. <!-- </if>-->
  33. <!-- order by u.update_time desc-->
  34. <!-- </select>-->
  35. <select id="selectVOByKeyword" resultType="com.platform.dao.vo.SysUserVO"
  36. parameterType="com.platform.dao.dto.upms.SysUserDTO">
  37. select distinct u.* from t_sys_user u
  38. join t_sys_user_role role
  39. on u.user_id=role.user_id left join t_sys_role srole on role.role_id=srole.role_id
  40. left join t_sys_user_dept ud on ud.user_id = u.user_id
  41. left join t_sys_dept dept on dept.dept_id = ud.dept_id
  42. where 1=1
  43. <if test="keyword !=null and keyword !=''">
  44. and (u.username like CONCAT('%',#{keyword},'%')
  45. or u.real_name like CONCAT('%',#{keyword},'%'))
  46. </if>
  47. <if test="deptId !=null and deptId !=''">
  48. and exists (select 1 from t_sys_user_dept t where t.user_id = u.user_id and t.dept_id = #{deptId}
  49. union select 1 from t_sys_dept t where t.dept_id = #{deptId} and t.parent_id = '0')
  50. </if>
  51. <if test="phone !=null and phone !=''">
  52. and u.phone = #{phone}
  53. </if>
  54. <if test="username !=null and username !=''">
  55. and u.username = #{username}
  56. </if>
  57. <if test="teamId !=null and teamId !=''">
  58. and exists (select 1 from t_sys_user_team t where t.user_id = u.user_id and t.team_id = #{teamId})
  59. </if>
  60. <if test="identityType !=null">
  61. and u.identity_type = #{identityType}
  62. </if>
  63. <if test="roleId!=null and roleId!=''">
  64. and role.role_id=#{roleId}
  65. </if>
  66. <if test="roleCode!=null and roleCode!=''">
  67. and srole.role_code=#{roleCode}
  68. </if>
  69. <if test="deptIds !=null and deptIds.size>0">
  70. and dept.dept_id in
  71. <foreach collection="deptIds" open="(" separator="," close=")" item="item">
  72. #{item}
  73. </foreach>
  74. </if>
  75. order by u.update_time desc
  76. </select>
  77. <select id="selectByDept" resultType="com.platform.dao.vo.SysUserVO"
  78. parameterType="com.platform.dao.dto.upms.SysUserDTO">
  79. select u.* from t_sys_user u
  80. left join t_sys_user_dept ud on u.user_id = ud.user_id
  81. where 1=1
  82. <if test="deptIds != null and deptIds.size >0">
  83. AND ud.dept_id in
  84. <foreach item="item" index="index" collection="deptIds" open="(" close=")" separator=",">
  85. #{item}
  86. </foreach>
  87. </if>
  88. order by u.update_time desc
  89. </select>
  90. <!-- <select id="selectByDept" resultType="com.platform.dao.vo.SysUserVO"-->
  91. <!-- parameterType="com.platform.dao.dto.upms.SysUserDTO">-->
  92. <!-- select u.* from t_sys_user u-->
  93. <!-- left join t_sys_user_dept ud on u.user_id = ud.user_id-->
  94. <!-- where 1=1-->
  95. <!-- <if test="deptIds != null and deptIds.size >0">-->
  96. <!-- AND ud.dept_id in-->
  97. <!-- <foreach item="item" index="index" collection="deptIds" open="(" close=")" separator=",">-->
  98. <!-- #{item}-->
  99. <!-- </foreach>-->
  100. <!-- </if>-->
  101. <!-- order by u.update_time desc-->
  102. <!-- </select>-->
  103. <select id="selectDeptRoleUser" resultType="com.platform.dao.vo.SysUserVO"
  104. parameterType="com.platform.dao.dto.upms.SysUserDTO">
  105. select distinct u.* from t_sys_user u, t_sys_user_dept ud, t_sys_user_role ur, t_sys_role r
  106. where u.user_id = ud.user_id and u.user_id = ur.user_id and ur.role_id = r.role_id
  107. <if test="deptIds != null and deptIds.size >0">
  108. AND ud.dept_id in
  109. <foreach item="item" index="index" collection="deptIds" open="(" close=")" separator=",">
  110. #{item}
  111. </foreach>
  112. </if>
  113. <if test="roleId !=null and roleId !=''">
  114. and r.role_id = #{roleId}
  115. </if>
  116. <if test="roleIds != null and roleIds.size >0">
  117. AND r.role_id in
  118. <foreach item="item" index="index" collection="roleIds" open="(" close=")" separator=",">
  119. #{item}
  120. </foreach>
  121. </if>
  122. <if test="roleCode !=null and roleCode !=''">
  123. and r.role_code = #{roleCode}
  124. </if>
  125. <if test="roleCodes != null and roleCodes.size >0">
  126. AND r.role_code in
  127. <foreach item="item" index="index" collection="roleCodes" open="(" close=")" separator=",">
  128. #{item}
  129. </foreach>
  130. </if>
  131. <if test="deptId != null">
  132. and ud.dept_id = #{deptId}
  133. </if>
  134. <if test="userId != null and userId != ''">
  135. and u.user_id = #{userId}
  136. </if>
  137. <choose>
  138. <when test="orderByFlag != null and orderByFlag == 1">
  139. order by u.created_time asc
  140. </when>
  141. <otherwise>
  142. order by u.update_time desc
  143. </otherwise>
  144. </choose>
  145. </select>
  146. <select id="selectUserNameById" resultType="java.lang.String" parameterType="java.lang.Object">
  147. select real_name
  148. from t_sys_user
  149. where user_id = #{value}
  150. </select>
  151. <select id="getSysUserList" parameterType="com.platform.dao.dto.upms.SysUserDeptDTO"
  152. resultType="com.platform.dao.vo.SysUserVO">
  153. select distinct user.username as username,user.real_name realName, user.user_id userId from t_sys_user user
  154. join t_sys_user_role urole on urole.user_id = user.user_id
  155. join t_sys_role role on urole.role_id = role.role_id
  156. join t_sys_user_dept dept on user.user_id = dept.user_id
  157. where role.role_name = '维修人员' and user.status = 1
  158. <if test="deptId != null and deptId != ''">
  159. and dept.dept_id = #{deptId}
  160. </if>
  161. </select>
  162. <select id="getRepairUsers" parameterType="com.platform.dao.dto.upms.SysUserDTO"
  163. resultType="com.platform.dao.vo.SysUserVO">
  164. select distinct user.username as username,user.real_name realName, user.user_id userId from t_sys_user user
  165. join t_sys_user_role urole on urole.user_id = user.user_id
  166. join t_sys_role role on urole.role_id = role.role_id
  167. join t_sys_user_dept dept on user.user_id = dept.user_id
  168. where user.status = 1
  169. <if test="roleCode != null">
  170. and role.role_code = #{roleCode}
  171. </if>
  172. <if test="deptId != null and deptId != ''">
  173. and dept.dept_id = #{deptId}
  174. </if>
  175. <if test="roleCodes != null and roleCodes.size >0">
  176. AND role.role_code in
  177. <foreach item="item" index="index" collection="roleCodes" open="(" close=")" separator=",">
  178. #{item}
  179. </foreach>
  180. </if>
  181. </select>
  182. <select id="getSysUserVO" parameterType="com.platform.dao.dto.upms.SysUserDTO"
  183. resultType="com.platform.dao.vo.SysUserVO">
  184. SELECT user.*,dept.name as dept, GROUP_CONCAT(role.role_name) as roless
  185. FROM t_sys_user USER LEFT JOIN t_sys_user_role ur
  186. ON user.`user_id`=ur.`user_id`
  187. LEFT JOIN t_sys_role role
  188. ON ur.`role_id`=role.`role_id`
  189. LEFT JOIN t_sys_user_dept ud
  190. ON user.`user_id`=ud.user_id
  191. LEFT JOIN t_sys_dept dept
  192. ON ud.`dept_id`=dept.`dept_id`
  193. where 1=1
  194. <if test="keyword !=null and keyword !=''">
  195. and (user.username like CONCAT('%',#{keyword},'%')
  196. or user.real_name like CONCAT('%',#{keyword},'%'))
  197. </if>
  198. <if test="deptId !=null and deptId !=''">
  199. and exists (select 1 from t_sys_user_dept ud where ud.user_id = user.user_id and ud.dept_id = #{deptId}
  200. union select 1 from t_sys_dept dept where ud.dept_id = #{deptId} and ud.parent_id = '0')
  201. </if>
  202. <if test="phone !=null and phone !=''">
  203. and user.phone = #{phone}
  204. </if>
  205. <if test="username !=null and username !=''">
  206. and user.username = #{username}
  207. </if>
  208. <if test="teamId !=null and teamId !=''">
  209. and exists (select 1 from t_sys_user_team t where t.user_id = user.user_id and t.team_id = #{teamId})
  210. </if>
  211. <if test="identityType !=null">
  212. and user.identity_type = #{identityType}
  213. </if>
  214. <if test="roleId!=null and roleId!=''">
  215. and role.role_id=#{roleId}
  216. </if>
  217. GROUP BY user.`user_id`
  218. order by user.update_time desc
  219. </select>
  220. </mapper>