From f36e4a38a8619e2ed72f5c32f8bbeb209653878a Mon Sep 17 00:00:00 2001
From: chen-xin-zhi <3588068430@qq.com>
Date: Tue, 29 Apr 2025 09:13:04 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86Web=E7=AB=AF?=
 =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95=E5=92=8C=E9=80=80=E5=87=BA?=
 =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=9A=84=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 pom.xml                                       | 11 +++++++++-
 .../controller/user/UserInfoController.java   | 10 ++++-----
 .../model/dto/user/UserInfoAddRequest.java    | 22 +++++++++----------
 .../promotion/model/entity/UserInfo.java      |  2 ++
 src/main/resources/application.yml            |  1 -
 5 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4af5bd7..2ecd2c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,6 +62,15 @@
             <scope>test</scope>
         </dependency>
 
+
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
+
+
+
         <!-- knife4j -->
         <dependency>
             <groupId>com.github.xiaoymin</groupId>
@@ -116,7 +125,7 @@
             <artifactId>spring-boot-starter-data-redis</artifactId>
         </dependency>
 
-        <!--        Gson-->
+        <!-- Gson -->
         <dependency>
             <groupId>com.google.code.gson</groupId>
             <artifactId>gson</artifactId>
diff --git a/src/main/java/com/greenorange/promotion/controller/user/UserInfoController.java b/src/main/java/com/greenorange/promotion/controller/user/UserInfoController.java
index 23be05c..b20b04d 100644
--- a/src/main/java/com/greenorange/promotion/controller/user/UserInfoController.java
+++ b/src/main/java/com/greenorange/promotion/controller/user/UserInfoController.java
@@ -3,7 +3,6 @@ package com.greenorange.promotion.controller.user;
 import com.auth0.jwt.interfaces.DecodedJWT;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.google.common.net.HttpHeaders;
 import com.greenorange.promotion.annotation.RequiresPermission;
 import com.greenorange.promotion.common.BaseResponse;
 import com.greenorange.promotion.common.ErrorCode;
@@ -23,17 +22,15 @@ import com.greenorange.promotion.service.common.CommonService;
 import com.greenorange.promotion.service.user.UserInfoService;
 import com.greenorange.promotion.utils.JWTUtils;
 import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.security.SecurityRequirement;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletRequest;
+import jakarta.validation.Valid;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
@@ -109,13 +106,14 @@ public class UserInfoController {
      */
     @PostMapping("add")
     @Operation(summary = "web端管理员添加用户表", description = "参数:用户表添加请求体,权限:管理员(boss, admin),方法名:addUserInfo")
-    public BaseResponse<Boolean> addUserInfo(@RequestBody @Valid UserInfoAddRequest userInfoAddRequest) {
+    public BaseResponse<Boolean> addUserInfo(@Valid @RequestBody UserInfoAddRequest userInfoAddRequest) {
         UserInfo userInfo = commonService.copyProperties(userInfoAddRequest, UserInfo.class);
         userInfoService.save(userInfo);
         return ResultUtils.success(true);
     }
 
 
+
     /**
      * web端管理员更新用户表
      * @param userInfoUpdateRequest 用户表更新请求体
@@ -123,7 +121,7 @@ public class UserInfoController {
      */
     @PostMapping("update")
     @Operation(summary = "web端管理员更新用户表", description = "参数:用户表更新请求体,权限:管理员(boss, admin),方法名:updateUserInfo")
-    public BaseResponse<Boolean> updateUserInfo(@RequestBody @Valid UserInfoUpdateRequest userInfoUpdateRequest) {
+    public BaseResponse<Boolean> updateUserInfo(@RequestBody UserInfoUpdateRequest userInfoUpdateRequest) {
         ThrowUtils.throwIf(userInfoUpdateRequest == null || userInfoUpdateRequest.getId() <= 0, ErrorCode.PARAMS_ERROR);
         UserInfo userInfo = commonService.copyProperties(userInfoUpdateRequest, UserInfo.class);
         userInfoService.updateById(userInfo);
diff --git a/src/main/java/com/greenorange/promotion/model/dto/user/UserInfoAddRequest.java b/src/main/java/com/greenorange/promotion/model/dto/user/UserInfoAddRequest.java
index 1c39632..2368d2a 100644
--- a/src/main/java/com/greenorange/promotion/model/dto/user/UserInfoAddRequest.java
+++ b/src/main/java/com/greenorange/promotion/model/dto/user/UserInfoAddRequest.java
@@ -1,9 +1,8 @@
 package com.greenorange.promotion.model.dto.user;
 
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
 import lombok.Data;
-
-import javax.validation.constraints.NotBlank;
 import java.io.Serial;
 import java.io.Serializable;
 
@@ -19,59 +18,60 @@ public class UserInfoAddRequest implements Serializable {
      * 用户昵称
      */
     @NotBlank(message = "参数不能为空")
-    @Schema(description = "用户昵称", example = "${field.example}")
+    @Schema(description = "用户昵称", example = "chenxinzhi")
     private String nickName;
 
     /**
      * 用户头像URL
      */
-    @Schema(description = "用户头像URL", example = "${field.example}")
+    @NotBlank(message = "参数不能为空")
+    @Schema(description = "用户头像URL", example = "http://xxx.png")
     private String userAvatar;
 
     /**
      * 手机号
      */
     @NotBlank(message = "参数不能为空")
-    @Schema(description = "手机号", example = "${field.example}")
+    @Schema(description = "手机号", example = "15888610253")
     private String phoneNumber;
 
     /**
      * 账号
      */
     @NotBlank(message = "参数不能为空")
-    @Schema(description = "账号", example = "${field.example}")
+    @Schema(description = "账号", example = "qingcheng_account")
     private String userAccount;
 
     /**
      * 密码
      */
     @NotBlank(message = "参数不能为空")
-    @Schema(description = "密码", example = "${field.example}")
+    @Schema(description = "密码", example = "qingcheng_password")
     private String userPassword;
 
     /**
      * 邀请码
      */
-    @Schema(description = "邀请码", example = "${field.example}")
+    @Schema(description = "邀请码", example = "666999")
     private String invitationCode;
 
     /**
      * 用户角色
      */
     @NotBlank(message = "参数不能为空")
-    @Schema(description = "用户角色", example = "${field.example}")
+    @Schema(description = "用户角色", example = "user")
     private String userRole;
 
     /**
      * 上级用户id
      */
-    @Schema(description = "上级用户id", example = "${field.example}")
+    @Schema(description = "上级用户id", example = "1")
     private Long parentUserId;
 
     /**
      * 上级用户列表(1,2,3)
      */
-    @Schema(description = "上级用户列表(1,2,3)", example = "${field.example}")
+    @Schema(description = "上级用户列表(1,2,3)", example = "1, 2, 3")
     private String superUserList;
 
 
diff --git a/src/main/java/com/greenorange/promotion/model/entity/UserInfo.java b/src/main/java/com/greenorange/promotion/model/entity/UserInfo.java
index e27b17f..f9a2851 100644
--- a/src/main/java/com/greenorange/promotion/model/entity/UserInfo.java
+++ b/src/main/java/com/greenorange/promotion/model/entity/UserInfo.java
@@ -8,6 +8,8 @@ import java.io.Serializable;
 import java.util.Date;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 /**
  * 用户基本信息表
  * @TableName user_info
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 7bf1d85..be5d1ab 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -10,7 +10,6 @@ spring:
 
 
 
-
   data:
     redis:
       port: 6379