替换strUtil.BACKSLASH为FileUtil.FILE_SEPARATOR

This commit is contained in:
cuizhibin 2025-05-19 10:27:23 +08:00
parent 4639da5dc5
commit 9d2cf4c916
1 changed files with 4 additions and 4 deletions

View File

@ -82,8 +82,8 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
Map<String, PartEntity> partIdMap= partService.listByIds(partIds).stream().collect(Collectors.toMap(PartEntity::getPartId, Function.identity())); Map<String, PartEntity> partIdMap= partService.listByIds(partIds).stream().collect(Collectors.toMap(PartEntity::getPartId, Function.identity()));
list.stream().forEach(req -> { list.stream().forEach(req -> {
if(partIdMap.containsKey(req.getPartId())){ if(partIdMap.containsKey(req.getPartId())){
String path_prefix = permPath.concat(StrUtil.BACKSLASH).concat(req.getImageSource()).concat(StrUtil.BACKSLASH).concat(req.getPartId()).concat(StrUtil.BACKSLASH); String path_prefix = permPath.concat(FileUtil.FILE_SEPARATOR).concat(req.getImageSource()).concat(FileUtil.FILE_SEPARATOR).concat(req.getPartId()).concat(FileUtil.FILE_SEPARATOR);
String temp_path_prefix = tempPath.concat(StrUtil.BACKSLASH).concat(req.getImageSource()).concat(StrUtil.BACKSLASH).concat(req.getPartId()).concat(StrUtil.BACKSLASH); String temp_path_prefix = tempPath.concat(FileUtil.FILE_SEPARATOR).concat(req.getImageSource()).concat(FileUtil.FILE_SEPARATOR).concat(req.getPartId()).concat(FileUtil.FILE_SEPARATOR);
File file = new File(req.getImagePath()); File file = new File(req.getImagePath());
if(file.exists() && req.getImagePath().contains(temp_path_prefix)){ if(file.exists() && req.getImagePath().contains(temp_path_prefix)){
ImageEntity entity = new ImageEntity(); ImageEntity entity = new ImageEntity();
@ -122,7 +122,7 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
throw new ServiceException(Message.IMAGE_IS_EMPTY); throw new ServiceException(Message.IMAGE_IS_EMPTY);
} }
List<ImageReq> list = new ArrayList<>(files.length); List<ImageReq> list = new ArrayList<>(files.length);
String path_prefix = tempPath.concat(StrUtil.BACKSLASH).concat(imageSource).concat(StrUtil.BACKSLASH).concat(partId).concat(StrUtil.BACKSLASH); String path_prefix = tempPath.concat(FileUtil.FILE_SEPARATOR).concat(imageSource).concat(FileUtil.FILE_SEPARATOR).concat(partId).concat(FileUtil.FILE_SEPARATOR);
for (MultipartFile file : files) { for (MultipartFile file : files) {
if (!file.isEmpty()) { if (!file.isEmpty()) {
try { try {
@ -147,7 +147,7 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
throw new ServiceException(Message.IMAGE_SOURCE_ID_NOT_EXIST_OR_ILLEGAL); throw new ServiceException(Message.IMAGE_SOURCE_ID_NOT_EXIST_OR_ILLEGAL);
} }
String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
String path_prefix = permPath.concat(StrUtil.BACKSLASH).concat(imageSource).concat(StrUtil.BACKSLASH).concat(dateStr).concat(StrUtil.BACKSLASH); String path_prefix = permPath.concat(FileUtil.FILE_SEPARATOR).concat(dateStr).concat(FileUtil.FILE_SEPARATOR).concat(imageSource).concat(FileUtil.FILE_SEPARATOR);
String path = path_prefix + file.getOriginalFilename(); String path = path_prefix + file.getOriginalFilename();
FileUtil.writeBytes(file.getBytes(),path); FileUtil.writeBytes(file.getBytes(),path);
return path; return path;