clean code
This commit is contained in:
parent
2e5f36a9c9
commit
c539c88c7c
|
|
@ -121,11 +121,11 @@ public class CommonService {
|
||||||
PATH_MAP.put(DataOwnEnum.REPO_PRJ.code, elePropertyConfig.getRepoPrjPath());
|
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;
|
return PATH_MAP.get(dataOwnCode) + File.separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEleDataPath(int dataOwnCode) {
|
public String getPrjRootPath(int dataOwnCode) {
|
||||||
|
|
||||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||||
return PATH_MAP.get(dataOwnCode) + File.separator + UserThreadLocal.getUserId() + File.separator;
|
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) {
|
public String getFileSysPath(String dbPath, int dataOwnCode) {
|
||||||
ArrayList<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
|
ArrayList<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
|
||||||
String path = getDbPath(paths);
|
String path = getDbPath(paths);
|
||||||
String destPath = getEleDataPath(dataOwnCode) + File.separator + path;
|
String destPath = getPrjRootPath(dataOwnCode) + File.separator + path;
|
||||||
return destPath.replace("//", "/");
|
return destPath.replace("//", "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,7 +262,7 @@ public class CommonService {
|
||||||
.setDataOwn(dataOwnCode);
|
.setDataOwn(dataOwnCode);
|
||||||
edFileInfoMapper.insert(fileInfo);
|
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);
|
fileSystemService.createDirectory(targetFilePath);
|
||||||
return ElectromagneticResultUtil.success(folderId);
|
return ElectromagneticResultUtil.success(folderId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -638,7 +638,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
sysFilePath.append(fileInfo.getFileName()).append(".").append(fileInfo.getFileType()).append(".").append(fileInfo.getFileCode());
|
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;
|
String sourcePath = prjDirPath + File.separator + sysFilePath;
|
||||||
fileSystemService.moveFile(sourcePath, destPath);
|
fileSystemService.moveFile(sourcePath, destPath);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
.setDataOwn(dataOwnCode);
|
.setDataOwn(dataOwnCode);
|
||||||
this.save(fileInfo);
|
this.save(fileInfo);
|
||||||
// 保存到文件系统
|
// 保存到文件系统
|
||||||
fileSystemService.createDirectory(commonService.getEleDataPath(dataOwnCode) + File.separator + prjName);
|
fileSystemService.createDirectory(commonService.getPrjRootPath(dataOwnCode) + File.separator + prjName);
|
||||||
UserThreadLocal.setSuccessInfo("", newPrjId, "创建 {} 项目成功。", prjName);
|
UserThreadLocal.setSuccessInfo("", newPrjId, "创建 {} 项目成功。", prjName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("工程 {} 创建失败,具体为--->{}", prjName, e.getMessage());
|
String info = StrFormatter.format("工程 {} 创建失败,具体为--->{}", prjName, e.getMessage());
|
||||||
|
|
@ -158,7 +158,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
return ElectromagneticResultUtil.fail("-1", info);
|
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)) {
|
if (fileSystemService.checkFolderExist(newPath)) {
|
||||||
String tmpPath = newPrjName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG;
|
String tmpPath = newPrjName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG;
|
||||||
fileSystemService.renameFile(newPath, tmpPath);
|
fileSystemService.renameFile(newPath, tmpPath);
|
||||||
|
|
@ -166,7 +166,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
|
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
.eq(EdFileInfo::getId, prjId)
|
.eq(EdFileInfo::getId, prjId)
|
||||||
.set(EdFileInfo::getFileName, newPrjName));
|
.set(EdFileInfo::getFileName, newPrjName));
|
||||||
fileSystemService.renameFile(commonService.getEleDataPath(dataOwnCode), oldPrjName, newPrjName);
|
fileSystemService.renameFile(commonService.getPrjRootPath(dataOwnCode), oldPrjName, newPrjName);
|
||||||
UserThreadLocal.setSuccessInfo("", prjId, "修改工层名 {} 为 {} 成功。", oldPrjName, newPrjName);
|
UserThreadLocal.setSuccessInfo("", prjId, "修改工层名 {} 为 {} 成功。", oldPrjName, newPrjName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("修改工程名异常--->{},{}", newPrjName, e.getMessage());
|
String info = StrFormatter.format("修改工程名异常--->{},{}", newPrjName, e.getMessage());
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,9 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
|
||||||
|
|
||||||
String destPath = "";
|
String destPath = "";
|
||||||
if (DataOwnEnum.isUserCode(edFileInfo.getDataOwn())) {
|
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 {
|
} 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("//", "/");
|
destPath = destPath.replace("//", "/");
|
||||||
log.info("back up file path is {}", destPath);
|
log.info("back up file path is {}", destPath);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue