fix:文件回收站功能:删除到回收站,7天(设置时间)后自动删除;回收站中也可以手动删除
This commit is contained in:
@@ -96,11 +96,14 @@ public enum DirTypeEnum {
|
||||
}
|
||||
|
||||
// 初始化用户业务库目录
|
||||
private static final List<DirTypeEnum> INIT_SPMD_DIR = List.of(
|
||||
/* private static final List<DirTypeEnum> INIT_SPMD_DIR = List.of(
|
||||
DirTypeEnum.KNOWLEDGE_BASE_DIR, DirTypeEnum.PROJECT_NODE_DIR,
|
||||
DirTypeEnum.AVATAR_DIR, DirTypeEnum.SIMULATION_PARAMETER_DIR,
|
||||
DirTypeEnum.TRAIN_MODEL_DIR, DirTypeEnum.SCRIPT_DIR,
|
||||
DirTypeEnum.VIDEO_DIR, DirTypeEnum.REPORT_TEMPLATE_DIR);
|
||||
DirTypeEnum.VIDEO_DIR, DirTypeEnum.REPORT_TEMPLATE_DIR);*/
|
||||
|
||||
// 初始化用户业务库目录,默认DirTypeEnum的所有枚举
|
||||
private static final List<DirTypeEnum> INIT_SPMD_DIR = List.of(DirTypeEnum.values());
|
||||
public static final List<DirTypeEnum> getInitSpmdDir() {
|
||||
return INIT_SPMD_DIR;
|
||||
}
|
||||
|
||||
@@ -478,9 +478,17 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
// 处理标签查询(使用AOP自动填充的dictTagIdsCache)
|
||||
if (queryBigFileReq.getDictTags() != null && !queryBigFileReq.getDictTags().isEmpty()) {
|
||||
List<Long> fileIds = extractFileIdsByTags(queryBigFileReq);
|
||||
if (fileIds != null) {
|
||||
queryBigFileReq.setFileIds(fileIds);
|
||||
// 传入了标签,但没有任何匹配的文件ID,直接返回空结果,避免查询出所有未打标签的文件
|
||||
if (ObjectUtils.isEmpty(fileIds)) {
|
||||
PageInfo<FileStorage> emptyPage = new PageInfo<>(Collections.emptyList());
|
||||
emptyPage.setPageNum(queryBigFileReq.getCurrent());
|
||||
emptyPage.setPageSize(queryBigFileReq.getSize());
|
||||
emptyPage.setTotal(0);
|
||||
return emptyPage;
|
||||
}
|
||||
|
||||
queryBigFileReq.setFileIds(fileIds);
|
||||
|
||||
}
|
||||
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
|
||||
@@ -46,14 +46,18 @@ public class DeleteApproveStrategy implements ApproveStrategy {
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理文件删除审批通过 - 移入回收站
|
||||
* 处理文件删除审批通过 - 更新审批状态并移入回收站
|
||||
*/
|
||||
private boolean handleFileDeletion(ApproveContext context, FileMetadataInfo metadata, int type) {
|
||||
IFileMetadataInfoService service = context.getFileMetadataInfoService();
|
||||
|
||||
// 移入回收站
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime expireAt = now.plusDays(recycleRetentionDays);
|
||||
|
||||
// 更新审批状态 + 移入回收站
|
||||
metadata.setTempMetadata(null);
|
||||
metadata.setApprovalStatus(ApprovalFileDataStatusEnum.APPROVED.getKey());
|
||||
metadata.setApproveType(ApproveFileDataTypeEnum.COMPLETED.getCode());
|
||||
metadata.setDeletedAt(now);
|
||||
metadata.setRecycleExpireAt(expireAt);
|
||||
metadata.setUpdateTime(now);
|
||||
@@ -64,7 +68,7 @@ public class DeleteApproveStrategy implements ApproveStrategy {
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理目录删除审批通过 - 移入回收站
|
||||
* 处理目录删除审批通过 - 更新审批状态并移入回收站
|
||||
*/
|
||||
private boolean handleDirDeletion(ApproveContext context, FileMetadataInfo rootDirMetadata) {
|
||||
IFileMetadataInfoService service = context.getFileMetadataInfoService();
|
||||
@@ -80,10 +84,13 @@ public class DeleteApproveStrategy implements ApproveStrategy {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime expireAt = now.plusDays(recycleRetentionDays);
|
||||
|
||||
// 批量更新为回收站状态
|
||||
// 批量更新审批状态 + 回收站状态
|
||||
if (CollectionUtils.isNotEmpty(allFileIds)) {
|
||||
List<FileMetadataInfo> allMetadataList = service.listByIds(allFileIds);
|
||||
allMetadataList.forEach(item -> {
|
||||
item.setTempMetadata(null);
|
||||
item.setApprovalStatus(ApprovalFileDataStatusEnum.APPROVED.getKey());
|
||||
item.setApproveType(ApproveFileDataTypeEnum.COMPLETED.getCode());
|
||||
item.setDeletedAt(now);
|
||||
item.setRecycleExpireAt(expireAt);
|
||||
item.setUpdateTime(now);
|
||||
@@ -96,18 +103,18 @@ public class DeleteApproveStrategy implements ApproveStrategy {
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理审批拒绝
|
||||
* 处理审批拒绝 - 只更新审批状态,不移入回收站
|
||||
*/
|
||||
private boolean handleRejection(ApproveContext context, FileMetadataInfo metadata) {
|
||||
IFileMetadataInfoService service = context.getFileMetadataInfoService();
|
||||
|
||||
// 如果是目录,需要递归恢复所有子项状态
|
||||
// 如果是目录,需要递归更新所有子项审批状态
|
||||
if (Objects.equals(DataTypeEnum.DIRECTORY.getValue(), metadata.getDataType())) {
|
||||
Set<Long> allFileIds = new HashSet<>();
|
||||
Set<Long> allDirIds = new HashSet<>();
|
||||
collectRecursiveIds(service, metadata.getId(), allFileIds, allDirIds);
|
||||
|
||||
// 批量恢复状态
|
||||
// 批量更新审批状态(不移入回收站)
|
||||
if (CollectionUtils.isNotEmpty(allFileIds)) {
|
||||
List<FileMetadataInfo> allMetadataList = service.listByIds(allFileIds);
|
||||
allMetadataList.forEach(item -> {
|
||||
@@ -119,16 +126,16 @@ public class DeleteApproveStrategy implements ApproveStrategy {
|
||||
service.updateBatchById(allMetadataList);
|
||||
}
|
||||
|
||||
log.info("审批拒绝,已恢复目录及所有子项状态: id={}", metadata.getId());
|
||||
log.info("审批拒绝,已更新目录及所有子项审批状态(未移入回收站): id={}", metadata.getId());
|
||||
} else {
|
||||
// 单文件恢复状态
|
||||
// 单文件更新审批状态(不移入回收站)
|
||||
metadata.setTempMetadata(null);
|
||||
metadata.setApprovalStatus(ApprovalFileDataStatusEnum.REJECTED.getKey());
|
||||
metadata.setApproveType(ApproveFileDataTypeEnum.COMPLETED.getCode());
|
||||
metadata.setUpdateTime(LocalDateTime.now());
|
||||
service.updateById(metadata);
|
||||
|
||||
log.info("审批拒绝,已恢复文件状态: id={}", metadata.getId());
|
||||
log.info("审批拒绝,已更新文件审批状态(未移入回收站): id={}", metadata.getId());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3407,6 +3407,7 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
||||
|
||||
SimulationDemand demand = new SimulationDemand();
|
||||
BeanUtils.copyProperties(demandAddReq, demand);
|
||||
demand.setCreator(currentUserId);
|
||||
simulationTaskService.batchCreateTaskFromDemand(List.of(demand));
|
||||
log.info("异步保存需求成功,需求ID:{}", demandAddReq.getUuid());
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -148,6 +148,7 @@ public class SimulationTaskServiceImpl extends ServiceImpl<SimulationTaskMapper,
|
||||
|
||||
@Override
|
||||
public void batchCreateTaskFromDemand(List<SimulationDemand> demandList) {
|
||||
log.info("从需求批量创建任务,需求数量:{}", demandList);
|
||||
if (CollectionUtils.isEmpty(demandList)) {
|
||||
return;
|
||||
}
|
||||
@@ -175,14 +176,18 @@ public class SimulationTaskServiceImpl extends ServiceImpl<SimulationTaskMapper,
|
||||
// 1.需求创建人对关联的任务文件夹有预览、下载权限
|
||||
// 2.需求负责人(仿真负责人、确认人)对关联的任务文件夹有预览、下载权限
|
||||
// 但是目前任务负责人就是从需求负责人继承的,权限也会继承
|
||||
// 构建单个任务的权限配置
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(task.getUuid());
|
||||
// 构建单个任务的权限配置(仅当需求创建人不为空时)
|
||||
if (demand.getCreator() != null) {
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(task.getUuid());
|
||||
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(demand.getCreator(), FilePermissionEnum.BASE.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissionItemList.add(item);
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(demand.getCreator(), FilePermissionEnum.BASE.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissionItemList.add(item);
|
||||
} else {
|
||||
log.warn("需求创建人为空,跳过任务权限配置,需求ID: {}, 任务UUID: {}", demand.getUuid(), task.getUuid());
|
||||
}
|
||||
}
|
||||
// 批量更新需求创建人对任务文件夹的权限
|
||||
if (CollectionUtils.isNotEmpty(filePermissionItemList)) {
|
||||
|
||||
Reference in New Issue
Block a user