层级相关的接口调通了
This commit is contained in:
parent
0c6ab12f3f
commit
89a939a0b2
|
|
@ -34,7 +34,6 @@ public class ProjectController {
|
|||
return edPrjService.modifyPrjName(prjId, newPrjName);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("queryAll")
|
||||
public ElectromagneticResult<?> queryAll() {
|
||||
return edPrjService.queryAllPrjInfo();
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ public interface EdPrjService {
|
|||
/**
|
||||
* 删除子集
|
||||
*
|
||||
* @param fileId
|
||||
* @param id
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> deleteFolder(String fileId, String parentId);
|
||||
ElectromagneticResult<?> deleteFolder(String id, String parentId);
|
||||
|
||||
/**
|
||||
* 层级沿用
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ import cn.hutool.core.lang.tree.TreeUtil;
|
|||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.EleDataSaveStatusEnum;
|
||||
|
|
@ -253,37 +251,27 @@ public class CommonService {
|
|||
}
|
||||
}
|
||||
|
||||
public ElectromagneticResult<?> deleteFolder(String fileId, String parentId, boolean needResort) {
|
||||
|
||||
public ElectromagneticResult<?> deleteFolder(String id, String parentId, boolean needResort) {
|
||||
// 如果文件夹下存在文件(包括文件夹和已经逻辑删除的文件),则不允许删除。后面管理员选择会有物理删除文件夹和文件的功能,此时MySQL和文件系统则会进行物理删除该文件。
|
||||
try {
|
||||
// TODO 如果文件夹下存在文件(不包括文件夹,包括已经删除的文件),则不允许删除
|
||||
Long count = edFileInfoMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + fileId + MYSQL_FILE_PATH_SPLIT)
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code));
|
||||
// 这里要分两种情况,1是删除层级目录,2是删除用户创建的文件夹
|
||||
EdFileInfo fileInfo = edFileInfoMapper.selectOne(Wrappers.<EdFileInfo>lambdaQuery().eq(EdFileInfo::getId, id));
|
||||
if (fileInfo.getPrjDir()) { // 删除的是层级目录
|
||||
long count = edFileInfoMapper.selectCount(Wrappers.<EdFileInfo>lambdaQuery()
|
||||
.eq(EdFileInfo::getPrjDir, false)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT));
|
||||
if (count > 0) {
|
||||
String info = "禁止删除非空文件夹";
|
||||
log.info(info);
|
||||
throw new BizException(-1, info);
|
||||
}
|
||||
|
||||
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 = edFileInfoMapper.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)
|
||||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
} else {
|
||||
// 先逻辑删除文件夹
|
||||
edFileInfoMapper.update(null, Wrappers.<EdFileInfo>lambdaUpdate()
|
||||
.eq(EdFileInfo::getId, id)
|
||||
.set(EdFileInfo::getSort, -1)
|
||||
.set(EdFileInfo::getUpdateTime, new Date())
|
||||
.set(EdFileInfo::getUpdatedBy, UserThreadLocal.getUserId())
|
||||
.in(EdFileInfo::getId, ids);
|
||||
edFileInfoMapper.update(null, updateWrapper);
|
||||
if (!needResort) {
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
// 同层级的resort
|
||||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
|
||||
// 层级文件夹重排序
|
||||
List<EdFileInfo> edFileInfos1 = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId, EdFileInfo::getSort)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
|
|
@ -292,12 +280,29 @@ public class CommonService {
|
|||
Date now = new Date();
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
for (int i = 0; i < edFileInfos1.size(); i++) {
|
||||
String id = edFileInfos1.get(i).getId();
|
||||
String tmp = edFileInfos1.get(i).getId();
|
||||
edFileInfoMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getSort, i + 1)
|
||||
.set(EdFileInfo::getUpdatedBy, currentUserId)
|
||||
.set(EdFileInfo::getUpdateTime, now)
|
||||
.eq(EdFileInfo::getId, id));
|
||||
.eq(EdFileInfo::getId, tmp));
|
||||
}
|
||||
}
|
||||
} else { // 删除的是用户自己创建的文件夹
|
||||
// 检查该文件夹下是否有没有被废除的文件
|
||||
long count = edFileInfoMapper.selectCount(Wrappers.<EdFileInfo>lambdaQuery()
|
||||
.eq(EdFileInfo::getParentId, parentId)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
if (count > 0) {
|
||||
String info = "禁止删除非空文件夹";
|
||||
log.info(info);
|
||||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
} else {
|
||||
// 逻辑文件夹重排序
|
||||
edFileInfoMapper.update(null, Wrappers.<EdFileInfo>lambdaUpdate()
|
||||
.eq(EdFileInfo::getId, id)
|
||||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
|
||||
}
|
||||
}
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -323,17 +328,4 @@ public class CommonService {
|
|||
String prjId = paths.get(0);
|
||||
return edFileInfoMapper.selectById(prjId).getFileName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,9 +73,9 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
.eq(EdFileInfo::getFileName, prjName));
|
||||
|
||||
if (count > 0) {
|
||||
String info = StrFormatter.format("{} 已经存在", prjName);
|
||||
String info = StrFormatter.format("{} 项目已经存在", prjName);
|
||||
log.info(info);
|
||||
ElectromagneticResultUtil.fail("-1", "该项目名称已经存在。");
|
||||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -132,16 +132,16 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
.eq(EdFileInfo::getFileName, newPrjName));
|
||||
|
||||
if (count > 0) {
|
||||
String info = StrFormatter.format("{} 已经存在", newPrjName);
|
||||
String info = StrFormatter.format("{} 项目已经存在", newPrjName);
|
||||
log.info(info);
|
||||
ElectromagneticResultUtil.fail("-1", "该项目名称已经存在。");
|
||||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
}
|
||||
|
||||
EdFileInfo fileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getFileName)
|
||||
.eq(EdFileInfo::getId, prjId));
|
||||
String oldPrjName = fileInfo.getFileName();
|
||||
String newPath = commonService.getEleDataPath();
|
||||
String newPath = commonService.getEleDataPath() + File.separator + newPrjName;
|
||||
if (fileSystemService.checkFolderExist(newPath)) {
|
||||
String info = StrFormatter.format("工程名{}已经存在", newPrjName);
|
||||
log.error(info);
|
||||
|
|
@ -363,7 +363,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
if (commonService.checkSameFolder(parentId, newFolderName)) {
|
||||
String info = "存在同名子集,禁止修改";
|
||||
log.error(info);
|
||||
throw new BizException(-1, info);
|
||||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
}
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
Date now = new Date();
|
||||
|
|
|
|||
Loading…
Reference in New Issue