5 天以前 92d8d06d8ae38c407715a5e9389691b446413e0a
src/main/resources/mapper/system/SysDeptMapper.xml
@@ -20,32 +20,37 @@
      <result property="createTime" column="create_time" />
      <result property="updateBy"   column="update_by"   />
      <result property="updateTime" column="update_time" />
      <result property="staffCount" column="staff_count" />
   </resultMap>
   
   <sql id="selectDeptVo">
        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 
        from sys_dept d
    </sql>
   <select id="selectDeptList" parameterType="com.ruoyi.project.system.domain.SysDept" resultMap="SysDeptResult">
        <include refid="selectDeptVo"/>
        where d.del_flag = '0'
      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,
      count(distinct soj.id) as staff_count
      from sys_dept d
      left join staff_on_job soj on soj.sys_dept_id = d.dept_id and soj.staff_state = '1'
      where d.del_flag = '0'
      <if test="deptId != null and deptId != 0">
         AND dept_id = #{deptId}
         AND d.dept_id = #{deptId}
      </if>
        <if test="parentId != null and parentId != 0">
         AND parent_id = #{parentId}
      <if test="parentId != null and parentId != 0">
         AND d.parent_id = #{parentId}
      </if>
      <if test="deptName != null and deptName != ''">
         AND dept_name like concat('%', #{deptName}, '%')
         AND d.dept_name like concat('%', #{deptName}, '%')
      </if>
      <if test="status != null and status != ''">
         AND status = #{status}
         AND d.status = #{status}
      </if>
      <!-- 数据范围过滤 -->
      ${params.dataScope}
      group by 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
      order by d.parent_id, d.order_num
    </select>
   </select>
    
    <select id="selectDeptListByRoleId" resultType="Long">
      select d.dept_id
@@ -178,5 +183,19 @@
      FROM DepartmentHierarchy
      WHERE parent_id = 100;
   </select>
    <select id="selectAllDept" resultType="com.ruoyi.production.dto.SysDeptAndUserDto">
      SELECT dept_id, parent_id, ancestors, dept_name, order_num, leader, phone, email,
            status, del_flag, create_by, create_time, update_by, update_time, dept_nick
      FROM sys_dept
      WHERE del_flag = '0' AND status = '0'
      ORDER BY order_num ASC
   </select>
   <select id="selectChildrenDeptByParentId" resultType="com.ruoyi.production.dto.SysDeptAndUserDto">
      SELECT dept_id, parent_id, ancestors, dept_name, order_num, leader, phone, email,
            status, del_flag, create_by, create_time, update_by, update_time, dept_nick
      FROM sys_dept
      WHERE parent_id = #{parentId} AND del_flag = '0' AND status = '0'
      ORDER BY order_num ASC
   </select>
</mapper>