heheng
2025-03-27 5d2cfd4562f74496a5263db3451c1e78ff53aead
assess-framework/src/main/java/com/gkhy/assess/framework/config/MyWebMvcConfig.java
@@ -1,6 +1,8 @@
package com.gkhy.assess.framework.config;
import com.gkhy.assess.framework.interceptor.LogInterceptor;
import com.gkhy.assess.framework.interceptor.RepeatSubmitInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@@ -12,12 +14,17 @@
@Configuration
// 指定要扫描的Mapper类的包的路径
@MapperScan("com.gkhy.**.mapper")
public class MyWebMvcConfig implements WebMvcConfigurer {
    @Value("${image.root_path}")
    private String uploadRootPath;
    @Value("${image.upload_path}")
    private String uploadPath;
    @Autowired
    private LogInterceptor logInterceptor;
    @Autowired
    private RepeatSubmitInterceptor repeatSubmitInterceptor;
    /**
     * 配置图片访问路径
@@ -26,13 +33,15 @@
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String systemDir=System.getProperty("user.dir");
        registry.addResourceHandler("/api/assess_file/**").addResourceLocations("file:"+systemDir+ File.separator+uploadRootPath+File.separator);
        registry.addResourceHandler("/upload/**").addResourceLocations("file:"+systemDir+ File.separator+uploadPath+File.separator);
      }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(logInterceptor)
                .addPathPatterns("/**");
        registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
    }
}