枚举转换

This commit is contained in:
liulu 2024-12-17 11:17:38 +08:00
parent be7bb30fd4
commit bd099ba04e
9 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package com.sunyard.chsm.config;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.sunyard.chsm.model.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
@ -55,6 +56,10 @@ public class GlobalExceptionResolver {
@ExceptionHandler(Exception.class)
public R<?> exceptionHandler(Exception ex, HttpServletRequest request) {
InvalidFormatException ife = findException(InvalidFormatException.class, ex);
if (ife != null) {
return R.error(400, "参数异常, 不支持的值: " + ife.getValue());
}
String errorMessage = buildErrorMessage(ex);
for (Class<? extends Exception> eClass : EX_CLASS) {
Exception exception = findException(eClass, ex);

View File

@ -1,5 +1,7 @@
package com.sunyard.chsm.param;
import com.sunyard.chsm.enums.KeyCategory;
import com.sunyard.chsm.enums.KeyStatus;
import lombok.Data;
/**
@ -20,11 +22,11 @@ public class KeyInfoQuery {
/**
* 密钥状态
*/
private String status;
private KeyStatus status;
/**
* 密钥类型: sym_key 对称密钥, asym_key 非对称密钥
* 密钥类型
*/
private String keyType;
private KeyCategory keyType;
}

View File

@ -29,6 +29,8 @@ spring:
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
mapper:
ACCEPT_CASE_INSENSITIVE_ENUMS: true
mybatis-plus:
mapper-locations: classpath:mapper/**/*Mapper.xml