diff --git a/src/main/java/com/guaiguailang/harmony/controller/UserController.java b/src/main/java/com/guaiguailang/harmony/controller/UserController.java index e4e5d7a..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 @@ -59,7 +61,7 @@ public class UserController { description = "加载可以分配的角色,以供用户添加子用户", tags = {"用户相关接口"} ) - @GetMapping("/add/roleList") + @PostMapping("/add/roleList") public ResponseEntity getRoleListWhenAddUser(@RequestParam String role){ /* @@ -75,9 +77,15 @@ public class UserController { ) @PostMapping("/add") public ResponseEntity addUser(@RequestBody ParamUserAdd userAddParam){ -// System.out.println("==============得到数据======="); -// System.out.println(userAddParam.toString()); - 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(