提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.framework.datapermission.core.aop; |
H |
2 |
|
|
3 |
import com.iailab.framework.datapermission.core.annotation.DataPermission; |
|
4 |
import lombok.EqualsAndHashCode; |
|
5 |
import lombok.Getter; |
|
6 |
import org.aopalliance.aop.Advice; |
|
7 |
import org.springframework.aop.Pointcut; |
|
8 |
import org.springframework.aop.support.AbstractPointcutAdvisor; |
|
9 |
import org.springframework.aop.support.ComposablePointcut; |
|
10 |
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut; |
|
11 |
|
|
12 |
/** |
|
13 |
* {@link com.iailab.framework.datapermission.core.annotation.DataPermission} 注解的 Advisor 实现类 |
|
14 |
* |
|
15 |
* @author iailab |
|
16 |
*/ |
|
17 |
@Getter |
|
18 |
@EqualsAndHashCode(callSuper = true) |
|
19 |
public class DataPermissionAnnotationAdvisor extends AbstractPointcutAdvisor { |
|
20 |
|
|
21 |
private final Advice advice; |
|
22 |
|
|
23 |
private final Pointcut pointcut; |
|
24 |
|
|
25 |
public DataPermissionAnnotationAdvisor() { |
|
26 |
this.advice = new DataPermissionAnnotationInterceptor(); |
|
27 |
this.pointcut = this.buildPointcut(); |
|
28 |
} |
|
29 |
|
|
30 |
protected Pointcut buildPointcut() { |
|
31 |
Pointcut classPointcut = new AnnotationMatchingPointcut(DataPermission.class, true); |
|
32 |
Pointcut methodPointcut = new AnnotationMatchingPointcut(null, DataPermission.class, true); |
|
33 |
return new ComposablePointcut(classPointcut).union(methodPointcut); |
|
34 |
} |
|
35 |
|
|
36 |
} |