java如何修复“使用Spring AOP,我想更改返回值,但返回类不是我的返回方法”
我正在使用Spring AOP来更改返回值。但我发现@Around函数中的返回值不是方法返回值。如何解决这个问题
控制器
Page<Object> page = PageHelper.startPage(pageNo, pageSize, true);
CallRecordEntity callRecordParam = new CallRecordEntity();
BeanUtils.copyProperties(callRecordVO, callRecordParam);
callRecordParam.setEnterpriseId(ThreadCacheMgr.getEntId());
List<CallRecordEntity> list = callRecordService.callList(callRecordParam);
服务
@Override
@SensitiveInfo(SensitiveInfoType.CALL_RECORD)
public List<CallRecordEntity> callList(CallRecordEntity callRecordEntity) {
}
@Pointcut("@annotation(com.zhexinit.aicc.common.annotation.SensitiveInfo)")
public void sensitiveInfoAspect() {
}
@Around("sensitiveInfoAspect()")
public Object process(ProceedingJoinPoint point) throws Throwable {
UserCacheVO userCacheVO = (UserCacheVO) SecurityContextHolder.getContext().getAuthentication()
.getPrincipal();
Object ret = point.proceed();
Signature signature = point.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method targetMethod = methodSignature.getMethod();
System.out.println("classname:" + targetMethod.getDeclaringClass().getName());
System.out.println("superclass:" + targetMethod.getDeclaringClass().getSuperclass().getName());
System.out.println("isinterface:" + targetMethod.getDeclaringClass().isInterface());
System.out.println("target:" + point.getTarget().getClass().getName());
System.out.println("proxy:" + point.getThis().getClass().getName());
System.out.println("method:" + targetMethod.getName());
System.out.println("methodReturnType:" + targetMethod.getReturnType().getName());
System.out.println("return value:" + ret.getClass().getName());
return ret;
}
我期待ret.getClass()。getName()是列表,但返回值是控制器中的Page
共 (0) 个答案