fuliqi
2024-10-17 8546b3d285af4235a0ef615a0c6e89486ae2c806
src/main/java/com/ycl/jxkg/config/spring/mvc/WebMvcConfiguration.java
@@ -1,11 +1,13 @@
package com.ycl.jxkg.config.spring.mvc;
import com.ycl.jxkg.config.RuoYiConfig;
import com.ycl.jxkg.config.property.SystemConfig;
import com.ycl.jxkg.config.spring.wx.TokenHandlerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
import java.io.File;
import java.util.List;
@@ -20,6 +22,7 @@
    private final TokenHandlerInterceptor tokenHandlerInterceptor;
    private final SystemConfig systemConfig;
    private final RuoYiConfig ruoYiConfig;
    /**
     * Instantiates a new Web mvc configuration.
@@ -28,9 +31,10 @@
     * @param systemConfig            the system config
     */
    @Autowired
    public WebMvcConfiguration(TokenHandlerInterceptor tokenHandlerInterceptor, SystemConfig systemConfig) {
    public WebMvcConfiguration(TokenHandlerInterceptor tokenHandlerInterceptor, SystemConfig systemConfig, RuoYiConfig ruoYiConfig) {
        this.tokenHandlerInterceptor = tokenHandlerInterceptor;
        this.systemConfig = systemConfig;
        this.ruoYiConfig = ruoYiConfig;
    }
    @Override
@@ -42,6 +46,8 @@
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/api/files" + "/**")
                .addResourceLocations("file:" + ruoYiConfig.getUrl() + File.separator);
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/static/")
                .setCachePeriod(31556926);