935090232@qq.com
2021-03-04 a7f47c8953b2055e7971df01b1aad3b40b128b17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.matrix.config;
 
 
 
import com.matrix.core.interceptor.WbeCommonInterceptor;
import com.matrix.system.common.interceptor.ApiUserLoginInterceptor;
import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.common.interceptor.SuAuthorityInterceptor;
import com.matrix.system.common.interceptor.UserLoginInterceptor;
import com.matrix.system.common.tag.MatrixProcessorDialect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
/**
 * @author 姜友瑶
 * @description 容器添加组件
 * @date 2019-06-14 15:50
 */
@Configuration
@PropertySource("classpath:config/system.properties")
public class MvcCoreConfig implements WebMvcConfigurer {
 
    @Autowired
    private UserLoginInterceptor userLoginInterceptor;
 
 
    @Autowired
    private SuAuthorityInterceptor suAuthorityInterceptor;
 
    @Autowired
    private HostInterceptor hostInterceptor;
 
    @Autowired
    private WbeCommonInterceptor wbeCommonInterceptor;
 
    @Autowired
    private ApiUserLoginInterceptor apiUserLoginInterceptor;
 
 
    /**
     * 添加拦截器
     *
     * @param registry
     * @return
     * @author jiangyouyao
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 手机端拦截
        registry.addInterceptor(apiUserLoginInterceptor)
                .addPathPatterns("/api/**")
                .excludePathPatterns("/api/common/**");
 
        // 公共拦截
        registry.addInterceptor(wbeCommonInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/images/**")
                .excludePathPatterns("/plugin/**")
                .excludePathPatterns("/swagger**/**")
                .excludePathPatterns("/webjars/**");
        // 用户认证拦截
        registry.addInterceptor(userLoginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/common/**")
                .excludePathPatterns("/resource/**")
                .excludePathPatterns("/swagger**/**")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/api/**");
 
        // url权限拦截
        registry.addInterceptor(suAuthorityInterceptor).addPathPatterns("/**/su/**");
        //小程序公司与域名对应关系拦截
        registry.addInterceptor(hostInterceptor).addPathPatterns("/**/wxapi/**");
    }
 
 
    /**
     * 将自定义标签加入到组件
     * 
     * @author jiangyouyao
     * @email 512061637@qq.com
     * @date 2019年1月12日
     * @return
     */
    @Bean
    public MatrixProcessorDialect matrixDialect() {
        return new MatrixProcessorDialect();
    }
 
 
}