Merge branch 'dev' of axzsource.com:universal/infrastructure/backend/pokonyan into dev

This commit is contained in:
金海洋 2023-10-23 18:15:26 +08:00
commit a9744494da
3 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,10 @@
package cn.axzo.pokonyan.common.enums;
/**
* @author tanjie@axzo.cn
* @date 2023/10/13 18:56
*/
public interface BaseTypeEnum {
<T> T getValue();
}

View File

@ -1,6 +1,7 @@
package cn.axzo.pokonyan.filter;
import cn.axzo.pokonyan.util.ExceptionUtil;
import cn.axzo.pokonyan.wrapper.BodyReaderHttpServletRequestWrapper;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
@ -54,7 +55,10 @@ public class RequestLogHandlerInterceptor implements HandlerInterceptor, WebMvcC
if (request.getDispatcherType().equals(DispatcherType.ERROR)) {
return;
}
if (!(request instanceof BodyReaderHttpServletRequestWrapper)) {
log.warn("print request log error : current request entity not support");
return;
}
String method = request.getMethod();
StringBuffer requestUrl = request.getRequestURL();

View File

@ -0,0 +1,24 @@
package cn.axzo.pokonyan.util;
import cn.axzo.pokonyan.common.enums.BaseTypeEnum;
import java.util.EnumSet;
import java.util.Objects;
/**
* @author tanjie@axzo.cn
* @date 2023/10/13 18:57
*/
public class EnumUtil {
/**
* 枚举匹配value
* @param clazz
* @param type
* @param <E>
* @return
*/
public <E extends Enum<E> & BaseTypeEnum> E matchType(Class<E> clazz, Integer value) {
return EnumSet.allOf(clazz).stream().filter(e -> Objects.equals(e.getValue(), value)).findFirst().orElse(null);
}
}