|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @description 容器添加组件 | 
|---|
|  |  |  | * @date 2019-06-14 15:50 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Configuration | 
|---|
|  |  |  | @Configuration() | 
|---|
|  |  |  | @PropertySource("classpath:config/system.properties") | 
|---|
|  |  |  | public class MvcCoreConfig implements WebMvcConfigurer { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WbeCommonInterceptor wbeCommonInterceptor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiUserLoginInterceptor apiUserLoginInterceptor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 添加拦截器 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @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("/plugin/**") | 
|---|
|  |  |  | .excludePathPatterns("/swagger**/**") | 
|---|
|  |  |  | .excludePathPatterns("/webjars/**"); | 
|---|
|  |  |  | // 用户认证拦截 | 
|---|
|  |  |  | registry.addInterceptor(userLoginInterceptor).addPathPatterns("/**").excludePathPatterns("/common/**").excludePathPatterns("/resource/**"); | 
|---|
|  |  |  | 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/**"); | 
|---|
|  |  |  | registry.addInterceptor(hostInterceptor).addPathPatterns("/**/wxapi/**") | 
|---|
|  |  |  | .excludePathPatterns("/wxCommon/wxapi/wxpayCallback") | 
|---|
|  |  |  | .excludePathPatterns("/wxCommon/wxapi/rechargeCallBack"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|