解决发现的问题
This commit is contained in:
parent
98ed6eafdb
commit
8dab45c624
|
|
@ -126,15 +126,6 @@ public class CommonService {
|
|||
return PATH_MAP.get(dataOwnCode) + File.separator;
|
||||
}
|
||||
|
||||
public String getPrjRootPath(int dataOwnCode) {
|
||||
|
||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
return PATH_MAP.get(dataOwnCode) + File.separator + UserThreadLocal.getUserId() + File.separator;
|
||||
}
|
||||
|
||||
return PATH_MAP.get(dataOwnCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查同层级是否有同名的文件夹
|
||||
*/
|
||||
|
|
@ -152,7 +143,13 @@ 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 = getPrjRootPath(dataOwnCode) + File.separator + path;
|
||||
String destPath;
|
||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
EdFileInfo prjFileInfo = edFileInfoMapper.selectById(paths.get(0));
|
||||
destPath = getPrjRootPath1(dataOwnCode) + prjFileInfo.getCreatedBy() + File.separator + path;
|
||||
} else {
|
||||
destPath = getPrjRootPath1(dataOwnCode) + File.separator + path;
|
||||
}
|
||||
return destPath.replace("//", "/");
|
||||
}
|
||||
|
||||
|
|
@ -263,7 +260,12 @@ public class CommonService {
|
|||
.setDataOwn(dataOwnCode);
|
||||
edFileInfoMapper.insert(fileInfo);
|
||||
// 保存到文件系统
|
||||
String targetFilePath = getPrjRootPath(dataOwnCode) + File.separator + getDbPath(paths) + File.separator + folderName;
|
||||
String targetFilePath;
|
||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
targetFilePath = getPrjRootPath1(dataOwnCode) + File.separator + UserThreadLocal.getUserId() + File.separator + getDbPath(paths) + File.separator + folderName;
|
||||
} else {
|
||||
targetFilePath = getPrjRootPath1(dataOwnCode) + File.separator + getDbPath(paths) + File.separator + folderName;
|
||||
}
|
||||
fileSystemService.createDirectory(targetFilePath);
|
||||
return ElectromagneticResultUtil.success(folderId);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -646,7 +646,12 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
sysFilePath.append(fileInfo.getFileName()).append(".").append(fileInfo.getFileType()).append(".").append(fileInfo.getFileCode());
|
||||
}
|
||||
}
|
||||
String destPath = commonService.getPrjRootPath(dataOwnCode) + File.separator + sysFilePath;
|
||||
String destPath;
|
||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
destPath = commonService.getPrjRootPath1(dataOwnCode) + UserThreadLocal.getUserId() + File.separator + sysFilePath;
|
||||
} else {
|
||||
destPath = commonService.getPrjRootPath1(dataOwnCode) + File.separator + sysFilePath;
|
||||
}
|
||||
String sourcePath = prjDirPath + File.separator + sysFilePath;
|
||||
fileSystemService.moveFile(sourcePath, destPath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,13 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
.setDataOwn(dataOwnCode);
|
||||
this.save(fileInfo);
|
||||
// 保存到文件系统
|
||||
fileSystemService.createDirectory(commonService.getPrjRootPath(dataOwnCode) + File.separator + prjName);
|
||||
String prjPath;
|
||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
prjPath = commonService.getPrjRootPath1(dataOwnCode) + File.separator + UserThreadLocal.getUserId() + File.separator + prjName;
|
||||
} else {
|
||||
prjPath = commonService.getPrjRootPath1(dataOwnCode) + File.separator + prjName;
|
||||
}
|
||||
fileSystemService.createDirectory(prjPath);
|
||||
UserThreadLocal.setSuccessInfo("", newPrjId, "创建 {} 项目成功。", prjName);
|
||||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("工程 {} 创建失败,具体为--->{}", prjName, e.getMessage());
|
||||
|
|
@ -158,7 +164,12 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
}
|
||||
|
||||
String newPath = commonService.getPrjRootPath(dataOwnCode) + File.separator + newPrjName;
|
||||
String newPath;
|
||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
newPath = commonService.getPrjRootPath1(dataOwnCode) + File.separator + UserThreadLocal.getUserId() + File.separator + newPrjName;
|
||||
} else {
|
||||
newPath = commonService.getPrjRootPath1(dataOwnCode) + File.separator + newPrjName;
|
||||
}
|
||||
if (fileSystemService.checkFolderExist(newPath)) {
|
||||
String tmpPath = newPrjName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG;
|
||||
fileSystemService.renameFile(newPath, tmpPath);
|
||||
|
|
@ -166,7 +177,15 @@ 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.getPrjRootPath(dataOwnCode), oldPrjName, newPrjName);
|
||||
|
||||
String prjPath;
|
||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
prjPath = commonService.getPrjRootPath1(dataOwnCode) + File.separator + UserThreadLocal.getUserId() + File.separator;
|
||||
} else {
|
||||
prjPath = commonService.getPrjRootPath1(dataOwnCode) + File.separator;
|
||||
}
|
||||
|
||||
fileSystemService.renameFile(prjPath, oldPrjName, newPrjName);
|
||||
UserThreadLocal.setSuccessInfo("", prjId, "修改工层名 {} 为 {} 成功。", oldPrjName, newPrjName);
|
||||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("修改工程名异常--->{},{}", newPrjName, e.getMessage());
|
||||
|
|
@ -229,9 +248,17 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
public ElectromagneticResult<?> addFolder(String parentId, String folderName, int dataOwnCode) {
|
||||
Assert.isTrue(EleCommonUtil.isFileNameValid(folderName), NAME_VALID_MSG);
|
||||
// 检查当前目录下有文件,如果有则不允许添加
|
||||
long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getParentId, parentId)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
|
||||
|
||||
queryWrapper.and(qr -> qr.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_FILE.code)
|
||||
.or()
|
||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_FILE.code)
|
||||
.or()
|
||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_FILE.code));
|
||||
|
||||
long count = this.baseMapper.selectCount(queryWrapper);
|
||||
|
||||
if (count > 0) {
|
||||
return ElectromagneticResultUtil.fail("-1", StrFormatter.format("该层级目录下存在文件或者文件夹,不允许再定义层级目录。父目录id {},子集名称 {}", parentId, folderName));
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
|||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -14,6 +15,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class BackupHandler {
|
||||
|
||||
@Resource
|
||||
|
|
@ -24,6 +26,7 @@ public class BackupHandler {
|
|||
map.put("file", new File(filePath));
|
||||
map.put("id", id);
|
||||
String url = StrFormatter.format("http://{}:{}/data/file/backup/upload", elePropertyConfig.getRemoteHost(), elePropertyConfig.getRemotePort());
|
||||
log.info("back up url is {}", url);
|
||||
String res = HttpUtil.post(url, map);
|
||||
ElectromagneticResult<?> resObj = JSONUtil.toBean(res, ElectromagneticResult.class);
|
||||
String data = JSONUtil.toJsonStr(resObj.getData());
|
||||
|
|
|
|||
Loading…
Reference in New Issue