feach: 新增信息校验
This commit is contained in:
parent
a75c4c3bd5
commit
571f4248e5
@ -3,6 +3,7 @@ package com.guaiguailang.harmony.controller;
|
|||||||
import com.guaiguailang.harmony.domain.dto.ParamLogin;
|
import com.guaiguailang.harmony.domain.dto.ParamLogin;
|
||||||
import com.guaiguailang.harmony.domain.dto.ParamUserAdd;
|
import com.guaiguailang.harmony.domain.dto.ParamUserAdd;
|
||||||
import com.guaiguailang.harmony.domain.dto.ParamUserList;
|
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.domain.vo.ResponseResult;
|
||||||
import com.guaiguailang.harmony.service.UserService;
|
import com.guaiguailang.harmony.service.UserService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -75,7 +77,15 @@ public class UserController {
|
|||||||
)
|
)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public ResponseEntity addUser(@RequestBody ParamUserAdd userAddParam){
|
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(
|
@Operation(
|
||||||
|
Loading…
Reference in New Issue
Block a user