This commit is contained in:
马三炮 2025-04-30 17:13:03 +08:00
parent 67af9e28ca
commit dbf3ba0d24
3 changed files with 40 additions and 24 deletions

View File

@ -1,5 +1,6 @@
package com.bonus.framework.config; package com.bonus.framework.config;
import java.io.File;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -26,17 +27,26 @@ public class ResourcesConfig implements WebMvcConfigurer
@Autowired @Autowired
private RepeatSubmitInterceptor repeatSubmitInterceptor; private RepeatSubmitInterceptor repeatSubmitInterceptor;
@Override // @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) // public void addResourceHandlers(ResourceHandlerRegistry registry)
{ // {
/** 本地文件上传路径 */ // /** 本地文件上传路径 */
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**") // registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
.addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); // .addResourceLocations("file:" + "/usr/local/bonus/uploadPath/" + "/");
//
// /** swagger配置 */
// registry.addResourceHandler("/swagger-ui/**")
// .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
// .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());
// }
/** swagger配置 */ @Override
registry.addResourceHandler("/swagger-ui/**") public void addResourceHandlers(ResourceHandlerRegistry registry) {
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") registry.addResourceHandler("/files/**").addResourceLocations("file:/usr/local/bonus/uploadPath"+ File.separator);
.setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic()); //super.addResourceHandlers(registry);
// registry.addResourceHandler("/files/**").addResourceLocations("file:E:\\file\\");
// super.addResourceHandlers(registry);
} }
/** /**

View File

@ -218,6 +218,9 @@ public class TokenService
private String getToken(HttpServletRequest request) private String getToken(HttpServletRequest request)
{ {
String token = request.getHeader(header); String token = request.getHeader(header);
if(StringUtils.isEmpty(token)){
token=request.getParameter("file_token");
}
if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX))
{ {
token = token.replace(Constants.TOKEN_PREFIX, ""); token = token.replace(Constants.TOKEN_PREFIX, "");

View File

@ -16,7 +16,7 @@ ruoyi:
# 开发环境配置 # 开发环境配置
server: server:
# 服务器的HTTP端口默认为8080 # 服务器的HTTP端口默认为8080
port: 58080 port: 58089
servlet: servlet:
# 应用的访问路径 # 应用的访问路径
context-path: / context-path: /
@ -68,13 +68,13 @@ spring:
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址
host: localhost host: 192.168.0.7
# 端口默认为6379 # 端口默认为6379
port: 6379 port: 16379
# 数据库索引 # 数据库索引
database: 0 database: 6
# 密码 # 密码
password: password: Bonus@admin123!
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s
lettuce: lettuce:
@ -87,6 +87,9 @@ spring:
max-active: 8 max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制) # #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms max-wait: -1ms
web:
resources:
static-locations: file:/usr/local/bonus//uploadPath/
# token配置 # token配置
token: token:
@ -129,6 +132,6 @@ xss:
urlPatterns: /system/*,/monitor/*,/tool/* urlPatterns: /system/*,/monitor/*,/tool/*
file: file:
domain: http://192.168.0.60:58080 domain: http://192.168.0.14:58089
path: /usr/local/bonus/uploadPath path: /usr/local/bonus/uploadPath
prefix: /statics prefix: /statics