1. 增加jackson配置,缩减json数据长度

2. ExceptionHandler添加SaTokenException检查,用于校验登陆
3. ResponseResult添加invalid和unauthorized静态方法
4. Task模块添加单查询,多查询,更新路由
5. Template添加两个JsonProperty
6. Template模块添加query路由
7.
This commit is contained in:
松岳 陈
2024-01-03 22:53:02 +08:00
parent b0c1700bd3
commit 06886de328
16 changed files with 342 additions and 73 deletions

View File

@@ -1,7 +1,9 @@
package com.realtime.protection.configuration.exception;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.exception.SaTokenException;
import com.realtime.protection.configuration.response.ResponseResult;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.core.annotation.Order;
@@ -24,26 +26,30 @@ public class GlobalExceptionHandler {
@ExceptionHandler(value = NotLoginException.class)
public ResponseResult handleNotLoginException(NotLoginException e) {
return new ResponseResult(
400,
401,
e.getMessage()
);
}
@Order(2)
@ExceptionHandler(value = PersistenceException.class)
public ResponseResult handleSQLException() {
return new ResponseResult(
400,
public ResponseResult handleSQLException(PersistenceException e) {
return ResponseResult.invalid().setMessage(
"please check the integrity of the data. check if the json data exists in the database");
}
@Order(2)
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public ResponseResult handleBindException(MethodArgumentNotValidException e) {
return new ResponseResult(
400,
return ResponseResult.invalid().setMessage(
e.getBindingResult().getAllErrors().stream()
.map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining())
);
}
@Order(2)
@ExceptionHandler(value = SaTokenException.class)
public ResponseResult handleSaTokenException(SaTokenException e) {
return ResponseResult.unAuthorized().setMessage(e.getMessage());
}
}