修改测试的bug
This commit is contained in:
parent
0c1062f9b8
commit
88e6f8f9d6
|
|
@ -51,8 +51,8 @@ public class ProjectController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("deleteFolder")
|
@RequestMapping("deleteFolder")
|
||||||
public ElectromagneticResult<?> deleteFolder(@RequestParam String fileId) {
|
public ElectromagneticResult<?> deleteFolder(@RequestParam String id, @RequestParam String parentId) {
|
||||||
return edFileInfoService.deleteFolder(fileId);
|
return edFileInfoService.deleteFolder(id, parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("folderResort")
|
@RequestMapping("folderResort")
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,10 @@ public interface EdFileInfoService {
|
||||||
* 删除子集
|
* 删除子集
|
||||||
*
|
*
|
||||||
* @param fileId
|
* @param fileId
|
||||||
|
* @param parentId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ElectromagneticResult<?> deleteFolder(String fileId);
|
ElectromagneticResult<?> deleteFolder(String fileId, String parentId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 层级沿用
|
* 层级沿用
|
||||||
|
|
|
||||||
|
|
@ -361,10 +361,12 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
* 删除子集
|
* 删除子集
|
||||||
*
|
*
|
||||||
* @param fileId
|
* @param fileId
|
||||||
|
* @param parentId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> deleteFolder(String fileId) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ElectromagneticResult<?> deleteFolder(String fileId, String parentId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO是否需要判断文件夹是否为空
|
// TODO是否需要判断文件夹是否为空
|
||||||
|
|
@ -380,25 +382,20 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.set(EdFileInfo::getSort, -1)
|
.set(EdFileInfo::getSort, -1)
|
||||||
.in(EdFileInfo::getId, ids);
|
.in(EdFileInfo::getId, ids);
|
||||||
this.baseMapper.update(null, updateWrapper);
|
this.baseMapper.update(null, updateWrapper);
|
||||||
|
|
||||||
String[] tmpFileIds = edFileInfos.get(0).getFilePath().split(MYSQL_FILE_PATH_SPLIT);
|
|
||||||
String parentId = tmpFileIds[0];
|
|
||||||
for (String tmpPathId : tmpFileIds) {
|
|
||||||
parentId = this.baseMapper.maxPrjId();
|
|
||||||
if (fileId.equals(tmpPathId)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 同层级的resort
|
// 同层级的resort
|
||||||
List<EdFileInfo> edFileInfos1 = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
List<EdFileInfo> edFileInfos1 = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo::getId, EdFileInfo::getSort)
|
.select(EdFileInfo::getId, EdFileInfo::getSort)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.eq(EdFileInfo::getParentId, parentId)
|
.eq(EdFileInfo::getParentId, parentId)
|
||||||
.orderByAsc(EdFileInfo::getSort));
|
.orderByAsc(EdFileInfo::getSort));
|
||||||
for (int i = 1; i <= edFileInfos1.size(); i++) {
|
Date now = new Date();
|
||||||
|
String currentUserId = UserThreadLocal.getUserId();
|
||||||
|
for (int i = 0; i < edFileInfos1.size(); i++) {
|
||||||
String id = edFileInfos1.get(i).getId();
|
String id = edFileInfos1.get(i).getId();
|
||||||
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
.set(EdFileInfo::getSort, i)
|
.set(EdFileInfo::getSort, i + 1)
|
||||||
|
.set(EdFileInfo::getUpdatedBy, currentUserId)
|
||||||
|
.set(EdFileInfo::getUpdateTime, now)
|
||||||
.eq(EdFileInfo::getId, id));
|
.eq(EdFileInfo::getId, id));
|
||||||
}
|
}
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
|
|
@ -465,7 +462,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.setCreatedBy(currentUserId)
|
.setCreatedBy(currentUserId)
|
||||||
.setUpdatedBy(currentUserId);
|
.setUpdatedBy(currentUserId);
|
||||||
this.save(targetFile);
|
this.save(targetFile);
|
||||||
String targetSysFilePath = getSysFilePathByDbPath(targetFile.getFilePath()) + File.separator + sourceFileName;
|
String targetSysFilePath = getFileSysPath(targetFile.getFilePath()) + File.separator + sourceFileName;
|
||||||
fileSystemService.createDirectory(targetSysFilePath);
|
fileSystemService.createDirectory(targetSysFilePath);
|
||||||
targetEdFileInfos = this.baseMapper.selectAllAdminFolder(targetId);
|
targetEdFileInfos = this.baseMapper.selectAllAdminFolder(targetId);
|
||||||
}
|
}
|
||||||
|
|
@ -487,25 +484,32 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ElectromagneticResult<?> modifyFolder(String id, String newFolderName) {
|
public ElectromagneticResult<?> modifyFolder(String id, String newFolderName) {
|
||||||
try {
|
try {
|
||||||
|
String currentUserId = UserThreadLocal.getUserId();
|
||||||
|
Date now = new Date();
|
||||||
EdFileInfo fileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
|
EdFileInfo fileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.eq(EdFileInfo::getId, id));
|
.eq(EdFileInfo::getId, id));
|
||||||
String sysFilePath = getSysFilePathByDbPath(fileInfo.getFilePath());
|
String sysFilePath = getFileSysPath(fileInfo.getFilePath());
|
||||||
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
|
.set(EdFileInfo::getUpdateTime, now)
|
||||||
|
.set(EdFileInfo::getUpdatedBy, currentUserId)
|
||||||
|
.eq(EdFileInfo::getId, id)
|
||||||
.set(EdFileInfo::getFileName, newFolderName));
|
.set(EdFileInfo::getFileName, newFolderName));
|
||||||
fileSystemService.renameFile(sysFilePath, newFolderName);
|
fileSystemService.renameFile(sysFilePath, newFolderName);
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("修改子集名称为{}失败", newFolderName);
|
String info = StrFormatter.format("修改子集名称为{}失败", newFolderName);
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
return ElectromagneticResultUtil.fail("-1", info);
|
throw new BizException(-1, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSysFilePathByDbPath(String dbPath) {
|
private String getFileSysPath(String dbPath) {
|
||||||
ArrayList<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
|
ArrayList<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
|
||||||
return getPath(paths);
|
String path = getPath(paths);
|
||||||
|
return eleDataPath + File.separator + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPath(List<String> ids) {
|
private String getPath(List<String> ids) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue