From 7e6efa4d50c54f3a9dcfa140a8f05cda08a870be Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Tue, 18 Mar 2025 16:36:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0https?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/user/UserController.java | 7 ++- .../model/vo/user/UserMainInfoVO.java | 51 +++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/cultural/heritage/model/vo/user/UserMainInfoVO.java diff --git a/src/main/java/com/cultural/heritage/controller/user/UserController.java b/src/main/java/com/cultural/heritage/controller/user/UserController.java index d5a0e37..7dced8b 100644 --- a/src/main/java/com/cultural/heritage/controller/user/UserController.java +++ b/src/main/java/com/cultural/heritage/controller/user/UserController.java @@ -16,6 +16,7 @@ import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.user.*; import com.cultural.heritage.model.entity.User; +import com.cultural.heritage.model.vo.user.UserMainInfoVO; import com.cultural.heritage.model.vo.user.UserVO; import com.cultural.heritage.service.user.UserService; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; @@ -200,13 +201,15 @@ public class UserController { @PostMapping("/query/id") @Operation(summary = "Web端管理员根据id查询用户信息", description = "参数:用户id, 权限:管理员(boss, admin), 方法名:getUserById") @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) - public BaseResponse getUserById(@RequestBody CommonRequest commonRequest) { + public BaseResponse getUserById(@RequestBody CommonRequest commonRequest) { if (commonRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); } Long id = commonRequest.getId(); User user = userService.getById(id); - return ResultUtils.success(userService.getUserVO(user)); + UserMainInfoVO userMainInfoVO = new UserMainInfoVO(); + BeanUtils.copyProperties(user, userMainInfoVO); + return ResultUtils.success(userMainInfoVO); } diff --git a/src/main/java/com/cultural/heritage/model/vo/user/UserMainInfoVO.java b/src/main/java/com/cultural/heritage/model/vo/user/UserMainInfoVO.java new file mode 100644 index 0000000..d02e0ab --- /dev/null +++ b/src/main/java/com/cultural/heritage/model/vo/user/UserMainInfoVO.java @@ -0,0 +1,51 @@ +package com.cultural.heritage.model.vo.user; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class UserMainInfoVO implements Serializable { + + + /** + * 主键 + */ + private Long id; + + /** + * 账号 + */ + private String userAccount; + + /** + * 密码 + */ + private String userPassword; + + + /** + * 用户昵称 + */ + private String userName; + + /** + * 用户头像 + */ + private String userAvatar; + + /** + * 积分 + */ + private Integer points; + + /** + * 用户身份 + */ + private String userRole; + + + @Serial + private static final long serialVersionUID = 1L; +}