解决发现问题。
This commit is contained in:
parent
4be8e338dd
commit
ab8786be7f
|
|
@ -113,7 +113,7 @@ public class EdFileInfo extends BaseModel {
|
||||||
/**
|
/**
|
||||||
* 数据的归属:0-》上传的文件或者新建的文件夹 1-》系统管理员创建的层级 2-》用户自定义的层级
|
* 数据的归属:0-》上传的文件或者新建的文件夹 1-》系统管理员创建的层级 2-》用户自定义的层级
|
||||||
*/
|
*/
|
||||||
@TableField(value = "prj_dir")
|
@TableField(value = "data_own")
|
||||||
private Integer dataOwn;
|
private Integer dataOwn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -183,16 +183,16 @@ public class CommonService {
|
||||||
return parentId + fileFormat.getSuffixNo() + version + timeStr;
|
return parentId + fileFormat.getSuffixNo() + version + timeStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EdFileInfo> selectAllAdminFolder(String id, List<String> accessibleIds, int dataOwnCode) {
|
public List<EdFileInfo> selectAllPrjFolder(String id, List<String> accessibleIds, int dataOwnCode) {
|
||||||
|
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||||
.likeRight(EdFileInfo::getFilePath, id);
|
.likeRight(EdFileInfo::getFilePath, id);
|
||||||
if (dataOwnCode == DataOwnEnum.SYS_FILE.code) {
|
if (dataOwnCode == DataOwnEnum.SYS_FILE.code || dataOwnCode == DataOwnEnum.SYS_PRJ.code) {
|
||||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
|
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
|
||||||
queryWrapper.in(EdFileInfo::getId, accessibleIds);
|
queryWrapper.in(EdFileInfo::getId, accessibleIds);
|
||||||
} else if(dataOwnCode == DataOwnEnum.USER_FILE.code){
|
} else if (dataOwnCode == DataOwnEnum.USER_FILE.code || dataOwnCode == DataOwnEnum.USER_PRJ.code) {
|
||||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
|
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
|
||||||
} else {
|
} else {
|
||||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code);
|
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code);
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,13 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> queryEdFileInfo(FileInfoQueryDTO pars, int dataOwnCode) {
|
public ElectromagneticResult<?> queryEdFileInfo(FileInfoQueryDTO pars, int dataOwnCode) {
|
||||||
|
|
||||||
|
if (DataOwnEnum.isSysCode(dataOwnCode)) {
|
||||||
String parentId = pars.getParentId();
|
String parentId = pars.getParentId();
|
||||||
List<String> accessibleTree = permissionService.getAccessibleTree();
|
List<String> accessibleTree = permissionService.getAccessibleTree();
|
||||||
if ((dataOwnCode != DataOwnEnum.USER_FILE.code) && (!accessibleTree.contains(parentId) && parentId.length() == PRJ_ID_LENGTH)) {
|
if ((dataOwnCode != DataOwnEnum.USER_FILE.code) && (!accessibleTree.contains(parentId) && parentId.length() == PRJ_ID_LENGTH)) {
|
||||||
throw new PermissionDeniedException();
|
throw new PermissionDeniedException();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||||
|
|
@ -187,7 +189,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
public ElectromagneticResult<?> tree(int querySource) {
|
public ElectromagneticResult<?> tree(int querySource) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 都是从用户界面处进来,一个是从数据库的用户界面(SYS_DB),一个是从用户自己的工程界面处(USER_DB)。
|
* 都是从用户界面处进来,一个是从数据库的用户界面(SYS_DB),一个是从用户自己的工程界面处(USER_DB),一个是从库工程界面进入(REPO_DB)。
|
||||||
*/
|
*/
|
||||||
|
|
||||||
List<String> accessibleIds;
|
List<String> accessibleIds;
|
||||||
|
|
@ -768,8 +770,10 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code);
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code);
|
||||||
if (dataOwnCode == DataOwnEnum.USER_FILE.code) {
|
if (dataOwnCode == DataOwnEnum.USER_FILE.code) {
|
||||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
|
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
|
||||||
} else {
|
} else if (dataOwnCode == DataOwnEnum.SYS_FILE.code){
|
||||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
|
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
|
||||||
|
} else {
|
||||||
|
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code);
|
||||||
}
|
}
|
||||||
long dirCount = this.baseMapper.selectCount(queryWrapper);
|
long dirCount = this.baseMapper.selectCount(queryWrapper);
|
||||||
Assert.isTrue(dirCount == 0, "文件 {} 上传到 {} 失败,层级结构不允许上传文件,同名同后缀的处理方式为 {}", fileName, destPath, strategyStr);
|
Assert.isTrue(dirCount == 0, "文件 {} 上传到 {} 失败,层级结构不允许上传文件,同名同后缀的处理方式为 {}", fileName, destPath, strategyStr);
|
||||||
|
|
|
||||||
|
|
@ -348,11 +348,11 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
try {
|
try {
|
||||||
// 把source工程的层级结构copy到目标工程
|
// 把source工程的层级结构copy到目标工程
|
||||||
// 查找source的全部目录
|
// 查找source的全部目录
|
||||||
List<EdFileInfo> sourceEdFileInfos = commonService.selectAllAdminFolder(sourceId, null, dataOwnCode);
|
List<EdFileInfo> sourceEdFileInfos = commonService.selectAllPrjFolder(sourceId, null, dataOwnCode);
|
||||||
List<String> needSavePaths = new ArrayList<>();
|
List<String> needSavePaths = new ArrayList<>();
|
||||||
// 确定层级最大为prjFolderMaxLength层,现在逐层来处理。
|
// 确定层级最大为prjFolderMaxLength层,现在逐层来处理。
|
||||||
for (int i = 1; i <= prjFolderMaxLength; ++i) {
|
for (int i = 1; i <= prjFolderMaxLength; ++i) {
|
||||||
List<EdFileInfo> targetEdFileInfos = commonService.selectAllAdminFolder(targetId, null, dataOwnCode);
|
List<EdFileInfo> targetEdFileInfos = commonService.selectAllPrjFolder(targetId, null, dataOwnCode);
|
||||||
// 先查找source第i层下有那些子集
|
// 先查找source第i层下有那些子集
|
||||||
final int count = i;
|
final int count = i;
|
||||||
// 取source当前层
|
// 取source当前层
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,7 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
|
import com.electromagnetic.industry.software.common.enums.*;
|
||||||
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
|
||||||
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
|
||||||
import com.electromagnetic.industry.software.common.enums.FileBackupSource;
|
|
||||||
import com.electromagnetic.industry.software.common.exception.BizException;
|
import com.electromagnetic.industry.software.common.exception.BizException;
|
||||||
import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
|
|
@ -103,9 +100,10 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
||||||
.or()
|
.or()
|
||||||
.like(EdFileInfo::getFileContent, pars.getKeyword()));
|
.like(EdFileInfo::getFileContent, pars.getKeyword()));
|
||||||
}
|
}
|
||||||
|
// TODO 要考虑数据是个人数据还是库数据,如果是管理员,则展示全部数据,其他用户则展示有权限的系统数据+用户个人数据+库数据
|
||||||
if (!UserThreadLocal.getAdminType().equals(AdminTypeEnum.SYSTEM.getValue())) {
|
if (!UserThreadLocal.getAdminType().equals(AdminTypeEnum.SYSTEM.getValue())) {
|
||||||
List<String> accessibleTree = permissionService.getAccessibleTree();
|
List<String> accessibleTree = permissionService.getAccessibleTree();
|
||||||
|
queryWrapper.and(qr -> qr.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId()).eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_FILE.code));
|
||||||
if (CollUtil.isNotEmpty(accessibleTree)) {
|
if (CollUtil.isNotEmpty(accessibleTree)) {
|
||||||
for (String permission : accessibleTree) {
|
for (String permission : accessibleTree) {
|
||||||
queryWrapper.or().likeRight(EdFileInfo::getFileCode, permission);
|
queryWrapper.or().likeRight(EdFileInfo::getFileCode, permission);
|
||||||
|
|
@ -222,6 +220,11 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetRes(List<FileRecycleQueryVO> records) {
|
private void resetRes(List<FileRecycleQueryVO> records) {
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(records)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<String> userIds = records.stream().map(FileRecycleQueryVO::getUpdatedBy).collect(Collectors.toList());
|
List<String> userIds = records.stream().map(FileRecycleQueryVO::getUpdatedBy).collect(Collectors.toList());
|
||||||
Map<String, String> idNameMap = userMapper.selectList(Wrappers.<User>lambdaQuery().in(User::getId, userIds)).stream().collect(Collectors.toMap(User::getUserId, User::getUserName));
|
Map<String, String> idNameMap = userMapper.selectList(Wrappers.<User>lambdaQuery().in(User::getId, userIds)).stream().collect(Collectors.toMap(User::getUserId, User::getUserName));
|
||||||
records.forEach(e -> {
|
records.forEach(e -> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue