增加异常处理相关逻辑。
This commit is contained in:
parent
e76449212e
commit
1b4492e812
|
|
@ -0,0 +1,32 @@
|
|||
package com.electromagnetic.industry.software.manage.common;
|
||||
|
||||
import com.electromagnetic.industry.software.common.exception.BizException;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ResponseBody
|
||||
public ElectromagneticResult<?> runTimeError(Throwable e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return ElectromagneticResultUtil.fail("-1", e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(BizException.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ResponseBody
|
||||
public ElectromagneticResult<?> bizError(BizException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return ElectromagneticResultUtil.fail("-1", e.getMsg());
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,9 @@ public interface FileSystemService {
|
|||
|
||||
void save(InputStream inputStream, String destination);
|
||||
|
||||
void renameFile(String sourcePath, String oldName, String newName);
|
||||
void renameFile(String sourcePath, String newName);
|
||||
|
||||
void renameFile(String sourcePath, String sourceName, String newName);
|
||||
|
||||
boolean checkFolderExist(String newPath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||
|
|
@ -17,6 +16,7 @@ import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
|||
import com.electromagnetic.industry.software.common.enums.EleDataSaveStatusEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.EleDataStatusEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
||||
import com.electromagnetic.industry.software.common.exception.BizException;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.*;
|
||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||
|
|
@ -121,7 +121,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("文件创建失败,具体为--->{}", e.getMessage());
|
||||
log.error(info, e);
|
||||
return ElectromagneticResultUtil.fail("-1", e.getMessage());
|
||||
throw new BizException(-1, info);
|
||||
}
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("修改工程名异常--->{},{}", newPrjName, e.getMessage());
|
||||
log.error(info, e);
|
||||
throw new RuntimeException(e);
|
||||
throw new BizException(-1, info);
|
||||
}
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
|
@ -163,17 +163,23 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> delete(String prjId) {
|
||||
|
||||
List<String> ids = new ArrayList<>();
|
||||
ids.add(prjId);
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId)
|
||||
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT);
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
|
||||
edFileInfos.forEach(e -> ids.add(e.getId()));
|
||||
Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
try {
|
||||
List<String> ids = new ArrayList<>();
|
||||
ids.add(prjId);
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId)
|
||||
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT);
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
|
||||
edFileInfos.forEach(e -> ids.add(e.getId()));
|
||||
Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
String info = "删除项目失败";
|
||||
log.error(info, e);
|
||||
throw new BizException(-1, info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -219,32 +225,38 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
}
|
||||
|
||||
int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
||||
Date now = new Date();
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
String newFolderId = String.valueOf(id + 1);
|
||||
String path = currentPath + MYSQL_FILE_PATH_SPLIT + newFolderId;
|
||||
EdFileInfo fileInfo = new EdFileInfo();
|
||||
fileInfo.setId(newFolderId)
|
||||
.setFileId(newFolderId)
|
||||
.setFileName(folderName)
|
||||
.setFileVersion(100)
|
||||
.setParentId(parentId)
|
||||
.setFileTime(EleCommonUtil.getNowTimeStr())
|
||||
.setDataType(EleDataTypeEnum.FOLDER.code)
|
||||
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||
.setEffectFlag(EffectFlagEnum.EFFECT.code)
|
||||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||
.setFilePath(path)
|
||||
.setSort(names.size() + 1)
|
||||
.setCreatedTime(now)
|
||||
.setUpdateTime(now)
|
||||
.setCreatedBy(currentUserId)
|
||||
.setUpdatedBy(currentUserId);
|
||||
// 保存到文件系统
|
||||
String targetFilePath = getPath(paths) + File.separator + folderName;
|
||||
fileSystemService.createDirectory(targetFilePath);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
try {
|
||||
int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
||||
Date now = new Date();
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
String newFolderId = String.valueOf(id + 1);
|
||||
String path = currentPath + MYSQL_FILE_PATH_SPLIT + newFolderId;
|
||||
EdFileInfo fileInfo = new EdFileInfo();
|
||||
fileInfo.setId(newFolderId)
|
||||
.setFileId(newFolderId)
|
||||
.setFileName(folderName)
|
||||
.setFileVersion(100)
|
||||
.setParentId(parentId)
|
||||
.setFileTime(EleCommonUtil.getNowTimeStr())
|
||||
.setDataType(EleDataTypeEnum.FOLDER.code)
|
||||
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||
.setEffectFlag(EffectFlagEnum.EFFECT.code)
|
||||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||
.setFilePath(path)
|
||||
.setSort(names.size() + 1)
|
||||
.setCreatedTime(now)
|
||||
.setUpdateTime(now)
|
||||
.setCreatedBy(currentUserId)
|
||||
.setUpdatedBy(currentUserId);
|
||||
// 保存到文件系统
|
||||
String targetFilePath = getPath(paths) + File.separator + folderName;
|
||||
fileSystemService.createDirectory(targetFilePath);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
String info = "添加子集失败";
|
||||
log.error(info, e);
|
||||
throw new BizException(-1, info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -255,37 +267,43 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
@Override
|
||||
public ElectromagneticResult<?> queryAllPrjInfo() {
|
||||
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId)
|
||||
.eq(EdFileInfo::getParentId, 0)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code);
|
||||
List<String> ids = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
try {
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId)
|
||||
.eq(EdFileInfo::getParentId, 0)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code);
|
||||
List<String> ids = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
|
||||
List<ProjectVO> projectVOS = new ArrayList<>();
|
||||
List<ProjectVO> projectVOS = new ArrayList<>();
|
||||
|
||||
for (String id : ids) {
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper1 = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId, EdFileInfo::getFileName, EdFileInfo::getParentId, EdFileInfo::getSort)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT);
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper1);
|
||||
// 转换为树
|
||||
TreeNodeConfig config = new TreeNodeConfig();
|
||||
config.setIdKey(EdFileInfo.Fields.id);
|
||||
config.setParentIdKey(EdFileInfo.Fields.parentId);
|
||||
config.setWeightKey(EdFileInfo.Fields.sort);
|
||||
for (String id : ids) {
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper1 = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId, EdFileInfo::getFileName, EdFileInfo::getParentId, EdFileInfo::getSort)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT);
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper1);
|
||||
// 转换为树
|
||||
TreeNodeConfig config = new TreeNodeConfig();
|
||||
config.setIdKey(EdFileInfo.Fields.id);
|
||||
config.setParentIdKey(EdFileInfo.Fields.parentId);
|
||||
config.setWeightKey(EdFileInfo.Fields.sort);
|
||||
|
||||
List<Tree<String>> trees = TreeUtil.build(edFileInfos, "0", config, ((obj, treeNode) -> {
|
||||
treeNode.putExtra(EdFileInfo.Fields.id, obj.getId());
|
||||
treeNode.putExtra(EdFileInfo.Fields.parentId, obj.getParentId());
|
||||
treeNode.putExtra(EdFileInfo.Fields.sort, obj.getSort());
|
||||
treeNode.putExtra(EdFileInfo.Fields.fileName, obj.getFileName());
|
||||
}));
|
||||
List<Tree<String>> trees = TreeUtil.build(edFileInfos, "0", config, ((obj, treeNode) -> {
|
||||
treeNode.putExtra(EdFileInfo.Fields.id, obj.getId());
|
||||
treeNode.putExtra(EdFileInfo.Fields.parentId, obj.getParentId());
|
||||
treeNode.putExtra(EdFileInfo.Fields.sort, obj.getSort());
|
||||
treeNode.putExtra(EdFileInfo.Fields.fileName, obj.getFileName());
|
||||
}));
|
||||
|
||||
String jsonStr = JSONUtil.toJsonStr(trees);
|
||||
ProjectVO projectVO = JSONUtil.toList(jsonStr, ProjectVO.class).get(0);
|
||||
projectVOS.add(projectVO);
|
||||
String jsonStr = JSONUtil.toJsonStr(trees);
|
||||
ProjectVO projectVO = JSONUtil.toList(jsonStr, ProjectVO.class).get(0);
|
||||
projectVOS.add(projectVO);
|
||||
}
|
||||
return ElectromagneticResultUtil.success(projectVOS);
|
||||
} catch (Exception e) {
|
||||
String info = "查询项目失败";
|
||||
log.error(info, e);
|
||||
throw new BizException(-1, info);
|
||||
}
|
||||
return ElectromagneticResultUtil.success(projectVOS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -297,14 +315,19 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> folderResort(List<FolderResortDTO> folderResortDTOList) {
|
||||
|
||||
for (FolderResortDTO folderResortDTO : folderResortDTOList) {
|
||||
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getSort, folderResortDTO.getSort())
|
||||
.eq(EdFileInfo::getId, folderResortDTO.getId());
|
||||
this.update(updateWrapper);
|
||||
try {
|
||||
for (FolderResortDTO folderResortDTO : folderResortDTOList) {
|
||||
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getSort, folderResortDTO.getSort())
|
||||
.eq(EdFileInfo::getId, folderResortDTO.getId());
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
String info = "子集重排序异常";
|
||||
log.error(info, e);
|
||||
throw new BizException(-1, info);
|
||||
}
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -314,12 +337,19 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> publish(String prjId) {
|
||||
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
||||
.likeRight(EdFileInfo::getFilePath, prjId);
|
||||
this.update(updateWrapper);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
try {
|
||||
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
||||
.likeRight(EdFileInfo::getFilePath, prjId);
|
||||
this.update(updateWrapper);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
String info = "项目发布异常";
|
||||
log.error(info, e);
|
||||
throw new BizException(-1, info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -330,41 +360,48 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
*/
|
||||
@Override
|
||||
public ElectromagneticResult<?> deleteFolder(String fileId) {
|
||||
// TODO是否需要判断文件夹是否为空
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId, EdFileInfo::getFilePath)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + fileId + MYSQL_FILE_PATH_SPLIT)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
|
||||
List<String> ids = edFileInfos.stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
ids.add(fileId);
|
||||
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||
.set(EdFileInfo::getSort, -1)
|
||||
.in(EdFileInfo::getId, ids);
|
||||
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;
|
||||
try {
|
||||
// TODO是否需要判断文件夹是否为空
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId, EdFileInfo::getFilePath)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + fileId + MYSQL_FILE_PATH_SPLIT)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
|
||||
List<String> ids = edFileInfos.stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
ids.add(fileId);
|
||||
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||
.set(EdFileInfo::getSort, -1)
|
||||
.in(EdFileInfo::getId, ids);
|
||||
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
|
||||
List<EdFileInfo> edFileInfos1 = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId, EdFileInfo::getSort)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(EdFileInfo::getParentId, parentId)
|
||||
.orderByAsc(EdFileInfo::getSort));
|
||||
for (int i = 1; i <= edFileInfos1.size(); i++) {
|
||||
String id = edFileInfos1.get(i).getId();
|
||||
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getSort, i)
|
||||
.eq(EdFileInfo::getId, id));
|
||||
}
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
String info = "删除子集异常";
|
||||
log.error(info, e);
|
||||
throw new BizException(-1, info);
|
||||
}
|
||||
// 同层级的resort
|
||||
List<EdFileInfo> edFileInfos1 = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId, EdFileInfo::getSort)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(EdFileInfo::getParentId, parentId)
|
||||
.orderByAsc(EdFileInfo::getSort));
|
||||
for (int i = 1; i <= edFileInfos1.size(); i++) {
|
||||
String id = edFileInfos1.get(i).getId();
|
||||
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getSort, i)
|
||||
.eq(EdFileInfo::getId, id));
|
||||
}
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -424,7 +461,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.setUpdatedBy(currentUserId);
|
||||
this.save(targetFile);
|
||||
String targetSysFilePath = getSysFilePathByDbPath(targetFile.getFilePath()) + File.separator + sourceFileName;
|
||||
FileUtil.mkdir(targetSysFilePath);
|
||||
fileSystemService.createDirectory(targetSysFilePath);
|
||||
targetEdFileInfos = this.baseMapper.selectAllAdminFolder(targetId);
|
||||
}
|
||||
}
|
||||
|
|
@ -452,7 +489,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
String sysFilePath = getSysFilePathByDbPath(fileInfo.getFilePath());
|
||||
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getFileName, newFolderName));
|
||||
FileUtil.rename(new File(sysFilePath), newFolderName, true);
|
||||
fileSystemService.renameFile(sysFilePath, newFolderName);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch(Exception e) {
|
||||
String info = StrFormatter.format("修改子集名称为{}失败", newFolderName);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public class FileSystemServiceImpl implements FileSystemService {
|
|||
public void save(InputStream inputStream, String destination) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renameFile(String sourcePath, String newName) {
|
||||
FileUtil.rename(new File(sourcePath), newName, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renameFile(String sourcePath, String oldName, String newName) {
|
||||
File sourceFile = new File(sourcePath + File.separator + oldName);
|
||||
|
|
|
|||
Loading…
Reference in New Issue