1. 添加策略模板API文档

This commit is contained in:
EnderByEndera
2024-01-12 19:24:19 +08:00
parent c1a5d2462f
commit 8a719709a3
33 changed files with 450 additions and 222 deletions

View File

@@ -1,7 +1,6 @@
package com.realtime.protection.configuration.entity.task;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Future;
import jakarta.validation.constraints.NotNull;

View File

@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.core.annotation.Order;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -27,7 +28,7 @@ public class GlobalExceptionHandler {
}
@Order(3)
@ExceptionHandler(value = Exception.class)
@ExceptionHandler(value = {Exception.class})
public ResponseResult handleGlobalException(Exception e) {
log.error("meets global exception: " + e.getMessage());
return ResponseResult.error().setMessage(e.getMessage());
@@ -35,13 +36,20 @@ public class GlobalExceptionHandler {
@Order(2)
@ExceptionHandler(value = PersistenceException.class)
@ExceptionHandler(value = {PersistenceException.class})
public ResponseResult handleSQLException(PersistenceException e) {
log.error("meets database exception: " + e.getMessage());
return ResponseResult.invalid().setMessage(
"please check the integrity of the data. check if the json data exists in the database");
}
@Order(2)
@ExceptionHandler(value = DuplicateKeyException.class)
public ResponseResult handleDuplicateKeyException(DuplicateKeyException e) {
log.debug("meets duplicate key exception: " + e.getMessage());
return ResponseResult.invalid().setMessage("duplicate key in json data");
}
@Order(2)
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public ResponseResult handleBindException(MethodArgumentNotValidException e) {

View File

@@ -8,7 +8,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
@Data
@Schema(name = "通用返回对象", description = "用于所有接口返回的通用返回对象")
@Schema(description = "用于所有接口返回的通用返回对象")
public class ResponseResult implements Serializable {
@Schema(description = "状态码")

View File

@@ -3,8 +3,6 @@ package com.realtime.protection.configuration.swagger;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@OpenAPIDefinition(
info = @Info(