一、加入注解
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
二、获取当前代理的接口
public interface ICurrentAopProxyService<T> {
default T getCurrentProxyService() {
return (T) AopContext.currentProxy();
}
}
三、需要嵌套调用的Service实现它
四、调用的时候改写代码
通过getCurrentProxyService()
去调用需要被嵌套生效的aop的方法
public SysMerchantVersion selectByMerchantId(Long merchantId) {
return getCurrentProxyService().getOne(new QueryWrapper<SysMerchantVersion>()
.lambda()
.eq(SysMerchantVersion::getMerchantId, merchantId));
}