路径修改
This commit is contained in:
parent
e59a45b48b
commit
9689c1b3a7
|
|
@ -153,7 +153,7 @@ public class FileUploadUtils
|
|||
{
|
||||
int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
|
||||
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
||||
return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
||||
return "/" + fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.framework.config;
|
|||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.CacheControl;
|
||||
|
|
@ -27,6 +28,12 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|||
@Autowired
|
||||
private RepeatSubmitInterceptor repeatSubmitInterceptor;
|
||||
|
||||
/**
|
||||
* 上传文件存储在本地的根路径
|
||||
*/
|
||||
@Value("${file.path}")
|
||||
private String localFilePath;
|
||||
|
||||
// @Override
|
||||
// public void addResourceHandlers(ResourceHandlerRegistry registry)
|
||||
// {
|
||||
|
|
@ -42,11 +49,8 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/files/**").addResourceLocations("file:/usr/local/bonus/uploadPath"+ File.separator);
|
||||
//super.addResourceHandlers(registry);
|
||||
registry.addResourceHandler("/files/**").addResourceLocations("file:"+localFilePath+ File.separator);
|
||||
|
||||
// registry.addResourceHandler("/files/**").addResourceLocations("file:E:\\file\\");
|
||||
// super.addResourceHandlers(registry);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ public class LocalSysFileServiceImpl implements ISysFileService
|
|||
public TbFileSourceVo uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
String url = FileUploadUtils.upload(localFilePath, file);
|
||||
// String url = domain + localFilePrefix + name;
|
||||
String name = FileUtils.getName(url);
|
||||
String fileSuffix = FileUploadUtils.getExtension(file);
|
||||
return TbFileSourceVo.builder().filePath(url).fileName(name).fileSuffix(fileSuffix).build();
|
||||
|
|
@ -97,12 +96,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
|
|||
@Override
|
||||
public void deleteFile(String urlStr) throws Exception
|
||||
{
|
||||
// String regex = String.format("^(.*?%s)", localFilePrefix);
|
||||
// String updatePath = urlStr.replaceFirst(regex, localFilePath);
|
||||
// Path path = Paths.get(updatePath);
|
||||
String oldPart = "/profile/oadPath";
|
||||
String updatePath = urlStr.replace(oldPart, localFilePath);
|
||||
Path path = Paths.get(updatePath);
|
||||
Path path = Paths.get(localFilePath+urlStr);
|
||||
if (Files.exists(path)){
|
||||
try {
|
||||
Files.deleteIfExists(path);
|
||||
|
|
|
|||
2
pom.xml
2
pom.xml
|
|
@ -8,7 +8,7 @@
|
|||
<artifactId>search_tool_service</artifactId>
|
||||
<version>3.8.9</version>
|
||||
|
||||
<name>ruoyi</name>
|
||||
<name>bonus</name>
|
||||
<url>http://www.ruoyi.vip</url>
|
||||
<description>若依管理系统</description>
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,8 @@ public class EpcServiceImpl implements EpcService {
|
|||
}
|
||||
}
|
||||
|
||||
@Value("file.path")
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.bonus.tool.service.StateGridService;
|
|||
import com.bonus.tool.template.util.FreeMarkerUtil;
|
||||
import com.bonus.tool.template.util.WordUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -264,9 +265,14 @@ public class StateGridServiceImpl implements StateGridService {
|
|||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Value("file.path")
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String bast64= FreeMarkerUtil.getImageBase("F:\\File\\tool\\2025\\05\\07\\3_20250507104937A005.png");
|
||||
System.err.println(bast64);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将数据转换为模版数据
|
||||
|
|
@ -312,7 +318,8 @@ public class StateGridServiceImpl implements StateGridService {
|
|||
imgMap.put("index", 100 * index + imgIndex++);
|
||||
imgMap.put("width", "5325745");
|
||||
imgMap.put("height", "7534910");
|
||||
imgMap.put("base64Url", file.getFilePath() != null ? FreeMarkerUtil.getImageBase(filePath+file.getFilePath()) : "");
|
||||
String bast64=FreeMarkerUtil.getImageBase(filePath+file.getFilePath());
|
||||
imgMap.put("base64Url", file.getFilePath() != null ? bast64: "");
|
||||
imgList.add(imgMap);
|
||||
}
|
||||
perfImgMap.put("imgList", imgList);
|
||||
|
|
@ -321,6 +328,7 @@ public class StateGridServiceImpl implements StateGridService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// 处理分包商数据(核心分包商业绩证明)
|
||||
if (tbData.getSubList() != null && !tbData.getSubList().isEmpty()) {
|
||||
int subIndex = 1;
|
||||
|
|
|
|||
|
|
@ -133,5 +133,5 @@ xss:
|
|||
|
||||
file:
|
||||
domain: http://192.168.0.14:58089
|
||||
path: /usr/local/bonus/uploadPath
|
||||
path: F:\File\tool
|
||||
prefix: /statics
|
||||
|
|
|
|||
Loading…
Reference in New Issue