12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package cn.efunbox.audio.config;
- import cn.efunbox.audio.aop.*;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.web.servlet.config.annotation.EnableWebMvc;
- import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
- /**
- * 用户权限验证拦截器
- * Created by yao on 17-9-29.
- */
- @Configuration
- @EnableWebMvc
- public class Config extends WebMvcConfigurerAdapter {
- /**
- * 直接采用new interceptor或Autowired注入拦截器会导致dao为null的错误
- *
- * @return
- */
- @Bean
- AuthInterceptor authInterceptor() {
- return new AuthInterceptor();
- }
- @Bean
- AdminInterceptor adminInterceptor() {
- return new AdminInterceptor();
- }
- @Bean
- AllowOriginIntercepter allowOriginIntercepter() {
- return new AllowOriginIntercepter();
- }
- @Bean
- IgnoreOptionsInterceptor ignoreOptionsInterceptor() {
- return new IgnoreOptionsInterceptor();
- }
- @Bean
- ResLogInterceptor resLogInterceptor() {
- return new ResLogInterceptor();
- }
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(authInterceptor())
- .addPathPatterns("/audio/search", "/audio/searchList", "/audio/info/{audioId}", "/album", "/album/{albumId}")
- .excludePathPatterns("/device/**", "/error", "/audio/*");
- registry.addInterceptor(adminInterceptor())
- .addPathPatterns("/**", "/device/update", "/device/delete")
- .excludePathPatterns("/device/**", "/audio/info/{audioId}", "/error", "/admin/login", "/audio/search", "/file/**", "/audio/searchList", "/statistics", "/album", "/album/{albumId}")
- .excludePathPatterns("/getTypeList", "/getTypeContentList", "/getContentDetail", "/getContentChapterList", "/getChapterDetail", "/getTypeUpdateList", "/getContentUpdateList", "/getChapterUpdateList", "/getTypeUpdateList/**", "/getContentUpdateList/**", "/getChapterUpdateList/**")
- .excludePathPatterns("/api/hag/v1/**");
- //杭研开放接口
- //.excludePathPatterns("/getTypeList","/getTypeContentList","/getContentDetail","/getContentChapterList","/getChapterDetail","/getTypeUpdateList","/getContentUpdateList","/getChapterUpdateList");
- registry.addInterceptor(ignoreOptionsInterceptor())
- .addPathPatterns("/**")
- //杭研开放接口
- .excludePathPatterns("/getTypeList", "/getTypeContentList", "/getContentDetail", "/getContentChapterList", "/getChapterDetail", "/getTypeUpdateList", "/getContentUpdateList", "/getChapterUpdateList");
- registry.addInterceptor(allowOriginIntercepter())
- .addPathPatterns("/**");
- //杭研接口日志拦截器
- registry.addInterceptor(resLogInterceptor())
- .addPathPatterns("/getTypeList", "/getTypeContentList", "/getContentDetail", "/getContentChapterList", "/getChapterDetail", "/getTypeUpdateList", "/getContentUpdateList", "/getChapterUpdateList");
- }
- // /**
- // * 允许跨域访问
- // * @param registry
- // */
- // @Override
- // public void addCorsMappings(CorsRegistry registry) {
- // registry.addMapping("/**")
- // .allowedOrigins("*")
- // .allowCredentials(true)
- // .allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS")
- //// .allowedMethods("*")
- //// .allowedHeaders("*")
- // .maxAge(3600);
- // }
- }
|