jiangping
2023-12-29 f9691d544e62d6c04dbfe45d05a6c7bc5e004291
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.doumee.dao.system.SystemDepartmentMapper">
 
  <!-- 查询部门列表 -->
  <resultMap id="SystemDepartmentListVO" type="com.doumee.dao.system.vo.SystemDepartmentListVO" autoMapping="true">
    <id column="id" property="id"/>
    <association property="createUserInfo" javaType="com.doumee.dao.system.model.SystemUser">
      <result column="create_user_id" property="id"/>
      <result column="create_user_name" property="username"/>
    </association>
    <association property="updateUserInfo" javaType="com.doumee.dao.system.model.SystemUser">
      <result column="update_user_id" property="id"/>
      <result column="update_user_name" property="username"/>
    </association>
  </resultMap>
  <select id="selectManageList" parameterType="com.doumee.dao.system.dto.QuerySystemDepartmentDTO" resultMap="SystemDepartmentListVO">
    select
      dept.id, dept.parent_id, dept.code, dept.name, dept.phone, dept.email, dept.create_time, dept.update_time, dept.create_user, dept.update_user, dept.deleted,
      create_user.id create_user_id, create_user.username create_user_name,
      update_user.id updete_user_id, update_user.username update_user_name,
    (select count(1) from system_department_user sdu where sdu.department_id = dept.id and sdu.deleted = 0  ) user_count
    from system_department dept
    left join "system_user" create_user on create_user.id = dept.create_user
    left join "system_user" update_user on update_user.id = dept.update_user
    <where>
      dept.deleted = 0
      <if test="id != null">
        and dept.id = #{id}
      </if>
      <if test="ids != null">
        AND dept.id IN
        <foreach collection="ids" item="id" separator="," open="(" close=")">
          #{id}
        </foreach>
      </if>
    </where>
  </select>
 
</mapper>