fix:支持同名文件覆盖
This commit is contained in:
@@ -24,12 +24,4 @@ public enum NodeTypeEnum {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否节点类型
|
||||
*/
|
||||
public static boolean isNodeType(String value) {
|
||||
return PROJECT.getValue().equals(value) || PHASE.getValue().equals(value)
|
||||
|| DISCIPLINE.getValue().equals(value) || MACHINE.getValue().equals(value)
|
||||
|| WORKSPACE.getValue().equals(value);
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,9 @@ public class UploadFilesReq {
|
||||
@Schema(description = "知识库文件审批模板名称")
|
||||
private String templateName;
|
||||
|
||||
@Schema(description = "是否需要覆盖同名文件")
|
||||
private Boolean isConverSameNameFile;
|
||||
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
|
||||
@@ -31,4 +31,12 @@ public class TagMapService {
|
||||
// project-->tag1 phase-->tag2
|
||||
return tagMapList.getData().stream().collect(Collectors.toMap(DataDictionary::getDictValue, DataDictionary::getDictName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否节点类型
|
||||
*/
|
||||
public boolean isNodeType(String tag) {
|
||||
Map<String, String> tagMap = getTagMapName();
|
||||
return tagMap.containsKey(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,8 +242,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
List<String> chooseUuids = nodeDirInfos.stream().map(FileMetadataInfo::getRelatedResourceUuid).toList();
|
||||
|
||||
// chooseUuid和chooseNodeType不为空,并且是node节点类型,才是节点文件夹,才需要查询子节点文件夹文件
|
||||
Map<String, String> tagMap = tagMapService.getTagMapName();
|
||||
if (ObjectUtils.isNotEmpty(chooseUuids) && ObjectUtils.isNotEmpty(chooseNodeType) && tagMap.containsKey(chooseNodeType)) {
|
||||
if (ObjectUtils.isNotEmpty(chooseUuids) && ObjectUtils.isNotEmpty(chooseNodeType) && tagMapService.isNodeType(chooseNodeType)) {
|
||||
// 从dimensionNodeTyepOrderList中获取chooseNodeType下一个位置的数据,有可能chooseNodeType所在位置就是最后一层节点,SdmResponse返回空数据
|
||||
int index = dimensionNodeTyepOrderList.indexOf(chooseNodeType);
|
||||
if (index == -1) {
|
||||
@@ -470,7 +469,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
.in(FileMetadataInfo::getParentId, fileIds).list();
|
||||
}else if(NodeTypeEnum.RUN.getValue().equalsIgnoreCase(nodeType)){
|
||||
runFileInfos = nodeFileInfos;
|
||||
} else if (NodeTypeEnum.isNodeType(nodeType)) {
|
||||
} else if (tagMapService.isNodeType(nodeType)) {
|
||||
// 基于 nodeUUids 获取 算列的run的uuids
|
||||
SpdmQueryRunListReq spdmQueryRunListReq = new SpdmQueryRunListReq();
|
||||
spdmQueryRunListReq.setNodeIdList(nodeUUids);
|
||||
|
||||
@@ -2058,6 +2058,11 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
}
|
||||
FileMetadataInfo dirMetadataInfo = dirResponse.getData();
|
||||
|
||||
SdmResponse<?> permissionResponse = checkUploadPermission(dirMetadataInfo);
|
||||
if (!permissionResponse.isSuccess()) {
|
||||
return permissionResponse;
|
||||
}
|
||||
|
||||
String originalName = resolveOriginalName(req);
|
||||
SdmResponse<String> versionedNameResponse = buildVersionedFileName(originalName);
|
||||
if (!versionedNameResponse.isSuccess()) {
|
||||
@@ -2068,11 +2073,12 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
|
||||
SdmResponse<?> existsResponse = ensureFileNotExists(fileMinioObjectKey);
|
||||
if (!existsResponse.isSuccess()) {
|
||||
return existsResponse;
|
||||
}
|
||||
SdmResponse<?> permissionResponse = checkUploadPermission(dirMetadataInfo);
|
||||
if (!permissionResponse.isSuccess()) {
|
||||
return permissionResponse;
|
||||
if(!req.getIsConverSameNameFile()) {
|
||||
return permissionResponse;
|
||||
}else {
|
||||
// 支持覆盖同名文件,直接minioService.uploadFile 覆盖一下原文件就行
|
||||
minioService.uploadFile(req.getFile(), fileMinioObjectKey, null, dirMetadataInfo.getBucketName());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user