serv\web- 多租户修改
This commit is contained in:
@@ -39,11 +39,29 @@
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectDeptRoleList">
|
||||
<!-- 部门角色VO结果映射 -->
|
||||
<resultMap id="DeptRoleVOResultMap" type="org.xyzh.common.vo.UserDeptRoleVO">
|
||||
<result column="dept_id" property="deptID" jdbcType="VARCHAR"/>
|
||||
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
|
||||
<result column="dept_description" property="deptDescription" jdbcType="VARCHAR"/>
|
||||
<result column="role_id" property="roleID" jdbcType="VARCHAR"/>
|
||||
<result column="role_name" property="roleName" jdbcType="VARCHAR"/>
|
||||
<result column="role_description" property="roleDescription" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectDeptRoleList" resultMap="DeptRoleVOResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_dept_role
|
||||
ORDER BY dept_id, role_id, create_time DESC
|
||||
dr.dept_id,
|
||||
d.name AS dept_name,
|
||||
d.description AS dept_description,
|
||||
dr.role_id,
|
||||
r.name AS role_name,
|
||||
r.description AS role_description
|
||||
FROM tb_sys_dept_role dr
|
||||
LEFT JOIN tb_sys_dept d ON dr.dept_id = d.dept_id AND d.deleted = 0
|
||||
LEFT JOIN tb_sys_role r ON dr.role_id = r.role_id AND r.deleted = 0
|
||||
WHERE dr.deleted = 0
|
||||
ORDER BY dr.dept_id, dr.role_id, dr.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- batchBindDeptRole -->
|
||||
@@ -65,4 +83,81 @@
|
||||
(#{deptRole.deptID}, #{deptRole.roleID})
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- selectParentDeptAdmin -->
|
||||
|
||||
<select id="selectParentDeptAdmin">
|
||||
WITH RECURSIVE dept_hierarchy AS (
|
||||
-- 基础查询:查询起始部门
|
||||
SELECT
|
||||
dept_id,
|
||||
parent_id,
|
||||
name,
|
||||
description,
|
||||
1 AS level
|
||||
FROM tb_sys_dept
|
||||
WHERE dept_id = #{deptID}
|
||||
AND deleted = 0
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- 递归查询:查询父级部门
|
||||
SELECT
|
||||
d.dept_id,
|
||||
d.parent_id,
|
||||
d.name,
|
||||
d.description,
|
||||
dh.level + 1 AS level
|
||||
FROM tb_sys_dept d
|
||||
INNER JOIN dept_hierarchy dh ON d.dept_id = dh.parent_id
|
||||
WHERE d.deleted = 0
|
||||
AND d.parent_id IS NOT NULL
|
||||
)
|
||||
SELECT
|
||||
dh.dept_id AS deptID,
|
||||
tsdr.role_id
|
||||
FROM dept_hierarchy dh
|
||||
INNER JOIN tb_sys_dept_role tsdr ON dh.dept_id = tsdr.dept_id
|
||||
WHERE tsdr.role_id = 'admin'
|
||||
AND tsdr.deleted = 0
|
||||
ORDER BY level DESC
|
||||
</select>
|
||||
|
||||
<!-- selectChildDeptRole -->
|
||||
|
||||
<select id="selectChildDeptRole">
|
||||
WITH RECURSIVE dept_hierarchy AS (
|
||||
-- 基础查询:查询起始部门
|
||||
SELECT
|
||||
dept_id,
|
||||
parent_id,
|
||||
name,
|
||||
description,
|
||||
1 AS level
|
||||
FROM tb_sys_dept
|
||||
WHERE dept_id = #{deptID}
|
||||
AND deleted = 0
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- 递归查询:查询子级部门
|
||||
SELECT
|
||||
d.dept_id,
|
||||
d.parent_id,
|
||||
d.name,
|
||||
d.description,
|
||||
dh.level + 1 AS level
|
||||
FROM tb_sys_dept d
|
||||
INNER JOIN dept_hierarchy dh ON d.parent_id = dh.dept_id
|
||||
WHERE d.deleted = 0
|
||||
AND d.parent_id IS NOT NULL
|
||||
)
|
||||
SELECT
|
||||
dh.dept_id AS deptID,
|
||||
tsdr.role_id
|
||||
FROM dept_hierarchy dh
|
||||
INNER JOIN tb_sys_dept_role tsdr ON dh.dept_id = tsdr.dept_id
|
||||
AND tsdr.deleted = 0
|
||||
ORDER BY level DESC
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user