SysDeptMapper.xml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.SysDeptMapper">
  6. <resultMap type="SysDept" id="SysDeptResult">
  7. <id property="deptId" column="dept_id"/>
  8. <result property="parentId" column="parent_id"/>
  9. <result property="ancestors" column="ancestors"/>
  10. <result property="deptName" column="dept_name"/>
  11. <result property="orderNum" column="order_num"/>
  12. <result property="leader" column="leader"/>
  13. <result property="phone" column="phone"/>
  14. <result property="email" column="email"/>
  15. <result property="status" column="status"/>
  16. <result property="delFlag" column="del_flag"/>
  17. <result property="parentName" column="parent_name"/>
  18. <result property="createBy" column="create_by"/>
  19. <result property="createTime" column="create_time"/>
  20. <result property="updateBy" column="update_by"/>
  21. <result property="updateTime" column="update_time"/>
  22. </resultMap>
  23. <sql id="selectDeptVo">
  24. select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
  25. from sys_dept d
  26. </sql>
  27. <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
  28. <include refid="selectDeptVo"/>
  29. where d.del_flag = '0'
  30. <if test="parentId != null and parentId != 0">
  31. AND parent_id = #{parentId}
  32. </if>
  33. <if test="deptName != null and deptName != ''">
  34. AND dept_name like concat('%', #{deptName}, '%')
  35. </if>
  36. <if test="status != null and status != ''">
  37. AND status = #{status}
  38. </if>
  39. <!-- 数据范围过滤 -->
  40. <if test="params.dataScope != null and params.dataScope != ''">
  41. AND ( ${params.dataScope} )
  42. </if>
  43. order by d.parent_id, d.order_num
  44. </select>
  45. <select id="selectDeptListByRoleId" resultType="Integer">
  46. select d.dept_id
  47. from sys_dept d
  48. left join sys_role_dept rd on d.dept_id = rd.dept_id
  49. where rd.role_id = #{roleId}
  50. <if test="deptCheckStrictly">
  51. and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
  52. </if>
  53. order by d.parent_id, d.order_num
  54. </select>
  55. </mapper>