综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SysUserMapper.xml 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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.ruoyi.system.mapper.SysUserMapper">
  6. <resultMap type="SysUser" id="SysUserResult">
  7. <id property="userId" column="user_id" />
  8. <result property="deptId" column="dept_id" />
  9. <result property="userName" column="user_name" />
  10. <result property="nickName" column="nick_name" />
  11. <result property="pinyin" column="pinyin" />
  12. <result property="email" column="email" />
  13. <result property="phonenumber" column="phonenumber" />
  14. <result property="sex" column="sex" />
  15. <result property="avatar" column="avatar" />
  16. <result property="password" column="password" />
  17. <result property="status" column="status" />
  18. <result property="delFlag" column="del_flag" />
  19. <result property="loginIp" column="login_ip" />
  20. <result property="loginDate" column="login_date" />
  21. <result property="createBy" column="create_by" />
  22. <result property="createTime" column="create_time" />
  23. <result property="updateBy" column="update_by" />
  24. <result property="updateTime" column="update_time" />
  25. <result property="remark" column="remark" />
  26. <result property="pmLevel" column="pm_level" />
  27. <result property="titles" column="titles" />
  28. <result property="certificates" column="certificates" />
  29. <result property="updateReason" column="update_reason" />
  30. <result property="engineerLevel" column="engineer_level" />
  31. <result property="postLevel" column="post_level" />
  32. <result property="salaryLevel" column="salary_level" />
  33. <result property="operatorLevel" column="operator_level" />
  34. <result property="entryDate" column="entry_date" />
  35. <result property="birthday" column="birthday" />
  36. <result property="age" column="age" />
  37. <result property="idCard" column="id_card" />
  38. <result property="nativePlace" column="native_place" />
  39. <result property="politicalAffiliation" column="political_affiliation" />
  40. <result property="ethnic" column="ethnic" />
  41. <result property="graduateSchool" column="graduate_school" />
  42. <result property="major" column="major" />
  43. <result property="degree" column="degree" />
  44. <result property="contractSign" column="contract_sign" />
  45. <result property="contractExpire" column="contract_expire" />
  46. <result property="homePlace" column="home_place" />
  47. <association property="dept" javaType="SysDept" resultMap="deptResult" />
  48. <association property="salary" javaType="CmcPostSalary" resultMap="CmcPostSalaryResult" />
  49. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  50. </resultMap>
  51. <resultMap id="deptResult" type="SysDept">
  52. <id property="deptId" column="dept_id" />
  53. <result property="parentId" column="parent_id" />
  54. <result property="deptName" column="dept_name" />
  55. <result property="ancestors" column="ancestors" />
  56. <result property="orderNum" column="order_num" />
  57. <result property="leader" column="leader" />
  58. <result property="status" column="dept_status" />
  59. </resultMap>
  60. <resultMap id="RoleResult" type="SysRole">
  61. <id property="roleId" column="role_id" />
  62. <result property="roleName" column="role_name" />
  63. <result property="roleKey" column="role_key" />
  64. <result property="roleSort" column="role_sort" />
  65. <result property="dataScope" column="data_scope" />
  66. <result property="status" column="role_status" />
  67. </resultMap>
  68. <resultMap id="CmcPostSalaryResult" type="CmcPostSalary">
  69. <result property="salaryId" column="salary_id" />
  70. <result property="postLevel" column="post_level" />
  71. <result property="salaryLevel" column="salary_level" />
  72. <result property="salary" column="salary" />
  73. </resultMap>
  74. <sql id="selectUserVo">
  75. select u.user_id, u.dept_id, u.user_name, u.nick_name, u.pinyin, u.email, u.avatar, u.phonenumber, u.password,
  76. u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
  77. u.pm_level, u.titles, u.certificates, u.update_reason, u.engineer_level, u.post_level, u.salary_level,
  78. u.operator_level, u.entry_date, u.birthday, u.age, u.id_card, u.native_place, u.political_affiliation,
  79. u.ethnic, u.graduate_school, u.major, u.degree, u.contract_sign, u.contract_expire, u.home_place,
  80. d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
  81. r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status, ps.salary
  82. from sys_user u
  83. left join sys_dept d on u.dept_id = d.dept_id
  84. left join cmc_post_salary ps on u.post_level = ps.post_level and u.salary_level = ps.salary_level
  85. left join sys_user_role ur on u.user_id = ur.user_id
  86. left join sys_role r on r.role_id = ur.role_id
  87. </sql>
  88. <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
  89. select u.user_id, u.dept_id, u.nick_name, u.pinyin, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag,
  90. u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, u.pm_level, u.titles, u.certificates, u.update_reason,
  91. u.engineer_level, u.post_level, u.salary_level, u.operator_level, u.entry_date, u.birthday, u.age, u.id_card,
  92. u.native_place, u.political_affiliation, u.ethnic, u.graduate_school, u.major, u.degree, u.contract_sign, u.contract_expire,
  93. u.home_place, d.dept_name, d.leader, ps.salary from sys_user u
  94. left join sys_dept d on u.dept_id = d.dept_id
  95. left join cmc_post_salary ps on u.post_level = ps.post_level and u.salary_level = ps.salary_level
  96. where u.del_flag = '0' and u.user_id != 1
  97. <if test="userId != null and userId != 0">
  98. AND u.user_id = #{userId}
  99. </if>
  100. <if test="userName != null and userName != ''">
  101. AND u.user_name like concat('%', #{userName}, '%')
  102. </if>
  103. <if test="nickName != null and nickName != ''">
  104. AND u.nick_name like concat('%', #{nickName}, '%')
  105. </if>
  106. <if test="status != null and status != ''">
  107. AND u.status = #{status}
  108. </if>
  109. <if test="phonenumber != null and phonenumber != ''">
  110. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  111. </if>
  112. <if test="degree != null and degree != ''">
  113. AND u.degree = #{degree}
  114. </if>
  115. <if test="titles != null and titles != ''">
  116. AND find_in_set(#{titles}, u.titles)
  117. </if>
  118. <if test="certificates != null and certificates != ''">
  119. AND find_in_set(#{certificates}, u.certificates})
  120. </if>
  121. <if test="politicalAffiliation != null and politicalAffiliation != ''">
  122. AND find_in_set(#{politicalAffiliation}, u.political_affiliation})
  123. </if>
  124. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  125. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
  126. </if>
  127. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  128. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
  129. </if>
  130. <if test="deptId != null and deptId != 0">
  131. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  132. </if>
  133. <!-- 数据范围过滤 -->
  134. ${params.dataScope}
  135. order by u.dept_id, u.user_id
  136. </select>
  137. <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
  138. select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
  139. from sys_user u
  140. left join sys_dept d on u.dept_id = d.dept_id
  141. left join sys_user_role ur on u.user_id = ur.user_id
  142. left join sys_role r on r.role_id = ur.role_id
  143. where u.del_flag = '0' and r.role_id = #{roleId}
  144. <if test="userName != null and userName != ''">
  145. AND u.user_name like concat('%', #{userName}, '%')
  146. </if>
  147. <if test="phonenumber != null and phonenumber != ''">
  148. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  149. </if>
  150. <!-- 数据范围过滤 -->
  151. ${params.dataScope}
  152. </select>
  153. <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
  154. select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
  155. from sys_user u
  156. left join sys_dept d on u.dept_id = d.dept_id
  157. left join sys_user_role ur on u.user_id = ur.user_id
  158. left join sys_role r on r.role_id = ur.role_id
  159. where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
  160. and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
  161. <if test="userName != null and userName != ''">
  162. AND u.user_name like concat('%', #{userName}, '%')
  163. </if>
  164. <if test="phonenumber != null and phonenumber != ''">
  165. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  166. </if>
  167. <!-- 数据范围过滤 -->
  168. ${params.dataScope}
  169. </select>
  170. <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
  171. <include refid="selectUserVo"/>
  172. where u.user_name = #{userName} and u.del_flag = '0'
  173. </select>
  174. <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
  175. <include refid="selectUserVo"/>
  176. where u.user_id = #{userId}
  177. </select>
  178. <select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
  179. select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
  180. </select>
  181. <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
  182. select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
  183. </select>
  184. <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
  185. select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
  186. </select>
  187. <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
  188. insert into sys_user(
  189. <if test="userId != null and userId != 0">user_id,</if>
  190. <if test="deptId != null and deptId != 0">dept_id,</if>
  191. <if test="userName != null and userName != ''">user_name,</if>
  192. <if test="nickName != null and nickName != ''">nick_name,</if>
  193. <if test="email != null and email != ''">email,</if>
  194. <if test="avatar != null and avatar != ''">avatar,</if>
  195. <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
  196. <if test="sex != null and sex != ''">sex,</if>
  197. <if test="password != null and password != ''">password,</if>
  198. <if test="status != null and status != ''">status,</if>
  199. <if test="createBy != null and createBy != ''">create_by,</if>
  200. <if test="remark != null and remark != ''">remark,</if>
  201. <if test="pmLevel != null and pmLevel != ''">pm_level,</if>
  202. <if test="titles != null and titles != ''">titles,</if>
  203. <if test="certificates != null and certificates != ''">certificates,</if>
  204. <if test="updateReason != null and updateReason != ''">update_reason,</if>
  205. <if test="engineerLevel != null and engineerLevel != ''">engineer_level,</if>
  206. <if test="postLevel != null and postLevel != ''">post_level,</if>
  207. <if test="salaryLevel != null and salaryLevel != ''">salary_level,</if>
  208. <if test="operatorLevel != null and operatorLevel != ''">operator_level,</if>
  209. <if test="entryDate != null">entry_date,</if>
  210. <if test="birthday != null">birthday,</if>
  211. <if test="age != null and age != ''">age,</if>
  212. <if test="idCard != null">id_card,</if>
  213. <if test="nativePlace != null">native_place,</if>
  214. <if test="politicalAffiliation != null">political_affiliation,</if>
  215. <if test="ethnic != null">ethnic,</if>
  216. <if test="graduateSchool != null">graduate_school,</if>
  217. <if test="major != null">major,</if>
  218. <if test="degree != null">degree,</if>
  219. <if test="contractSign != null">contract_sign,</if>
  220. <if test="contractExpire != null">contract_expire,</if>
  221. <if test="homePlace != null">home_place,</if>
  222. <if test="pinyin != null">pinyin,</if>
  223. create_time
  224. )values(
  225. <if test="userId != null and userId != ''">#{userId},</if>
  226. <if test="deptId != null and deptId != ''">#{deptId},</if>
  227. <if test="userName != null and userName != ''">#{userName},</if>
  228. <if test="nickName != null and nickName != ''">#{nickName},</if>
  229. <if test="email != null and email != ''">#{email},</if>
  230. <if test="avatar != null and avatar != ''">#{avatar},</if>
  231. <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
  232. <if test="sex != null and sex != ''">#{sex},</if>
  233. <if test="password != null and password != ''">#{password},</if>
  234. <if test="status != null and status != ''">#{status},</if>
  235. <if test="createBy != null and createBy != ''">#{createBy},</if>
  236. <if test="remark != null and remark != ''">#{remark},</if>
  237. <if test="pmLevel != null and pmLevel != ''">#{pmLevel},</if>
  238. <if test="titles != null and titles != ''">#{titles},</if>
  239. <if test="certificates != null and certificates != ''">#{certificates},</if>
  240. <if test="updateReason != null and updateReason != ''">#{updateReason},</if>
  241. <if test="engineerLevel != null and engineerLevel != ''">#{engineerLevel},</if>
  242. <if test="postLevel != null and postLevel != ''">#{postLevel},</if>
  243. <if test="salaryLevel != null and salaryLevel != ''">#{salaryLevel},</if>
  244. <if test="operatorLevel != null and operatorLevel != ''">#{operatorLevel},</if>
  245. <if test="entryDate != null">#{entryDate},</if>
  246. <if test="birthday != null">#{birthday},</if>
  247. <if test="age != null and age != ''">#{age},</if>
  248. <if test="idCard != null">#{idCard},</if>
  249. <if test="nativePlace != null">#{nativePlace},</if>
  250. <if test="politicalAffiliation != null">#{politicalAffiliation},</if>
  251. <if test="ethnic != null">#{ethnic},</if>
  252. <if test="graduateSchool != null">#{graduateSchool},</if>
  253. <if test="major != null">#{major},</if>
  254. <if test="degree != null">#{degree},</if>
  255. <if test="contractSign != null">#{contractSign},</if>
  256. <if test="contractExpire != null">#{contractExpire},</if>
  257. <if test="homePlace != null">#{homePlace},</if>
  258. <if test="pinyin != null">#{pinyin},</if>
  259. sysdate()
  260. )
  261. </insert>
  262. <update id="updateUser" parameterType="SysUser">
  263. update sys_user
  264. <set>
  265. <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
  266. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  267. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  268. <if test="email != null ">email = #{email},</if>
  269. <if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
  270. <if test="sex != null and sex != ''">sex = #{sex},</if>
  271. <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
  272. <if test="password != null and password != ''">password = #{password},</if>
  273. <if test="status != null and status != ''">status = #{status},</if>
  274. <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
  275. <if test="loginDate != null">login_date = #{loginDate},</if>
  276. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  277. <if test="remark != null">remark = #{remark},</if>
  278. <if test="pmLevel != null">pm_level = #{pmLevel},</if>
  279. <if test="titles != null">titles = #{titles},</if>
  280. <if test="certificates != null">certificates = #{certificates},</if>
  281. <if test="updateReason != null">update_reason = #{updateReason},</if>
  282. <if test="engineerLevel != null">engineer_level = #{engineerLevel},</if>
  283. <if test="postLevel != null">post_level = #{postLevel},</if>
  284. <if test="salaryLevel != null">salary_level = #{salaryLevel},</if>
  285. <if test="operatorLevel != null">operator_level = #{operatorLevel},</if>
  286. <if test="entryDate != null">entry_date = #{entryDate},</if>
  287. <if test="birthday != null">birthday = #{birthday},</if>
  288. <if test="age != null">age = #{age},</if>
  289. <if test="idCard != null">id_card = #{idCard},</if>
  290. <if test="nativePlace != null">native_place = #{nativePlace},</if>
  291. <if test="politicalAffiliation != null">political_affiliation = #{politicalAffiliation},</if>
  292. <if test="ethnic != null">ethnic = #{ethnic},</if>
  293. <if test="graduateSchool != null">graduate_school = #{graduateSchool},</if>
  294. <if test="major != null">major = #{major},</if>
  295. <if test="degree != null">degree = #{degree},</if>
  296. contract_sign = #{contractSign},
  297. contract_expire = #{contractExpire},
  298. <if test="homePlace != null">home_place = #{homePlace},</if>
  299. <if test="pinyin != null">pinyin = #{pinyin},</if>
  300. update_time = sysdate()
  301. </set>
  302. where user_id = #{userId}
  303. </update>
  304. <update id="updateUserStatus" parameterType="SysUser">
  305. update sys_user set status = #{status} where user_id = #{userId}
  306. </update>
  307. <update id="updateUserAvatar" parameterType="SysUser">
  308. update sys_user set avatar = #{avatar} where user_name = #{userName}
  309. </update>
  310. <update id="resetUserPwd" parameterType="SysUser">
  311. update sys_user set password = #{password} where user_name = #{userName}
  312. </update>
  313. <delete id="deleteUserById" parameterType="Long">
  314. update sys_user set del_flag = '2' where user_id = #{userId}
  315. </delete>
  316. <delete id="deleteUserByIds" parameterType="Long">
  317. update sys_user set del_flag = '2' where user_id in
  318. <foreach collection="array" item="userId" open="(" separator="," close=")">
  319. #{userId}
  320. </foreach>
  321. </delete>
  322. </mapper>