1. 修改setDataMap函数为addDataMap以防止swagger将DataMap视为一种属性
2. 当任务未通过审核时,现在会立刻报错而不是返回false
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package com.realtime.protection.configuration.cors;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CorsFilter implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry corsRegistry) {
|
||||
corsRegistry.addMapping("/**")
|
||||
.allowedOrigins("http://localhost:8000")
|
||||
.allowCredentials(true)
|
||||
.allowedMethods("GET", "POST", "DELETE", "PUT")
|
||||
.allowedHeaders("*")
|
||||
.exposedHeaders("*");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,12 @@ public class ResponseResult implements Serializable {
|
||||
private String message;
|
||||
|
||||
@Schema(description = "封装数据")
|
||||
private Map<String, Object> data;
|
||||
private ResponseData data;
|
||||
|
||||
@Schema(description = "返回对象链接的另外一个返回对象")
|
||||
private ResponseResult another;
|
||||
|
||||
public ResponseResult(int code, String message, LinkedHashMap<String, Object> data) {
|
||||
public ResponseResult(int code, String message, ResponseData data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
@@ -31,13 +31,13 @@ public class ResponseResult implements Serializable {
|
||||
|
||||
public ResponseResult(int code) {
|
||||
this.code = code;
|
||||
this.data = new LinkedHashMap<>();
|
||||
this.data = new ResponseData();
|
||||
}
|
||||
|
||||
public ResponseResult(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = new LinkedHashMap<>();
|
||||
this.data = new ResponseData();
|
||||
}
|
||||
|
||||
public static ResponseResult ok() {
|
||||
@@ -83,8 +83,8 @@ public class ResponseResult implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponseResult setDataMap(Map<String, Object> data) {
|
||||
this.data = data;
|
||||
public ResponseResult addDataMap(Map<String, Object> data) {
|
||||
this.data = (ResponseData) data;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user