serv-资源修改
This commit is contained in:
@@ -125,6 +125,15 @@ public interface UserMapper extends BaseMapper<TbSysUser> {
|
||||
*/
|
||||
int updateUserInfo(@Param("userInfo") TbSysUserInfo userInfo);
|
||||
|
||||
/**
|
||||
* @description 获取用户完整部门路径
|
||||
* @param userId 用户ID
|
||||
* @return String 部门路径(如:公司总部/技术部/前端组)
|
||||
* @author yslg
|
||||
* @since 2025-10-18
|
||||
*/
|
||||
String getUserDeptPath(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 获取用户信息总览
|
||||
* @param userId 用户ID
|
||||
|
||||
@@ -719,8 +719,9 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
ResultDomain<UserVO> resultDomain = new ResultDomain<>();
|
||||
try {
|
||||
logger.info("开始获取用户信息总览:{}", userId);
|
||||
String deptPath = userMapper.getUserDeptPath(userId);
|
||||
UserVO userVO = userMapper.selectUserInfoTotal(userId);
|
||||
|
||||
userVO.setDeptName(deptPath);
|
||||
resultDomain.success("获取用户信息总览成功", userVO);
|
||||
return resultDomain;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
FROM tb_sys_module
|
||||
<include refid="Base_Where_Clause" />
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计模块数量 -->
|
||||
|
||||
@@ -245,9 +245,69 @@
|
||||
WHERE user_id = #{userInfo.userID} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- selectUserInfoTotal -->
|
||||
<!-- 获取用户完整部门路径 -->
|
||||
<select id="getUserDeptPath" resultType="java.lang.String">
|
||||
WITH RECURSIVE dept_hierarchy AS (
|
||||
-- 基础查询:获取用户直接所属的部门
|
||||
SELECT
|
||||
tsd.dept_id,
|
||||
tsd.name,
|
||||
tsd.parent_id,
|
||||
tsd.name as dept_path,
|
||||
1 as level
|
||||
FROM tb_sys_user_info tsui
|
||||
INNER JOIN tb_sys_user_dept_role tsudr ON tsui.user_id = tsudr.user_id
|
||||
INNER JOIN tb_sys_dept tsd ON tsudr.dept_id = tsd.dept_id
|
||||
WHERE tsui.user_id = #{userId} AND tsui.deleted = 0
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- 递归查询:向上查找父部门
|
||||
SELECT
|
||||
p.dept_id,
|
||||
p.name,
|
||||
p.parent_id,
|
||||
CONCAT(p.name, '/', dh.dept_path) as dept_path,
|
||||
dh.level + 1 as level
|
||||
FROM tb_sys_dept p
|
||||
INNER JOIN dept_hierarchy dh ON p.dept_id = dh.parent_id
|
||||
WHERE p.deleted = 0
|
||||
)
|
||||
SELECT dh.dept_path
|
||||
FROM dept_hierarchy dh
|
||||
WHERE dh.parent_id IS NULL -- 只取最顶层的部门路径
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectUserInfoTotal" resultMap="UserInfoTotalResultMap">
|
||||
<!-- selectUserInfoTotal -->
|
||||
|
||||
<select id="selectUserInfoTotal" resultMap="UserInfoTotalResultMap">
|
||||
WITH RECURSIVE dept_hierarchy AS (
|
||||
-- 基础查询:获取用户直接所属的部门
|
||||
SELECT
|
||||
tsd.dept_id,
|
||||
tsd.name,
|
||||
tsd.parent_id,
|
||||
tsd.name as dept_path,
|
||||
1 as level
|
||||
FROM tb_sys_user_info tsui
|
||||
INNER JOIN tb_sys_user_dept_role tsudr ON tsui.user_id = tsudr.user_id
|
||||
INNER JOIN tb_sys_dept tsd ON tsudr.dept_id = tsd.dept_id
|
||||
WHERE tsui.user_id = #{userId} AND tsui.deleted = 0
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- 递归查询:向上查找父部门
|
||||
SELECT
|
||||
p.dept_id,
|
||||
p.name,
|
||||
p.parent_id,
|
||||
CONCAT(p.name, '/', dh.dept_path) as dept_path,
|
||||
dh.level + 1 as level
|
||||
FROM tb_sys_dept p
|
||||
INNER JOIN dept_hierarchy dh ON p.dept_id = dh.parent_id
|
||||
WHERE p.deleted = 0
|
||||
)
|
||||
SELECT
|
||||
tus.id as user_id,
|
||||
tus.username,
|
||||
@@ -255,7 +315,7 @@
|
||||
tus.email,
|
||||
tsui.avatar,
|
||||
tsui.gender,
|
||||
tsd.name as dept_name,
|
||||
dh.dept_path as dept_name,
|
||||
tsr.name as role_name,
|
||||
tsui.level,
|
||||
tsui.id_card,
|
||||
@@ -263,8 +323,10 @@
|
||||
FROM tb_sys_user_info tsui
|
||||
INNER JOIN tb_sys_user tus ON tsui.user_id = tus.id
|
||||
INNER JOIN tb_sys_user_dept_role tsudr ON tsui.user_id = tsudr.user_id
|
||||
INNER JOIN tb_sys_dept tsd ON tsudr.dept_id = tsd.dept_id
|
||||
INNER JOIN dept_hierarchy dh ON tsudr.dept_id = dh.dept_id
|
||||
INNER JOIN tb_sys_role tsr ON tsudr.role_id = tsr.role_id
|
||||
WHERE tsui.user_id = #{userId} AND tsui.deleted = 0
|
||||
WHERE tsui.user_id = #{userId}
|
||||
AND tsui.deleted = 0
|
||||
AND dh.parent_id IS NULL -- 只取最顶层的部门路径
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user