|
@@ -8,10 +8,13 @@ import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.format.FormatterRegistry;
|
|
|
import org.springframework.http.MediaType;
|
|
|
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
import com.keao.edu.common.config.EnumConverterFactory;
|
|
|
import com.keao.edu.common.config.LocalFastJsonHttpMessageConverter;
|
|
|
+import com.keao.edu.common.tenant.TenantInterceptor;
|
|
|
+import com.keao.edu.datasource.interceptor.DataSourceInterceptor;
|
|
|
|
|
|
@Configuration
|
|
|
public class WebMvcConfig implements WebMvcConfigurer {
|
|
@@ -23,6 +26,23 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
public void addFormatters(FormatterRegistry registry) {
|
|
|
registry.addConverterFactory(new EnumConverterFactory());
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addInterceptors(InterceptorRegistry registry) {
|
|
|
+
|
|
|
+ registry.addInterceptor(getDataSrouceInterceptor()).addPathPatterns("/**");
|
|
|
+ registry.addInterceptor(getTenantInterceptor()).addPathPatterns("/**");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public DataSourceInterceptor getDataSrouceInterceptor() {
|
|
|
+ return new DataSourceInterceptor();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public TenantInterceptor getTenantInterceptor() {
|
|
|
+ return new TenantInterceptor();
|
|
|
+ }
|
|
|
|
|
|
@Bean
|
|
|
public HttpMessageConverters fastJsonHttpMessageConverters(){
|