fix(接口测试): 删除场景模块树时更新回收站统计
This commit is contained in:
parent
039a234370
commit
b628f853cb
|
@ -31,4 +31,6 @@ public interface ExtFileMetadataMapper {
|
|||
List<String> selectFileTypeByProjectId(@Param("projectId") String projectId, @Param("storage") String storage);
|
||||
|
||||
long countRepositoryFileByFileNameAndBranch(@Param("projectId") String projectId, @Param("moduleId") String moduleId, @Param("filePath") String filePath, @Param("branch") String branch);
|
||||
|
||||
FileMetadata selectLatestById(String fileId);
|
||||
}
|
||||
|
|
|
@ -197,6 +197,15 @@
|
|||
AND fgit.branch = #{branch}
|
||||
AND f.project_id = #{projectId}
|
||||
</select>
|
||||
<select id="selectLatestById" resultType="io.metersphere.project.domain.FileMetadata">
|
||||
select *
|
||||
from file_metadata
|
||||
where latest = true
|
||||
and ref_id IN (select ref_id
|
||||
from file_metadata
|
||||
where id = #{0})
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -529,6 +529,7 @@ public class FileMetadataService {
|
|||
fileMetadata.setProjectId(oldFile.getProjectId());
|
||||
fileMetadata.setModuleId(oldFile.getModuleId());
|
||||
fileMetadata.setName(oldFile.getName());
|
||||
fileMetadata.setOriginalName(oldFile.getOriginalName());
|
||||
fileMetadata.setCreateTime(oldFile.getCreateTime());
|
||||
fileMetadata.setCreateUser(oldFile.getCreateUser());
|
||||
fileMetadata.setUpdateTime(operationTime);
|
||||
|
@ -539,11 +540,11 @@ public class FileMetadataService {
|
|||
fileMetadata.setLatest(true);
|
||||
}
|
||||
|
||||
public String pullFile(String fileId, String operator) {
|
||||
FileMetadata oldFile = fileMetadataMapper.selectByPrimaryKey(fileId);
|
||||
String returnFileId = fileId;
|
||||
public String pullFile(String paramFileId, String operator) {
|
||||
FileMetadata oldFile = extFileMetadataMapper.selectLatestById(paramFileId);
|
||||
String returnFileId = oldFile.getId();
|
||||
if (StringUtils.equals(oldFile.getStorage(), StorageType.GIT.name())) {
|
||||
FileMetadataRepository metadataRepository = fileMetadataRepositoryMapper.selectByPrimaryKey(fileId);
|
||||
FileMetadataRepository metadataRepository = fileMetadataRepositoryMapper.selectByPrimaryKey(oldFile.getId());
|
||||
FileModuleRepository moduleRepository = fileModuleRepositoryMapper.selectByPrimaryKey(oldFile.getModuleId());
|
||||
if (metadataRepository != null && moduleRepository != null) {
|
||||
|
||||
|
@ -606,7 +607,7 @@ public class FileMetadataService {
|
|||
List<String> fileIdList = fileMetadataList.stream().map(FileMetadata::getId).toList();
|
||||
FileMetadataRepositoryExample repositoryExample = new FileMetadataRepositoryExample();
|
||||
repositoryExample.createCriteria().andFileMetadataIdIn(fileIdList);
|
||||
List<FileMetadataRepository> fileMetadataRepositoryList = fileMetadataRepositoryMapper.selectByExample(repositoryExample);
|
||||
List<FileMetadataRepository> fileMetadataRepositoryList = fileMetadataRepositoryMapper.selectByExampleWithBLOBs(repositoryExample);
|
||||
Map<String, FileMetadataRepository> fileIdMap = fileMetadataRepositoryList.stream().collect(Collectors.toMap(FileMetadataRepository::getFileMetadataId, Function.identity()));
|
||||
|
||||
//用户ID-用户名的映射
|
||||
|
|
|
@ -109,7 +109,11 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
|||
example.clear();
|
||||
}
|
||||
}
|
||||
example.createCriteria().andParentIdEqualTo(fileModule.getParentId()).andNameEqualTo(fileModule.getName()).andModuleTypeEqualTo(fileModule.getModuleType()).andIdNotEqualTo(fileModule.getId());
|
||||
example.createCriteria().andParentIdEqualTo(fileModule.getParentId())
|
||||
.andNameEqualTo(fileModule.getName())
|
||||
.andModuleTypeEqualTo(fileModule.getModuleType())
|
||||
.andProjectIdEqualTo(fileModule.getProjectId())
|
||||
.andIdNotEqualTo(fileModule.getId());
|
||||
if (fileModuleMapper.countByExample(example) > 0) {
|
||||
throw new MSException(Translator.get("node.name.repeat"));
|
||||
}
|
||||
|
@ -136,6 +140,7 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
|||
updateModule.setName(request.getName().trim());
|
||||
updateModule.setParentId(module.getParentId());
|
||||
updateModule.setModuleType(module.getModuleType());
|
||||
updateModule.setProjectId(module.getProjectId());
|
||||
this.checkDataValidity(updateModule);
|
||||
updateModule.setUpdateTime(System.currentTimeMillis());
|
||||
updateModule.setUpdateUser(userId);
|
||||
|
|
|
@ -171,7 +171,14 @@
|
|||
readOnly: false,
|
||||
}
|
||||
);
|
||||
const emit = defineEmits(['init', 'newScenario', 'import', 'folderNodeSelect', 'changeProtocol']);
|
||||
const emit = defineEmits([
|
||||
'init',
|
||||
'countRecycleScenario',
|
||||
'newScenario',
|
||||
'import',
|
||||
'folderNodeSelect',
|
||||
'changeProtocol',
|
||||
]);
|
||||
|
||||
const appStore = useAppStore();
|
||||
const { t } = useI18n();
|
||||
|
@ -353,6 +360,7 @@
|
|||
await deleteModule(node.id);
|
||||
Message.success(t('apiScenario.deleteSuccess'));
|
||||
await initModules();
|
||||
emit('countRecycleScenario');
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
<scenarioModuleTree
|
||||
ref="scenarioModuleTreeRef"
|
||||
:is-show-scenario="isShowScenario"
|
||||
@count-recycle-scenario="selectRecycleCount"
|
||||
@folder-node-select="handleNodeSelect"
|
||||
@init="handleModuleInit"
|
||||
@new-scenario="() => newTab()"
|
||||
|
|
Loading…
Reference in New Issue