From 571f4248e5fd6f189c992f3a5bcb7a30f86f3099 Mon Sep 17 00:00:00 2001 From: Moon Date: Tue, 5 Nov 2024 15:53:33 +0800 Subject: [PATCH] =?UTF-8?q?feach:=20=E6=96=B0=E5=A2=9E=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../harmony/controller/UserController.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/guaiguailang/harmony/controller/UserController.java b/src/main/java/com/guaiguailang/harmony/controller/UserController.java index 9fd640a..9ae2c87 100644 --- a/src/main/java/com/guaiguailang/harmony/controller/UserController.java +++ b/src/main/java/com/guaiguailang/harmony/controller/UserController.java @@ -3,6 +3,7 @@ package com.guaiguailang.harmony.controller; import com.guaiguailang.harmony.domain.dto.ParamLogin; import com.guaiguailang.harmony.domain.dto.ParamUserAdd; import com.guaiguailang.harmony.domain.dto.ParamUserList; +import com.guaiguailang.harmony.domain.entity.UserInfo; import com.guaiguailang.harmony.domain.vo.ResponseResult; import com.guaiguailang.harmony.service.UserService; import io.swagger.v3.oas.annotations.Operation; @@ -10,6 +11,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import org.apache.commons.lang3.StringUtils; @RestController @@ -75,7 +77,15 @@ public class UserController { ) @PostMapping("/add") public ResponseEntity addUser(@RequestBody ParamUserAdd userAddParam){ - return ResponseEntity.ok(userService.addUser(userAddParam)); + +// 校验字段 + if (StringUtils.isAnyBlank(userAddParam.getName(), userAddParam.getUserName(), userAddParam.getPassword(), userAddParam.getRoleId())) { + return ResponseEntity.badRequest().body("用户账号不能为空"); + } else { + return ResponseEntity.ok(userService.addUser(userAddParam)); + } + + } @Operation(