办学质量监测教学评价系统
ageer
2024-05-17 7fe89a931b291196b0b571c668bd3758309019d7
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
package spring.config;
 
import cn.hutool.core.text.CharSequenceUtil;
import com.xmzs.midjourney.ProxyProperties;
import com.xmzs.midjourney.support.ApiAuthorizeInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    private ApiAuthorizeInterceptor apiAuthorizeInterceptor;
    @Resource
    private ProxyProperties properties;
 
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("redirect:doc.html");
    }
 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        if (CharSequenceUtil.isNotBlank(this.properties.getApiSecret())) {
            registry.addInterceptor(this.apiAuthorizeInterceptor)
                    .addPathPatterns("/mj/submit/**", "/mj/task/**", "/mj/account/**");
        }
    }
 
}