-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathMain.java
More file actions
48 lines (41 loc) · 1.94 KB
/
Copy pathMain.java
File metadata and controls
48 lines (41 loc) · 1.94 KB
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
package com.javabaas.server;
import com.javabaas.server.common.interceptor.AdminInterceptor;
import com.javabaas.server.common.interceptor.AuthInterceptor;
import com.javabaas.server.common.interceptor.HeaderInterceptor;
import com.javabaas.server.common.interceptor.MasterInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@SpringBootApplication
public class Main extends WebMvcConfigurerAdapter {
@Autowired
private HeaderInterceptor contentTypeInterceptor;
@Autowired
private AuthInterceptor authInterceptor;
@Autowired
private AdminInterceptor adminInterceptor;
@Autowired
private MasterInterceptor masterInterceptor;
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
//请求头拦截器,检查Content-Type、platform等
registry.addInterceptor(contentTypeInterceptor).addPathPatterns("/api/**").excludePathPatterns("/api/file/callback", "/api/file/notify/**", "/customer/**");
//授权拦截器
registry.addInterceptor(authInterceptor).addPathPatterns("/api/**").excludePathPatterns("/api/file/callback", "/api/file/notify/**", "/api/admin/**", "/customer/**");
//超级权限
registry.addInterceptor(adminInterceptor).addPathPatterns("/api/admin/**");
//管理权限
registry.addInterceptor(masterInterceptor).addPathPatterns("/api/master/**");
}
@Bean
public RestTemplate getRest() {
return new RestTemplate();
}
}