提交 | 用户 | 时间
|
325d2f
|
1 |
package com.iailab.framework.datapermission.config; |
H |
2 |
|
|
3 |
import com.iailab.framework.datapermission.core.rpc.DataPermissionRequestInterceptor; |
|
4 |
import com.iailab.framework.datapermission.core.rpc.DataPermissionRpcWebFilter; |
|
5 |
import org.springframework.boot.autoconfigure.AutoConfiguration; |
|
6 |
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
|
7 |
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
|
8 |
import org.springframework.context.annotation.Bean; |
|
9 |
|
|
10 |
import static com.iailab.framework.common.enums.WebFilterOrderEnum.TENANT_CONTEXT_FILTER; |
|
11 |
|
|
12 |
|
|
13 |
/** |
|
14 |
* 数据权限针对 RPC 的自动配置类 |
|
15 |
* |
4d4165
|
16 |
* @author iailab |
325d2f
|
17 |
*/ |
H |
18 |
@AutoConfiguration |
|
19 |
@ConditionalOnClass(name = "feign.RequestInterceptor") |
|
20 |
public class IailabDataPermissionRpcAutoConfiguration { |
|
21 |
|
|
22 |
@Bean |
|
23 |
public DataPermissionRequestInterceptor dataPermissionRequestInterceptor() { |
|
24 |
return new DataPermissionRequestInterceptor(); |
|
25 |
} |
|
26 |
|
|
27 |
@Bean |
|
28 |
public FilterRegistrationBean<DataPermissionRpcWebFilter> dataPermissionRpcFilter() { |
|
29 |
FilterRegistrationBean<DataPermissionRpcWebFilter> registrationBean = new FilterRegistrationBean<>(); |
|
30 |
registrationBean.setFilter(new DataPermissionRpcWebFilter()); |
|
31 |
registrationBean.setOrder(TENANT_CONTEXT_FILTER - 1); // 顺序没有绝对的要求,在租户 Filter 前面稳妥点 |
|
32 |
return registrationBean; |
|
33 |
} |
|
34 |
|
|
35 |
} |