Merge remote-tracking branch 'origin/feautre/REQ-1465'

This commit is contained in:
zhansihu 2023-12-18 20:50:56 +08:00
commit 894d319aa0
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; package cn.axzo.pokonyan.filter;
import cn.axzo.pokonyan.util.ExceptionUtil; import cn.axzo.pokonyan.util.ExceptionUtil;
import cn.axzo.pokonyan.wrapper.BodyReaderHttpServletRequestWrapper;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -56,7 +57,10 @@ public class RequestLogHandlerInterceptor implements HandlerInterceptor, WebMvcC
if (request.getDispatcherType().equals(DispatcherType.ERROR)) { if (request.getDispatcherType().equals(DispatcherType.ERROR)) {
return; return;
} }
if (!(request instanceof BodyReaderHttpServletRequestWrapper)) {
log.warn("print request log error : current request entity not support");
return;
}
String method = request.getMethod(); String method = request.getMethod();
StringBuffer requestUrl = request.getRequestURL(); 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);
}
}