参数校验问题处理

This commit is contained in:
Chopper
2021-09-23 09:27:22 +08:00
parent 50b52f07c6
commit be1c9772ad
11 changed files with 34 additions and 29 deletions

View File

@@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@@ -51,14 +52,14 @@ public class SpecificationManagerController {
@PostMapping
@ApiOperation(value = "保存规格")
public ResultMessage<Object> save(Specification specification) {
public ResultMessage<Object> save(@Valid Specification specification) {
specificationService.save(specification);
return ResultUtil.success();
}
@PutMapping("/{id}")
@ApiOperation(value = "更改规格")
public ResultMessage<Object> update(Specification specification, @PathVariable String id) {
public ResultMessage<Object> update(@Valid Specification specification, @PathVariable String id) {
specification.setId(id);
specificationService.saveOrUpdate(specification);
return ResultUtil.success();