package com.wgb.system.service.config;

import com.wgb.system.service.Filter.TokenFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//@Configuration
//@EnableWebMvc
public class MyWebAppConfigurer extends WebMvcConfigurerAdapter {

    @Bean
    public FilterRegistrationBean jwtFilter() {
        final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new TokenFilter());
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }

    /** 添加拦截器 **/
    public void addInterceptors(InterceptorRegistry registry){

    }
    /** 这里配置视图解析器 **/
    public void configureViewResolvers(ViewResolverRegistry registry){

    }
    /** 配置内容裁决的一些选项 **/
    public void configureContentNegotiation(ContentNegotiationConfigurer configurer){

    }
    /** 视图跳转控制器 **/
    public void addViewControllers(ViewControllerRegistry registry){

    }

    /** 静态资源处理 **/
    public void addResourceHandlers(ResourceHandlerRegistry registry){
    }

    /** 默认静态资源处理器 **/
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer){

    }

    /** 解决跨域问题 **/
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**");
    }
}
