Commit 5a6e76e6 authored by hanbing's avatar hanbing

[update] 策略管理,优先级为空时返回异常说明

parent 4fe1638a
......@@ -17,7 +17,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import javax.ws.rs.core.MediaType;
import java.util.List;
/**
* 策略管理-场景库
......@@ -42,8 +44,15 @@ public class SceneController {
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = JsonViewObject.class),
})
public JsonViewObject addOrUpdateScene(@RequestBody AddOrUpdateSceneDTO addOrUpdateSceneDTO) {
public JsonViewObject addOrUpdateScene(@RequestBody @Valid AddOrUpdateSceneDTO addOrUpdateSceneDTO) {
try {
List<AddOrUpdateSceneDTO.StrategyListElement> strategyList = addOrUpdateSceneDTO.getStrategyList();
for (AddOrUpdateSceneDTO.StrategyListElement strategyListElement : strategyList) {
Integer priority = strategyListElement.getPriority();
if (priority == null) {
throw new RuntimeException("优先级不可为空");
}
}
sceneService.addOrUpdateScene(addOrUpdateSceneDTO);
} catch (DuplicateKeyException e) {
throw new DuplicateKeyException("场景编号或场景名称不可重复");
......
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;
......@@ -39,6 +40,7 @@ public class AddOrUpdateSceneDTO {
@ApiModelProperty(value = "策略名称",required = true,notes = "")
private String strategyName;
@ApiModelProperty(value = "优先级",required = true,notes = "")
@NotNull(message = "优先级不可为空")
private Integer priority;
@ApiModelProperty(value = "优化方法",required = true,notes = "")
private List<IdeaListElement> ideaList;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment