fix(文件管理): 修复默认多出一个默认模块问题
--bug=1015975 --user=赵勇 【项目设置】文件管理,历史项目有两个默认模块 https://www.tapd.cn/55049933/s/1226824
This commit is contained in:
parent
918e318d13
commit
578569620a
|
@ -30,12 +30,10 @@
|
|||
</foreach>
|
||||
</when>
|
||||
<when test="key=='moduleIds'">
|
||||
and
|
||||
( file_metadata.module_id in
|
||||
and file_metadata.module_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
OR file_metadata.module_id is null)
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
|
|
|
@ -3,5 +3,4 @@ package io.metersphere.commons.constants;
|
|||
public class ApiTestConstants {
|
||||
public static final String JAR_PATH = "JAR_PATH";
|
||||
public static final String DEF_MODULE = "DEF_MODULE";
|
||||
public static final String DEF_MODULE_ID = "moduleIds";
|
||||
}
|
||||
|
|
|
@ -107,18 +107,7 @@ public class FileMetadataService {
|
|||
this.add(req);
|
||||
}});
|
||||
}
|
||||
List<FileMetadata> list = extFileMetadataMapper.getProjectFiles(projectId, request);
|
||||
long size = list.stream().filter(t -> StringUtils.isEmpty(t.getModuleId())).count();
|
||||
if (size > 0) {
|
||||
// 历史数据处理
|
||||
String moduleId = fileModuleService.getDefaultNode(projectId).getId();
|
||||
list.forEach(item -> {
|
||||
if (StringUtils.isEmpty(item.getModuleId())) {
|
||||
item.setModuleId(moduleId);
|
||||
}
|
||||
});
|
||||
}
|
||||
return list;
|
||||
return extFileMetadataMapper.getProjectFiles(projectId, request);
|
||||
}
|
||||
|
||||
public void deleteFile(String fileId) {
|
||||
|
@ -424,7 +413,7 @@ public class FileMetadataService {
|
|||
fileMetadata.setProjectId(SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
if (StringUtils.isEmpty(fileMetadata.getModuleId())) {
|
||||
fileMetadata.setModuleId(fileModuleService.getDefaultNode(fileMetadata.getProjectId()).getId());
|
||||
fileMetadata.setModuleId(fileModuleService.getDefaultNodeId(fileMetadata.getProjectId()));
|
||||
}
|
||||
fileMetadata.setCreateTime(System.currentTimeMillis());
|
||||
fileMetadata.setUpdateTime(System.currentTimeMillis());
|
||||
|
|
|
@ -60,11 +60,7 @@ public class FileModuleService extends NodeTreeService<FileModuleVo> {
|
|||
|
||||
public List<FileModuleVo> getNodeTreeByProjectId(String projectId) {
|
||||
// 判断当前项目下是否有默认模块,没有添加默认模块
|
||||
FileModule defaultNode = this.getDefaultNode(projectId);
|
||||
// 历史数据统计
|
||||
FileMetadataExample example = new FileMetadataExample();
|
||||
example.createCriteria().andProjectIdEqualTo(projectId).andModuleIdIsNull();
|
||||
long defaultCount = fileMetadataMapper.countByExample(example);
|
||||
this.initDefaultNode(projectId);
|
||||
|
||||
List<FileModuleVo> modules = extFileModuleMapper.getNodeTreeByProjectId(projectId);
|
||||
List<String> ids = modules.stream().map(FileModuleVo::getId).collect(Collectors.toList());
|
||||
|
@ -85,7 +81,6 @@ public class FileModuleService extends NodeTreeService<FileModuleVo> {
|
|||
countNum += moduleCountMap.get(moduleId).intValue();
|
||||
}
|
||||
}
|
||||
countNum += defaultCount;
|
||||
node.setCaseNum(countNum);
|
||||
});
|
||||
}
|
||||
|
@ -355,7 +350,7 @@ public class FileModuleService extends NodeTreeService<FileModuleVo> {
|
|||
return fileModuleMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public FileModule getDefaultNode(String projectId) {
|
||||
private FileModule initDefaultNode(String projectId) {
|
||||
FileModuleExample example = new FileModuleExample();
|
||||
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo(ApiTestConstants.DEF_MODULE).andParentIdIsNull();
|
||||
List<FileModule> list = fileModuleMapper.selectByExample(example);
|
||||
|
@ -379,15 +374,14 @@ public class FileModuleService extends NodeTreeService<FileModuleVo> {
|
|||
}
|
||||
}
|
||||
|
||||
public FileModule getDefaultNodeUnCreateNew(String projectId) {
|
||||
public String getDefaultNodeId(String projectId) {
|
||||
FileModuleExample example = new FileModuleExample();
|
||||
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo(ApiTestConstants.DEF_MODULE).andParentIdIsNull();
|
||||
List<FileModule> list = fileModuleMapper.selectByExample(example);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return null;
|
||||
} else {
|
||||
return list.get(0);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
return list.get(0).getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getModuleNameById(String moduleId) {
|
||||
|
|
Loading…
Reference in New Issue