clean code

This commit is contained in:
chenxudong 2025-03-27 17:34:52 +08:00
parent 2e5f36a9c9
commit c539c88c7c
4 changed files with 10 additions and 10 deletions

View File

@ -121,11 +121,11 @@ public class CommonService {
PATH_MAP.put(DataOwnEnum.REPO_PRJ.code, elePropertyConfig.getRepoPrjPath());
}
public String getPrjPath(int dataOwnCode) {
public String getPrjRootPath1(int dataOwnCode) {
return PATH_MAP.get(dataOwnCode) + File.separator;
}
public String getEleDataPath(int dataOwnCode) {
public String getPrjRootPath(int dataOwnCode) {
if (DataOwnEnum.isUserCode(dataOwnCode)) {
return PATH_MAP.get(dataOwnCode) + File.separator + UserThreadLocal.getUserId() + File.separator;
@ -151,7 +151,7 @@ public class CommonService {
public String getFileSysPath(String dbPath, int dataOwnCode) {
ArrayList<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
String path = getDbPath(paths);
String destPath = getEleDataPath(dataOwnCode) + File.separator + path;
String destPath = getPrjRootPath(dataOwnCode) + File.separator + path;
return destPath.replace("//", "/");
}
@ -262,7 +262,7 @@ public class CommonService {
.setDataOwn(dataOwnCode);
edFileInfoMapper.insert(fileInfo);
// 保存到文件系统
String targetFilePath = getEleDataPath(dataOwnCode) + File.separator + getDbPath(paths) + File.separator + folderName;
String targetFilePath = getPrjRootPath(dataOwnCode) + File.separator + getDbPath(paths) + File.separator + folderName;
fileSystemService.createDirectory(targetFilePath);
return ElectromagneticResultUtil.success(folderId);
} catch (Exception e) {

View File

@ -638,7 +638,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
sysFilePath.append(fileInfo.getFileName()).append(".").append(fileInfo.getFileType()).append(".").append(fileInfo.getFileCode());
}
}
String destPath = commonService.getEleDataPath(dataOwnCode) + File.separator + sysFilePath;
String destPath = commonService.getPrjRootPath(dataOwnCode) + File.separator + sysFilePath;
String sourcePath = prjDirPath + File.separator + sysFilePath;
fileSystemService.moveFile(sourcePath, destPath);
}

View File

@ -121,7 +121,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
.setDataOwn(dataOwnCode);
this.save(fileInfo);
// 保存到文件系统
fileSystemService.createDirectory(commonService.getEleDataPath(dataOwnCode) + File.separator + prjName);
fileSystemService.createDirectory(commonService.getPrjRootPath(dataOwnCode) + File.separator + prjName);
UserThreadLocal.setSuccessInfo("", newPrjId, "创建 {} 项目成功。", prjName);
} catch (Exception e) {
String info = StrFormatter.format("工程 {} 创建失败,具体为--->{}", prjName, e.getMessage());
@ -158,7 +158,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
return ElectromagneticResultUtil.fail("-1", info);
}
String newPath = commonService.getEleDataPath(dataOwnCode) + File.separator + newPrjName;
String newPath = commonService.getPrjRootPath(dataOwnCode) + File.separator + newPrjName;
if (fileSystemService.checkFolderExist(newPath)) {
String tmpPath = newPrjName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG;
fileSystemService.renameFile(newPath, tmpPath);
@ -166,7 +166,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getId, prjId)
.set(EdFileInfo::getFileName, newPrjName));
fileSystemService.renameFile(commonService.getEleDataPath(dataOwnCode), oldPrjName, newPrjName);
fileSystemService.renameFile(commonService.getPrjRootPath(dataOwnCode), oldPrjName, newPrjName);
UserThreadLocal.setSuccessInfo("", prjId, "修改工层名 {} 为 {} 成功。", oldPrjName, newPrjName);
} catch (Exception e) {
String info = StrFormatter.format("修改工程名异常--->{}{}", newPrjName, e.getMessage());

View File

@ -75,9 +75,9 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
String destPath = "";
if (DataOwnEnum.isUserCode(edFileInfo.getDataOwn())) {
destPath = commonService.getPrjPath(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getCreatedBy() + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getCreatedBy() + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
} else {
destPath = commonService.getPrjPath(edFileInfo.getDataOwn()) + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
}
destPath = destPath.replace("//", "/");
log.info("back up file path is {}", destPath);