DepartmentDao.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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="platform.modules.sys.dao.DepartmentDao">
  6. <!--返回树列表-->
  7. <select id="findTreeList" resultType="platform.modules.sys.vo.TreeNode">
  8. SELECT id,parent_id,name FROM sys_department p where user_type =#{user_type}
  9. <if test="build_id!=null and build_id!=''">
  10. and build_id=#{build_id}
  11. </if>
  12. <if test="street_id!=null and street_id!=''">
  13. and street_id=#{street_id}
  14. </if>
  15. <if test="company_id!=null and company_id!=''">
  16. and company_id=#{company_id}
  17. </if>
  18. order by p.create_time asc
  19. </select>
  20. <select id="findByDepartmentName" resultType="platform.modules.sys.entity.Department">
  21. select * from sys_department where name=#{name}
  22. <if test="id!=null and id!=''">
  23. and id!=#{id}
  24. </if>
  25. <if test="condition.user_type !=null and condition.user_type !=''">
  26. and user_type = #{condition.user_type}
  27. </if>
  28. <if test="condition.build_id!=null and condition.build_id!=''">
  29. and build_id=#{condition.build_id}
  30. </if>
  31. <if test="condition.street_id!=null and condition.street_id!=''">
  32. and street_id=#{condition.street_id}
  33. </if>
  34. <if test="condition.company_id!=null and condition.company_id!=''">
  35. and company_id=#{condition.company_id}
  36. </if>
  37. </select>
  38. <select id="findByDepartmentId" resultType="platform.modules.sys.entity.Department">
  39. select * from sys_department where parent_id=#{department_id} and del_flag=0
  40. </select>
  41. <select id="findDepartmentIdByName" resultType="int">
  42. SELECT id from sys_department where name in
  43. <foreach collection="departments" index="index" item="item" open="(" separator="," close=")">
  44. #{item}
  45. </foreach>
  46. </select>
  47. <select id="findDepartmentByGoupId" resultType="platform.modules.sys.entity.Department">
  48. SELECT * FROM sys_department where id IN
  49. (SELECT department_id from sys_department_group where group_id=#{id})
  50. </select>
  51. <select id="findDepartmentByGroupNamePageInfo" resultType="platform.modules.sys.entity.Department">
  52. SELECT * FROM sys_department where id IN
  53. (SELECT department_id from sys_department_group where group_id =
  54. (SELECT id from sys_de_group where name = #{groupName})
  55. )
  56. <if test="keyWords != null and keyWords != ''" >
  57. and name LIKE CONCAT ('%',#{keyWords},'%')
  58. </if>
  59. <if test="null != departmenstIds and departmenstIds.size >0">
  60. AND id not IN
  61. <foreach collection="departmenstIds" index="index" item="item" open="(" separator="," close=")">
  62. #{item}
  63. </foreach>
  64. </if>
  65. </select>
  66. <select id="departmentList" resultType="platform.modules.sys.entity.Department">
  67. SELECT * FROM sys_department dep WHERE dep.del_flag = 0
  68. </select>
  69. <select id="selectMaxId" resultType="Integer">
  70. select MAX(id) FROM sys_department dept WHERE dept.del_flag = 0
  71. </select>
  72. <select id="getAllUserDepts" resultType="platform.modules.sys.entity.Department">
  73. SELECT
  74. distinct dep.id,
  75. dep.name
  76. FROM
  77. sys_department dep
  78. LEFT JOIN z_user u on u.department_id = dep.id
  79. WHERE
  80. dep.del_flag = 0
  81. and u.id in
  82. <foreach collection="userIdArr" index="index" item="item" open="(" separator="," close=")">
  83. #{item}
  84. </foreach>
  85. </select>
  86. <select id="findDepartmentList" resultType="platform.modules.api.dto.DepartmentDto">
  87. select id, `name` AS departmentName, parent_id AS partentId from sys_department WHERE del_flag = FALSE
  88. </select>
  89. </mapper>