|
|
@@ -2,7 +2,6 @@ package top.lvzhiqiang.config;
|
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
-import org.springframework.core.annotation.Order;
|
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
@@ -14,6 +13,7 @@ import javax.annotation.Resource;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 静态资源过滤配置器
|
|
|
@@ -44,14 +44,17 @@ public class WebAppConfig implements WebMvcConfigurer {
|
|
|
|
|
|
// 初始化字典码表
|
|
|
dicCodeList = dicCodeMapper.findAll();
|
|
|
- DicCode dicCode4Qibing = dicCodeList.stream().filter(x -> 1 == x.getType() && "qibing_path".equals(x.getCodeKey())).findFirst().get();
|
|
|
- DicCode dicCode4Machi = dicCodeList.stream().filter(x -> 1 == x.getType() && "machi_path".equals(x.getCodeKey())).findFirst().get();
|
|
|
- String qibingPath = "F:/1/0/2/4/视频/电影/A级(成人级)/骑兵/";
|
|
|
- if (dicCode4Qibing != null) {
|
|
|
- qibingPath = dicCode4Qibing.getCodeValue();
|
|
|
+ List<DicCode> dicCodeList = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType()).collect(Collectors.toList());
|
|
|
+ for (DicCode dicCode : dicCodeList) {
|
|
|
+ StringBuffer resourceHandlerSB = new StringBuffer("/");
|
|
|
+ resourceHandlerSB.append(dicCode.getCodeKey().split("_")[0]).append("/**");
|
|
|
+
|
|
|
+ List<String> resourceLocationsList = new ArrayList<>();
|
|
|
+ for (String s : dicCode.getCodeValue().split(",")) {
|
|
|
+ resourceLocationsList.add("file:".concat(s));
|
|
|
+ }
|
|
|
+ registry.addResourceHandler(resourceHandlerSB.toString()).addResourceLocations(resourceLocationsList.toArray(new String[resourceLocationsList.size()]));
|
|
|
}
|
|
|
- registry.addResourceHandler("/qibing/**").addResourceLocations("file:" + qibingPath);
|
|
|
- registry.addResourceHandler("/machi/**").addResourceLocations("file:" + dicCode4Machi.getCodeValue());
|
|
|
}
|
|
|
|
|
|
@Bean
|