SysUserLinkFrontLineDeptMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.ydtech.modules.admin.dao.SysUserLinkFrontLineDeptMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.po.SysUserLinkFrontLineDept">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="userId" column="user_id" jdbcType="VARCHAR"/>
  9. <result property="frontLineDeptId" column="front_line_dept_id" jdbcType="VARCHAR"/>
  10. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  11. <result property="createUser" column="create_user" jdbcType="VARCHAR"/>
  12. <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
  13. <result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
  14. </resultMap>
  15. <sql id="Base_Column_List">
  16. id,user_id,front_line_dept_id,
  17. create_time,create_user,update_time,
  18. update_user
  19. </sql>
  20. <delete id="deleteByUserId">
  21. delete from sys_user_link_front_line_dept
  22. where user_id =#{userId}
  23. </delete>
  24. <select id="queryPage" resultType="com.ydtech.modules.admin.model.dto.SysUserLinkFrontLineDeptDto">
  25. SELECT
  26. link.id AS id,
  27. su.id AS userId,
  28. su.NAME AS userName,
  29. sd.id AS deptId,
  30. sd.NAME AS deptName,
  31. link.create_time AS createTime
  32. FROM
  33. sys_user_link_front_line_dept link
  34. LEFT JOIN sys_user su ON link.user_id = su.id
  35. LEFT JOIN sys_dept sd ON link.front_line_dept_id = sd.id
  36. <where>
  37. <if test="vo.userId != null and vo.userId != ''">
  38. and link.user_id = #{vo.userId}
  39. </if>
  40. <if test="vo.userName != null and vo.userName != ''">
  41. and su.name like CONCAT('%', #{vo.userName}, '%')
  42. </if>
  43. <if test="vo.orgId != null and vo.orgId != ''">
  44. and sd.id = #{vo.orgId}
  45. </if>
  46. </where>
  47. order by link.create_time desc
  48. </select>
  49. <select id="findDeptListByUserId" resultType="com.ydtech.modules.admin.model.SysDept">
  50. SELECT
  51. sd.id as id,
  52. sd.name as name,
  53. sd.parent_id as parentId,
  54. sd.comlevel as comlevel,
  55. CASE WHEN ( SELECT count( 0 ) FROM sys_user_link_front_line_dept link WHERE link.front_line_dept_id=sd.id and link.user_id = #{userId}) > 0 THEN
  56. true ELSE false
  57. END AS flag
  58. FROM
  59. sys_dept sd
  60. WHERE
  61. ( sd.comlevel = 3 )
  62. OR ( sd.comlevel = 4 )
  63. OR ( sd.comlevel > 4 AND id LIKE '%M%' )
  64. OR ( sd.comlevel > 4 AND id LIKE '%D%' )
  65. ORDER BY comlevel
  66. </select>
  67. <select id="findUserListByDeptPage" resultType="com.ydtech.modules.admin.model.vo.SysUserBaseVO">
  68. SELECT
  69. t1.id AS userId,
  70. t1.NAME AS NAME,
  71. t1.mobile AS mobile,
  72. t1.`status` AS `status`,
  73. t2.id AS deptId,
  74. t2.`name` AS deptName,
  75. sd2.id AS pDeptId,
  76. sd2.`name` AS pDeptName,
  77. CASE
  78. WHEN ( SELECT count( 0 ) FROM sys_user_link_front_line_dept link WHERE link.user_id = t1.id) > 0 THEN
  79. true ELSE false
  80. END AS flag
  81. FROM
  82. sys_user t1
  83. LEFT JOIN sys_dept t2 ON t1.dept_id = t2.id
  84. LEFT JOIN sys_dept sd2 ON sd2.id = t2.parent_id
  85. WHERE
  86. t1.`status` = 1
  87. AND t1.id NOT LIKE '%M%'
  88. <if test='user !=null '>
  89. <if test='user.name !=null and user.name!="" '>
  90. and t1.name like CONCAT('%', #{user.name}, '%')
  91. </if>
  92. <if test='user.userId !=null and user.userId!="" '>
  93. and t1.id = #{user.userId}
  94. </if>
  95. <if test='user.mobile !=null and user.mobile!="" '>
  96. and t1.mobile = #{user.mobile}
  97. </if>
  98. <if test='user.deptId !=null and user.deptId!="" '>
  99. and t2.id like CONCAT('', #{user.deptId}, '%')
  100. </if>
  101. </if>
  102. order by flag desc
  103. </select>
  104. </mapper>