Compare commits

...

2 Commits

Author SHA1 Message Date
疯狂的狮子Li
48213bc9c9 fix 修复 个人中心数据被脱敏问题 2025-07-25 16:36:24 +08:00
疯狂的狮子Li
3995d9699d fix 修复 权限为null导致报错问题 2025-07-25 15:47:16 +08:00
3 changed files with 108 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package org.dromara.common.satoken.core.service;
import cn.dev33.satoken.stp.StpInterface;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import org.dromara.common.core.domain.model.LoginUser;
import org.dromara.common.core.enums.UserType;
@ -39,8 +40,12 @@ public class SaPermissionImpl implements StpInterface {
if (userType == UserType.APP_USER) {
// 其他端 自行根据业务编写
}
// SYS_USER 默认返回权限
return new ArrayList<>(loginUser.getMenuPermission());
if (CollUtil.isNotEmpty(loginUser.getMenuPermission())) {
// SYS_USER 默认返回权限
return new ArrayList<>(loginUser.getMenuPermission());
} else {
return new ArrayList<>();
}
}
/**
@ -62,8 +67,12 @@ public class SaPermissionImpl implements StpInterface {
if (userType == UserType.APP_USER) {
// 其他端 自行根据业务编写
}
// SYS_USER 默认返回权限
return new ArrayList<>(loginUser.getRolePermission());
if (CollUtil.isNotEmpty(loginUser.getRolePermission())) {
// SYS_USER 默认返回权限
return new ArrayList<>(loginUser.getMenuPermission());
} else {
return new ArrayList<>();
}
}
private PermissionService getPermissionService() {

View File

@ -17,6 +17,7 @@ import org.dromara.common.web.core.BaseController;
import org.dromara.system.domain.bo.SysUserBo;
import org.dromara.system.domain.bo.SysUserPasswordBo;
import org.dromara.system.domain.bo.SysUserProfileBo;
import org.dromara.system.domain.vo.ProfileUserVo;
import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.service.ISysOssService;
@ -50,7 +51,9 @@ public class SysProfileController extends BaseController {
SysUserVo user = userService.selectUserById(LoginHelper.getUserId());
String roleGroup = userService.selectUserRoleGroup(user.getUserId());
String postGroup = userService.selectUserPostGroup(user.getUserId());
ProfileVo profileVo = new ProfileVo(user, roleGroup, postGroup);
// 单独做一个vo专门给个人中心用 避免数据被脱敏
ProfileUserVo profileUser = BeanUtil.toBean(user, ProfileUserVo.class);
ProfileVo profileVo = new ProfileVo(profileUser, roleGroup, postGroup);
return R.ok(profileVo);
}
@ -128,6 +131,6 @@ public class SysProfileController extends BaseController {
public record AvatarVo(String imgUrl) {}
public record ProfileVo(SysUserVo user, String roleGroup, String postGroup) {}
public record ProfileVo(ProfileUserVo user, String roleGroup, String postGroup) {}
}

View File

@ -0,0 +1,90 @@
package org.dromara.system.domain.vo;
import lombok.Data;
import org.dromara.common.translation.annotation.Translation;
import org.dromara.common.translation.constant.TransConstant;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 用户信息视图对象 sys_user
*
* @author Lion Li
*/
@Data
public class ProfileUserVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private Long userId;
/**
* 租户ID
*/
private String tenantId;
/**
* 部门ID
*/
private Long deptId;
/**
* 用户账号
*/
private String userName;
/**
* 用户昵称
*/
private String nickName;
/**
* 用户类型sys_user系统用户
*/
private String userType;
/**
* 用户邮箱
*/
private String email;
/**
* 手机号码
*/
private String phonenumber;
/**
* 用户性别0男 1女 2未知
*/
private String sex;
/**
* 头像地址
*/
@Translation(type = TransConstant.OSS_ID_TO_URL)
private Long avatar;
/**
* 最后登录IP
*/
private String loginIp;
/**
* 最后登录时间
*/
private Date loginDate;
/**
* 部门名
*/
@Translation(type = TransConstant.DEPT_ID_TO_NAME, mapper = "deptId")
private String deptName;
}