Browse Source

【报表】增加AOP拦截器,和对应的注解,用于拦截url参数,给具有@RequestBody注解的入参赋值

dev
wangxianzhang 3 years ago
parent
commit
ac7fc2032b
  1. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ReportRequestAspect.java

9
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ReportRequestAspect.java

@ -1,7 +1,10 @@
package com.epmet.commons.tools.aspect; package com.epmet.commons.tools.aspect;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
@ -25,6 +28,7 @@ import java.util.Map;
@Aspect @Aspect
@Component @Component
@Order(20) @Order(20)
@Slf4j
public class ReportRequestAspect { public class ReportRequestAspect {
/** /**
@ -46,6 +50,11 @@ public class ReportRequestAspect {
} }
Map<String, Object> cachedParams = redisUtils.hGetAll(paramKey); Map<String, Object> cachedParams = redisUtils.hGetAll(paramKey);
if (cachedParams == null || cachedParams.size() == 0) {
log.warn("【报表服务】根据paramKey:{}未获取到有效的参数缓存。", paramKey);
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "参数失效", "参数失效");
// redis中没有此参数
}
// 使用方法签名获取出参数class列表 // 使用方法签名获取出参数class列表
Object[] args = point.getArgs(); Object[] args = point.getArgs();

Loading…
Cancel
Save