|
@@ -21,35 +21,37 @@
|
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
|
<result property="remark" column="remark"/>
|
|
<result property="remark" column="remark"/>
|
|
|
|
|
+ <result property="userCount" column="user_count"/>
|
|
|
</resultMap>
|
|
</resultMap>
|
|
|
|
|
|
|
|
<sql id="selectDeptVo">
|
|
<sql id="selectDeptVo">
|
|
|
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone,
|
|
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, d.remark
|
|
|
|
|
|
|
+ d.email, d.status, d.del_flag, d.create_by, d.create_time, d.remark, t.user_count
|
|
|
from sys_dept d
|
|
from sys_dept d
|
|
|
|
|
+ left join (select dept_id, count(*) as user_count from sys_user where del_flag = '0' group by dept_id) t on t.dept_id = d.dept_id
|
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
|
|
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
|
|
|
<include refid="selectDeptVo"/>
|
|
<include refid="selectDeptVo"/>
|
|
|
where d.del_flag = '0'
|
|
where d.del_flag = '0'
|
|
|
<if test="deptId != null and deptId != 0">
|
|
<if test="deptId != null and deptId != 0">
|
|
|
- AND dept_id = #{deptId}
|
|
|
|
|
|
|
+ AND d.dept_id = #{deptId}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="parentId != null and parentId != 0">
|
|
<if test="parentId != null and parentId != 0">
|
|
|
- AND parent_id = #{parentId}
|
|
|
|
|
|
|
+ AND d.parent_id = #{parentId}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="deptName != null and deptName != ''">
|
|
<if test="deptName != null and deptName != ''">
|
|
|
- AND dept_name like concat('%', #{deptName}, '%')
|
|
|
|
|
|
|
+ AND d.dept_name like concat('%', #{deptName}, '%')
|
|
|
</if>
|
|
</if>
|
|
|
<if test="status != null and status != ''">
|
|
<if test="status != null and status != ''">
|
|
|
- AND status = #{status}
|
|
|
|
|
|
|
+ AND d.status = #{status}
|
|
|
</if>
|
|
</if>
|
|
|
<!-- 数据范围过滤 -->
|
|
<!-- 数据范围过滤 -->
|
|
|
${params.dataScope}
|
|
${params.dataScope}
|
|
|
order by d.parent_id, d.order_num
|
|
order by d.parent_id, d.order_num
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
- <select id="selectDeptListByRoleId" resultType="Integer">
|
|
|
|
|
|
|
+ <select id="selectDeptListByRoleId" resultType="Long">
|
|
|
select d.dept_id
|
|
select d.dept_id
|
|
|
from sys_dept d
|
|
from sys_dept d
|
|
|
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
|
left join sys_role_dept rd on d.dept_id = rd.dept_id
|