优化代码。
This commit is contained in:
parent
7944c5bfc9
commit
f48c02967d
|
|
@ -2,17 +2,13 @@ package com.electromagnetic.industry.software.manage.pojo.models;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
||||
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
|
||||
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("ed_file_info")
|
||||
@Accessors(chain = true)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import cn.hutool.core.lang.tree.Tree;
|
|||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
|
@ -237,7 +236,7 @@ public class CommonService {
|
|||
case USER_FILE, USER_PRJ -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
|
||||
case SYS_FILE, SYS_PRJ -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
|
||||
case REPO_PRJ, REPO_FILE -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code);
|
||||
default -> ElectromagneticResultUtil.fail("-1", "参数错误");
|
||||
default -> throw new BizException("参数错误");
|
||||
}
|
||||
return edFileInfoMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
|
@ -463,8 +462,6 @@ public class CommonService {
|
|||
// 如果文件夹下存在文件(包括文件夹和已经逻辑删除的文件),则不允许删除。后面管理员选择会有物理删除文件夹和文件的功能,此时MySQL和文件系统则会进行物理删除该文件。
|
||||
EdFileInfo srcFileInfo = edFileInfoMapper.selectById(id);
|
||||
Assert.isTrue(srcFileInfo.getDataType().equals(EleDataTypeEnum.FOLDER.code), "禁止删除目录");
|
||||
String srcFilePath = getFileSysPath(srcFileInfo.getId());
|
||||
String uuid = IdUtil.fastSimpleUUID();
|
||||
try {
|
||||
// 这里要分两种情况,1是删除层级目录,2是删除用户创建的文件夹
|
||||
String parentId = srcFileInfo.getParentId();
|
||||
|
|
@ -535,11 +532,8 @@ public class CommonService {
|
|||
}
|
||||
|
||||
public Set<String> selectPrjLeafs(int dataOwnCode, List<String> accessibleIds) {
|
||||
|
||||
Set<String> res = new HashSet<>();
|
||||
|
||||
List<String> prjInfo = List.of();
|
||||
|
||||
List<String> prjInfo;
|
||||
DataOwnEnum obj = DataOwnEnum.getEnumByCode(dataOwnCode);
|
||||
switch (Objects.requireNonNull(obj)) {
|
||||
case USER_FILE, USER_PRJ ->
|
||||
|
|
@ -548,7 +542,7 @@ public class CommonService {
|
|||
prjInfo = querySysPrjTree(PrjQuerySource.SYS_DB.value, accessibleIds, new FileProjectVO()).getOrDefault(PrjQuerySource.SYS_DB.value, new ArrayList<>());
|
||||
case REPO_PRJ, REPO_FILE ->
|
||||
prjInfo = queryRepoPrjTree(PrjQuerySource.REPO_DB.value, accessibleIds, new FileProjectVO()).getOrDefault(PrjQuerySource.REPO_DB.value, new ArrayList<>());
|
||||
default -> ElectromagneticResultUtil.fail("-1", "参数错误");
|
||||
default -> throw new BizException("参数错误");
|
||||
}
|
||||
|
||||
for (String info : prjInfo) {
|
||||
|
|
@ -619,7 +613,7 @@ public class CommonService {
|
|||
case USER_FILE, USER_PRJ -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
|
||||
case SYS_FILE, SYS_PRJ -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
|
||||
case REPO_PRJ, REPO_FILE -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code);
|
||||
default -> ElectromagneticResultUtil.fail("-1", "参数错误");
|
||||
default -> throw new BizException("参数错误");
|
||||
}
|
||||
|
||||
long dirCount = edFileInfoMapper.selectCount(queryWrapper);
|
||||
|
|
@ -681,7 +675,7 @@ public class CommonService {
|
|||
throw new BizException(info);
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo(Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getParentId).orElse(""),
|
||||
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getFileId).orElse(""),
|
||||
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getId).orElse(""),
|
||||
"文件 {} 为上传到 {} 成功,同名同后缀的处理方式为 {},存入的文件名为 {}",
|
||||
fileName,
|
||||
destPath,
|
||||
|
|
|
|||
|
|
@ -263,9 +263,9 @@
|
|||
select r.role_name
|
||||
from ed_role r
|
||||
where r.id in (select ur.role_id
|
||||
from ed_users u
|
||||
left join ed_user_role ur on u.user_id = ur.user_id
|
||||
where u.user_id = #{userId})
|
||||
from ed_users u
|
||||
left join ed_user_role ur on u.user_id = ur.user_id
|
||||
where u.user_id = #{userId})
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue