xiaoyong931011
2023-08-15 84c7afc62bb1eb6f5d80d2d9928d0d11a1ffbdda
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
package cc.mrbird.febs.common.configure;
 
import cc.mrbird.febs.common.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
/**
 * @author xxx
 * @date 2020-08-24
 **/
@Configuration
public class WebMvcConfigure implements WebMvcConfigurer {
 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(new LoginInterceptor());
        registration.addPathPatterns("/api/**");
        registration.excludePathPatterns("/api/login/**");
        registration.excludePathPatterns("/api/common/**");
        registration.excludePathPatterns("/api/category/**");
        registration.excludePathPatterns("/api/goods/**");
        registration.excludePathPatterns("/api/pay/**");
        registration.excludePathPatterns("/api/news/**");
        registration.excludePathPatterns("/api/member/cashOutSetting");
        registration.excludePathPatterns("/api/member/agentDetail");
        registration.excludePathPatterns("/api/member/activityInfo");
        registration.excludePathPatterns("/api/leader/leaderList");
        registration.excludePathPatterns("/api/leader/leaderListInFence");
        registration.excludePathPatterns("/api/leader/noLoginLeaderTitle");
        registration.excludePathPatterns("/api/xcxPay/wxpayCallback");
        registration.excludePathPatterns("/api/xcxPay/rechargeCallBack");
        registration.excludePathPatterns("/api/wechat/reply/event");
    }
 
    /**
     * 设置cors跨域支持
     *
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry){
        //设置允许跨域的路径
        registry.addMapping ("/**")
                //设置允许跨域请求的域名
                .allowedOrigins ("*")
                //是否允许证书
                .allowCredentials (true)
                //设置允许的方法
                .allowedMethods ("GET","POST", "OPTIONS")
                //设置允许的header属性
                .allowedHeaders ("*")
                //允许跨域时间
                .maxAge (3600);
    }
}