refactor(auth): 优化用户认证信息获取逻辑

This commit is contained in:
2026-01-07 16:26:33 +08:00
parent b2cae22719
commit 54cae0855b
2 changed files with 8 additions and 5 deletions
@@ -22,6 +22,7 @@ import cn.odboy.system.dal.dataobject.SystemUserTb;
import cn.odboy.system.dal.model.SystemQueryUserArgs;
import cn.odboy.system.dal.model.SystemUpdateUserPasswordArgs;
import cn.odboy.system.dal.model.SystemUserInfoVo;
import cn.odboy.system.dal.model.SystemUserJwtVo;
import cn.odboy.system.dal.model.SystemUserVo;
import cn.odboy.system.framework.operalog.OperationLog;
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
@@ -151,8 +152,8 @@ public class SystemUserController {
@ApiOperation("获取用户信息")
@PostMapping(value = "/getCurrentUserInfo")
public ResponseEntity<SystemUserInfoVo> getUserInfo() {
SystemUserInfoVo userInfoVo = systemAuthService.getCurrentUserInfoVo();
public ResponseEntity<SystemUserJwtVo> getUserInfo() {
SystemUserJwtVo userInfoVo = systemAuthService.getCurrentUserInfo();
return ResponseEntity.ok(userInfoVo);
}
}
@@ -83,10 +83,12 @@ public class SystemAuthService {
return authInfo;
}
public SystemUserInfoVo getCurrentUserInfoVo() {
public SystemUserJwtVo getCurrentUserInfo() {
SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser();
// 转换是为了去掉密码
return KitBeanUtil.copyToClass(jwtUser, SystemUserInfoVo.class);
if (jwtUser.getUser() != null) {
jwtUser.getUser().setPassword(null);
}
return jwtUser;
}
public Map<String, Object> getCaptchaInfo() {