1. 修改防护对象、策略模板和任务的Swagger文档
2. 修改任务和指令部分逻辑
This commit is contained in:
@@ -40,7 +40,6 @@ public class GlobalExceptionHandler {
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = {
|
||||
PersistenceException.class,
|
||||
DuplicateKeyException.class,
|
||||
SQLException.class,
|
||||
SQLIntegrityConstraintViolationException.class
|
||||
})
|
||||
@@ -50,6 +49,14 @@ public class GlobalExceptionHandler {
|
||||
"请检查json字段的完整性,确保json字段按照文档中要求填写。");
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = DuplicateKeyException.class)
|
||||
public ResponseResult handleDuplicateKeyException(DuplicateKeyException e) {
|
||||
return ResponseResult.invalid().setMessage(
|
||||
"插入/更新失败,请检查当前插入字段和数据库中是否存在相同数据"
|
||||
);
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
||||
public ResponseResult handleBindException(MethodArgumentNotValidException e) {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.realtime.protection.configuration.response;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Schema(description = "xxx")
|
||||
public class ResponseData extends HashMap<String, Object> {
|
||||
|
||||
public Object put(String key, Object value, String description) {
|
||||
return super.put(key, value);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@@ -17,12 +18,12 @@ public class ResponseResult implements Serializable {
|
||||
private String message;
|
||||
|
||||
@Schema(description = "封装数据")
|
||||
private ResponseData data;
|
||||
private Map<String, Object> data;
|
||||
|
||||
@Schema(description = "返回对象链接的另外一个返回对象")
|
||||
private ResponseResult another;
|
||||
|
||||
public ResponseResult(int code, String message, ResponseData data) {
|
||||
public ResponseResult(int code, String message, LinkedHashMap<String, Object> data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
@@ -30,13 +31,13 @@ public class ResponseResult implements Serializable {
|
||||
|
||||
public ResponseResult(int code) {
|
||||
this.code = code;
|
||||
this.data = new ResponseData();
|
||||
this.data = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
public ResponseResult(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = new ResponseData();
|
||||
this.data = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
public static ResponseResult ok() {
|
||||
@@ -83,7 +84,7 @@ public class ResponseResult implements Serializable {
|
||||
}
|
||||
|
||||
public ResponseResult addDataMap(Map<String, Object> data) {
|
||||
this.data = (ResponseData) data;
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user