SysUserMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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="selectByDept" resultType="com.platform.dao.vo.SysUserVO"
  36. parameterType="com.platform.dao.dto.upms.SysUserDTO">
  37. select u.* from t_sys_user u
  38. left join t_sys_user_dept ud on u.user_id = ud.user_id
  39. where 1=1
  40. <if test="deptIds != null and deptIds.size >0">
  41. AND ud.dept_id in
  42. <foreach item="item" index="index" collection="deptIds" open="(" close=")" separator=",">
  43. #{item}
  44. </foreach>
  45. </if>
  46. order by u.update_time desc
  47. </select>
  48. <select id="selectDeptRoleUser" resultType="com.platform.dao.vo.SysUserVO"
  49. parameterType="com.platform.dao.dto.upms.SysUserDTO">
  50. select distinct u.* from t_sys_user u, t_sys_user_dept ud, t_sys_user_role ur, t_sys_role r
  51. where u.user_id = ud.user_id and u.user_id = ur.user_id and ur.role_id = r.role_id
  52. <if test="deptIds != null and deptIds.size >0">
  53. AND ud.dept_id in
  54. <foreach item="item" index="index" collection="deptIds" open="(" close=")" separator=",">
  55. #{item}
  56. </foreach>
  57. </if>
  58. <if test="roleCode !=null and roleCode !=''">
  59. and r.role_code = #{roleCode}
  60. </if>
  61. <if test="roleCodes != null and roleCodes.size >0">
  62. AND r.role_code in
  63. <foreach item="item" index="index" collection="roleCodes" open="(" close=")" separator=",">
  64. #{item}
  65. </foreach>
  66. </if>
  67. order by u.update_time desc
  68. </select>
  69. <select id="selectUserNameById" resultType="java.lang.String" parameterType="java.lang.Object">
  70. select real_name
  71. from t_sys_user
  72. where user_id = #{value}
  73. </select>
  74. </mapper>