SysUserLinkDeptInternalAgentMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.SysUserLinkDeptInternalAgentMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.po.SysUserLinkDeptInternalAgent">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="userId" column="user_id" jdbcType="VARCHAR"/>
  9. <result property="sysDeptInternalAgentId" column="sys_dept_internal_agent_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,sys_dept_internal_agent_id,
  17. create_time,create_user,update_time,
  18. update_user
  19. </sql>
  20. <delete id="deleteByDeptId">
  21. delete from sys_user_link_dept_internal_agent
  22. where sys_dept_internal_agent_id =#{deptId}
  23. </delete>
  24. <select id="queryPage" resultType="com.ydtech.modules.admin.model.dto.SysUserLinkDeptInternalAgentDto">
  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_dept_internal_agent link
  34. LEFT JOIN sys_user su ON link.user_id = su.id
  35. LEFT JOIN sys_dept_internal_agent sd ON link.sys_dept_internal_agent_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.deptId != null and vo.deptId != ''">
  44. and sd.id = #{vo.deptId}
  45. </if>
  46. </where>
  47. order by link.create_time desc
  48. </select>
  49. <select id="findUserListByDeptPage" resultType="com.ydtech.modules.admin.model.vo.SysUserBaseVO">
  50. SELECT
  51. t1.id AS userId,
  52. t1.NAME AS NAME,
  53. t1.mobile AS mobile,
  54. t1.`status` AS `status`,
  55. t2.id AS deptId,
  56. t2.`name` AS deptName,
  57. sd2.id AS pDeptId,
  58. sd2.`name` AS pDeptName,
  59. CASE
  60. WHEN ( SELECT count( 0 ) FROM sys_user_link_dept_internal_agent link WHERE link.user_id = t1.id and link.sys_dept_internal_agent_id = #{user.deptNBId}) > 0 THEN
  61. true ELSE false
  62. END AS flag
  63. FROM
  64. sys_user t1
  65. LEFT JOIN sys_dept t2 ON t1.dept_id = t2.id
  66. LEFT JOIN sys_dept sd2 ON sd2.id = t2.parent_id
  67. WHERE
  68. t1.`status` = 1
  69. AND t1.id NOT LIKE '%M%'
  70. <if test='user !=null '>
  71. <if test='user.name !=null and user.name!="" '>
  72. and t1.name like CONCAT('%', #{user.name}, '%')
  73. </if>
  74. <if test='user.userId !=null and user.userId!="" '>
  75. and t1.id = #{user.userId}
  76. </if>
  77. <if test='user.mobile !=null and user.mobile!="" '>
  78. and t1.mobile = #{user.mobile}
  79. </if>
  80. <if test='user.deptId !=null and user.deptId!="" '>
  81. and t2.id like CONCAT('', #{user.deptId}, '%')
  82. </if>
  83. </if>
  84. order by flag desc
  85. </select>
  86. <select id="getUserIdListByDeptPrentIds" resultType="java.lang.String">
  87. SELECT
  88. link.user_id
  89. FROM
  90. sys_user_link_dept_internal_agent link
  91. LEFT JOIN sys_dept_internal_agent sd ON link.sys_dept_internal_agent_id = sd.id
  92. <where>
  93. <if test="parentIds != null and parentIds != ''">
  94. AND sd.parent_ids like concat(#{parentIds},'%')
  95. </if>
  96. </where>
  97. </select>
  98. </mapper>