Merge branch 'hotfix/20250207' into 'master'
Hotfix/20250207 See merge request universal/framework/backend/axzo-framework-commons!103
This commit is contained in:
commit
c3d1a27a81
@ -17,7 +17,10 @@ import lombok.SneakyThrows;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.*;
|
import org.aspectj.lang.annotation.AfterThrowing;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
@ -31,8 +34,6 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.axzo.framework.datapermission.context.DataPermissionContextHolder.DATA_PERMISSION_HEADER;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析数据权限规则,把解析后的数据放置在上下文中DataPermissionContext
|
* 解析数据权限规则,把解析后的数据放置在上下文中DataPermissionContext
|
||||||
*/
|
*/
|
||||||
@ -81,8 +82,7 @@ public class DataPermissionInterceptor {
|
|||||||
@Around(value = "@within(dataPermission) && @within(restController)")
|
@Around(value = "@within(dataPermission) && @within(restController)")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public Object classHandler(ProceedingJoinPoint pjp, DataPermission dataPermission, RestController restController) {
|
public Object classHandler(ProceedingJoinPoint pjp, DataPermission dataPermission, RestController restController) {
|
||||||
handle(dataPermission);
|
return proceed(pjp, dataPermission);
|
||||||
return pjp.proceed(pjp.getArgs());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,8 +91,18 @@ public class DataPermissionInterceptor {
|
|||||||
@Around(value = "@annotation(dataPermission) && mappingAnnotations()")
|
@Around(value = "@annotation(dataPermission) && mappingAnnotations()")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public Object methodHandler(ProceedingJoinPoint pjp, DataPermission dataPermission) {
|
public Object methodHandler(ProceedingJoinPoint pjp, DataPermission dataPermission) {
|
||||||
|
return proceed(pjp, dataPermission);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object proceed(ProceedingJoinPoint pjp, DataPermission dataPermission) throws Throwable {
|
||||||
|
Object result;
|
||||||
|
try {
|
||||||
handle(dataPermission);
|
handle(dataPermission);
|
||||||
return pjp.proceed(pjp.getArgs());
|
result = pjp.proceed(pjp.getArgs());
|
||||||
|
} finally {
|
||||||
|
DataPermissionContextHolder.remove();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterThrowing(value = "(@within(cn.axzo.framework.datapermission.annotation.DataPermission) && @within(org.springframework.web.bind.annotation.RestController)) " +
|
@AfterThrowing(value = "(@within(cn.axzo.framework.datapermission.annotation.DataPermission) && @within(org.springframework.web.bind.annotation.RestController)) " +
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user