fix 修复 个人中心数据被脱敏问题

This commit is contained in:
疯狂的狮子Li
2025-07-25 16:37:55 +08:00
parent 1bc23099aa
commit 35937624b2
2 changed files with 96 additions and 3 deletions

View File

@@ -1,8 +1,8 @@
package org.dromara.system.controller.system;
import cn.hutool.crypto.digest.BCrypt;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.crypto.digest.BCrypt;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.seata.spring.annotation.GlobalTransactional;
@@ -21,6 +21,7 @@ import org.dromara.resource.api.domain.RemoteFile;
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.SysUserVo;
import org.dromara.system.service.ISysUserService;
import org.springframework.http.MediaType;
@@ -55,7 +56,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);
}
@@ -134,6 +137,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;
}