增加异常处理相关逻辑。
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 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);
|
boolean checkFolderExist(String newPath);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
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.EleDataSaveStatusEnum;
|
||||||
import com.electromagnetic.industry.software.common.enums.EleDataStatusEnum;
|
import com.electromagnetic.industry.software.common.enums.EleDataStatusEnum;
|
||||||
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
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.resp.ElectromagneticResult;
|
||||||
import com.electromagnetic.industry.software.common.util.*;
|
import com.electromagnetic.industry.software.common.util.*;
|
||||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||||
|
|
@ -121,7 +121,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("文件创建失败,具体为--->{}", e.getMessage());
|
String info = StrFormatter.format("文件创建失败,具体为--->{}", e.getMessage());
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
return ElectromagneticResultUtil.fail("-1", e.getMessage());
|
throw new BizException(-1, info);
|
||||||
}
|
}
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +151,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("修改工程名异常--->{},{}", newPrjName, e.getMessage());
|
String info = StrFormatter.format("修改工程名异常--->{},{}", newPrjName, e.getMessage());
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new RuntimeException(e);
|
throw new BizException(-1, info);
|
||||||
}
|
}
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
@ -163,17 +163,23 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ElectromagneticResult<?> delete(String prjId) {
|
public ElectromagneticResult<?> delete(String prjId) {
|
||||||
|
try {
|
||||||
List<String> ids = new ArrayList<>();
|
List<String> ids = new ArrayList<>();
|
||||||
ids.add(prjId);
|
ids.add(prjId);
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo::getId)
|
.select(EdFileInfo::getId)
|
||||||
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT);
|
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT);
|
||||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
|
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
|
||||||
edFileInfos.forEach(e -> ids.add(e.getId()));
|
edFileInfos.forEach(e -> ids.add(e.getId()));
|
||||||
Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids);
|
Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids);
|
||||||
return ElectromagneticResultUtil.success(true);
|
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);
|
return ElectromagneticResultUtil.fail("-1", info);
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
try {
|
||||||
Date now = new Date();
|
int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
||||||
String currentUserId = UserThreadLocal.getUserId();
|
Date now = new Date();
|
||||||
String newFolderId = String.valueOf(id + 1);
|
String currentUserId = UserThreadLocal.getUserId();
|
||||||
String path = currentPath + MYSQL_FILE_PATH_SPLIT + newFolderId;
|
String newFolderId = String.valueOf(id + 1);
|
||||||
EdFileInfo fileInfo = new EdFileInfo();
|
String path = currentPath + MYSQL_FILE_PATH_SPLIT + newFolderId;
|
||||||
fileInfo.setId(newFolderId)
|
EdFileInfo fileInfo = new EdFileInfo();
|
||||||
.setFileId(newFolderId)
|
fileInfo.setId(newFolderId)
|
||||||
.setFileName(folderName)
|
.setFileId(newFolderId)
|
||||||
.setFileVersion(100)
|
.setFileName(folderName)
|
||||||
.setParentId(parentId)
|
.setFileVersion(100)
|
||||||
.setFileTime(EleCommonUtil.getNowTimeStr())
|
.setParentId(parentId)
|
||||||
.setDataType(EleDataTypeEnum.FOLDER.code)
|
.setFileTime(EleCommonUtil.getNowTimeStr())
|
||||||
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
.setDataType(EleDataTypeEnum.FOLDER.code)
|
||||||
.setEffectFlag(EffectFlagEnum.EFFECT.code)
|
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
.setEffectFlag(EffectFlagEnum.EFFECT.code)
|
||||||
.setFilePath(path)
|
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||||
.setSort(names.size() + 1)
|
.setFilePath(path)
|
||||||
.setCreatedTime(now)
|
.setSort(names.size() + 1)
|
||||||
.setUpdateTime(now)
|
.setCreatedTime(now)
|
||||||
.setCreatedBy(currentUserId)
|
.setUpdateTime(now)
|
||||||
.setUpdatedBy(currentUserId);
|
.setCreatedBy(currentUserId)
|
||||||
// 保存到文件系统
|
.setUpdatedBy(currentUserId);
|
||||||
String targetFilePath = getPath(paths) + File.separator + folderName;
|
// 保存到文件系统
|
||||||
fileSystemService.createDirectory(targetFilePath);
|
String targetFilePath = getPath(paths) + File.separator + folderName;
|
||||||
return ElectromagneticResultUtil.success(true);
|
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
|
@Override
|
||||||
public ElectromagneticResult<?> queryAllPrjInfo() {
|
public ElectromagneticResult<?> queryAllPrjInfo() {
|
||||||
|
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
try {
|
||||||
.select(EdFileInfo::getId)
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.eq(EdFileInfo::getParentId, 0)
|
.select(EdFileInfo::getId)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code);
|
.eq(EdFileInfo::getParentId, 0)
|
||||||
List<String> ids = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
.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) {
|
for (String id : ids) {
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper1 = Wrappers.lambdaQuery(EdFileInfo.class)
|
LambdaQueryWrapper<EdFileInfo> queryWrapper1 = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo::getId, EdFileInfo::getFileName, EdFileInfo::getParentId, EdFileInfo::getSort)
|
.select(EdFileInfo::getId, EdFileInfo::getFileName, EdFileInfo::getParentId, EdFileInfo::getSort)
|
||||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT);
|
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT);
|
||||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper1);
|
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper1);
|
||||||
// 转换为树
|
// 转换为树
|
||||||
TreeNodeConfig config = new TreeNodeConfig();
|
TreeNodeConfig config = new TreeNodeConfig();
|
||||||
config.setIdKey(EdFileInfo.Fields.id);
|
config.setIdKey(EdFileInfo.Fields.id);
|
||||||
config.setParentIdKey(EdFileInfo.Fields.parentId);
|
config.setParentIdKey(EdFileInfo.Fields.parentId);
|
||||||
config.setWeightKey(EdFileInfo.Fields.sort);
|
config.setWeightKey(EdFileInfo.Fields.sort);
|
||||||
|
|
||||||
List<Tree<String>> trees = TreeUtil.build(edFileInfos, "0", config, ((obj, treeNode) -> {
|
List<Tree<String>> trees = TreeUtil.build(edFileInfos, "0", config, ((obj, treeNode) -> {
|
||||||
treeNode.putExtra(EdFileInfo.Fields.id, obj.getId());
|
treeNode.putExtra(EdFileInfo.Fields.id, obj.getId());
|
||||||
treeNode.putExtra(EdFileInfo.Fields.parentId, obj.getParentId());
|
treeNode.putExtra(EdFileInfo.Fields.parentId, obj.getParentId());
|
||||||
treeNode.putExtra(EdFileInfo.Fields.sort, obj.getSort());
|
treeNode.putExtra(EdFileInfo.Fields.sort, obj.getSort());
|
||||||
treeNode.putExtra(EdFileInfo.Fields.fileName, obj.getFileName());
|
treeNode.putExtra(EdFileInfo.Fields.fileName, obj.getFileName());
|
||||||
}));
|
}));
|
||||||
|
|
||||||
String jsonStr = JSONUtil.toJsonStr(trees);
|
String jsonStr = JSONUtil.toJsonStr(trees);
|
||||||
ProjectVO projectVO = JSONUtil.toList(jsonStr, ProjectVO.class).get(0);
|
ProjectVO projectVO = JSONUtil.toList(jsonStr, ProjectVO.class).get(0);
|
||||||
projectVOS.add(projectVO);
|
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
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ElectromagneticResult<?> folderResort(List<FolderResortDTO> folderResortDTOList) {
|
public ElectromagneticResult<?> folderResort(List<FolderResortDTO> folderResortDTOList) {
|
||||||
|
try {
|
||||||
for (FolderResortDTO folderResortDTO : folderResortDTOList) {
|
for (FolderResortDTO folderResortDTO : folderResortDTOList) {
|
||||||
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
.set(EdFileInfo::getSort, folderResortDTO.getSort())
|
.set(EdFileInfo::getSort, folderResortDTO.getSort())
|
||||||
.eq(EdFileInfo::getId, folderResortDTO.getId());
|
.eq(EdFileInfo::getId, folderResortDTO.getId());
|
||||||
this.update(updateWrapper);
|
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
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ElectromagneticResult<?> publish(String prjId) {
|
public ElectromagneticResult<?> publish(String prjId) {
|
||||||
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
try {
|
||||||
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
.likeRight(EdFileInfo::getFilePath, prjId);
|
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
||||||
this.update(updateWrapper);
|
.likeRight(EdFileInfo::getFilePath, prjId);
|
||||||
return ElectromagneticResultUtil.success(true);
|
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
|
@Override
|
||||||
public ElectromagneticResult<?> deleteFolder(String fileId) {
|
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);
|
try {
|
||||||
String parentId = tmpFileIds[0];
|
// TODO是否需要判断文件夹是否为空
|
||||||
for (String tmpPathId : tmpFileIds) {
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
parentId = this.baseMapper.maxPrjId();
|
.select(EdFileInfo::getId, EdFileInfo::getFilePath)
|
||||||
if (fileId.equals(tmpPathId)) {
|
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + fileId + MYSQL_FILE_PATH_SPLIT)
|
||||||
break;
|
.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);
|
.setUpdatedBy(currentUserId);
|
||||||
this.save(targetFile);
|
this.save(targetFile);
|
||||||
String targetSysFilePath = getSysFilePathByDbPath(targetFile.getFilePath()) + File.separator + sourceFileName;
|
String targetSysFilePath = getSysFilePathByDbPath(targetFile.getFilePath()) + File.separator + sourceFileName;
|
||||||
FileUtil.mkdir(targetSysFilePath);
|
fileSystemService.createDirectory(targetSysFilePath);
|
||||||
targetEdFileInfos = this.baseMapper.selectAllAdminFolder(targetId);
|
targetEdFileInfos = this.baseMapper.selectAllAdminFolder(targetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -452,7 +489,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
String sysFilePath = getSysFilePathByDbPath(fileInfo.getFilePath());
|
String sysFilePath = getSysFilePathByDbPath(fileInfo.getFilePath());
|
||||||
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
.set(EdFileInfo::getFileName, newFolderName));
|
.set(EdFileInfo::getFileName, newFolderName));
|
||||||
FileUtil.rename(new File(sysFilePath), newFolderName, true);
|
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);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@ public class FileSystemServiceImpl implements FileSystemService {
|
||||||
public void save(InputStream inputStream, String destination) {
|
public void save(InputStream inputStream, String destination) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renameFile(String sourcePath, String newName) {
|
||||||
|
FileUtil.rename(new File(sourcePath), newName, true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameFile(String sourcePath, String oldName, String newName) {
|
public void renameFile(String sourcePath, String oldName, String newName) {
|
||||||
File sourceFile = new File(sourcePath + File.separator + oldName);
|
File sourceFile = new File(sourcePath + File.separator + oldName);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue