优化相关功能

This commit is contained in:
chenxudong 2025-02-26 15:07:24 +08:00
parent 58e4c4397d
commit 545188be69
3 changed files with 15 additions and 1 deletions

View File

@ -421,4 +421,15 @@ public class CommonService {
} }
} }
public String getLastPrjLeafId(String path) {
String[] split = path.split(MYSQL_FILE_PATH_SPLIT);
for (int i = split.length - 1; i >= 0; i--) {
if (split[i].length() < 19) {
return split[i];
}
}
return "";
}
} }

View File

@ -316,7 +316,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.set(EdFileInfo::getFileNote, updateFileInfoDTO.getFileNote())); .set(EdFileInfo::getFileNote, updateFileInfoDTO.getFileNote()));
String newName = updateFileInfoDTO.getFileName() + "." + fileInfo.getFileType() + "." + fileInfo.getFileCode(); String newName = updateFileInfoDTO.getFileName() + "." + fileInfo.getFileType() + "." + fileInfo.getFileCode();
fileSystemService.renameFile(srcFilePath, newName); fileSystemService.renameFile(srcFilePath, newName);
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), updateFileInfoDTO.getId(), "更新文件信息成功,新文件名为 {}", newFileName); UserThreadLocal.setSuccessInfo(commonService.getLastPrjLeafId(fileInfo.getFilePath()), updateFileInfoDTO.getId(), "更新文件信息成功,新文件名为 {}.{}", newFileName, fileInfo.getFileType());
return ElectromagneticResultUtil.success(true); return ElectromagneticResultUtil.success(true);
} catch (Exception e) { } catch (Exception e) {
String info = StrFormatter.format("更新文件信息失败,新文件名 {} 原因 {}", newFileName, e.getMessage()); String info = StrFormatter.format("更新文件信息失败,新文件名 {} 原因 {}", newFileName, e.getMessage());

View File

@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.common.util;
import cn.hutool.core.text.StrFormatter; import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.util.StrUtil;
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo; import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult; import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
@ -52,6 +53,8 @@ public class UserThreadLocal {
} }
public static void setSuccessInfo(String parentId, String dataId, String strPattern, Object... argArray) { public static void setSuccessInfo(String parentId, String dataId, String strPattern, Object... argArray) {
parentId = StrUtil.isEmpty(parentId) ? "" : parentId;
dataId = StrUtil.isEmpty(dataId) ? "" : dataId;
String successMsg = StrFormatter.format(strPattern, argArray); String successMsg = StrFormatter.format(strPattern, argArray);
userThread.get().setSuccessInfo(parentId, successMsg, dataId); userThread.get().setSuccessInfo(parentId, successMsg, dataId);
} }