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("/admin/**"); //小程序公司与域名对应关系拦截 registry.addInterceptor(hostInterceptor).addPathPatterns("/**/wxapi/**") .excludePathPatterns("/wxCommon/wxapi/wxpayCallback") .excludePathPatterns("/wxCommon/wxapi/rechargeCallBack"); } /** * 将自定义标签加入到组件 * * @author jiangyouyao * @email 512061637@qq.com * @date 2019年1月12日 * @return */ @Bean public MatrixProcessorDialect matrixDialect() { return new MatrixProcessorDialect(); } }