fix(测试计划): 修复用例&评审&计划富文本图片问题

This commit is contained in:
WangXu10 2024-07-19 15:53:09 +08:00 committed by 刘瑞斌
parent 4dbe854cf9
commit 013733e7f2
5 changed files with 19 additions and 10 deletions

View File

@ -104,4 +104,6 @@ public interface ExtFunctionalCaseMapper {
List<FunctionalCase> getListBySelectModules(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("moduleIds") List<String> moduleIds, @Param("testPlanId") String testPlanId);
List<FunctionalCase> getListBySelectIds(@Param("projectId") String projectId, @Param("ids") List<String> ids, @Param("testPlanId") String testPlanId);
List<FunctionalCase> getProjectIdByIds(@Param("ids") List<String> ids);
}

View File

@ -951,4 +951,11 @@
#{id}
</foreach>
</select>
<select id="getProjectIdByIds" resultType="io.metersphere.functional.domain.FunctionalCase">
select id, project_id from functional_case where id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

View File

@ -505,10 +505,6 @@ public class FunctionalCaseAttachmentService {
fileCopyRequest.setStorage(StorageType.MINIO.toString());
fileService.upload(previewImg, fileCopyRequest);
}
// 删除临时文件
fileCopyRequest.setFolder(systemTempDir + "/" + fileId);
fileCopyRequest.setFileName(fileName);
defaultRepository.delete(fileCopyRequest);
} catch (Exception e) {
LogUtils.error("上传副文本文件失败:{}",e);
throw new MSException(Translator.get("file_upload_fail"));

View File

@ -71,8 +71,9 @@ public class FunctionalCaseCommentService {
* @return FunctionalCaseComment
*/
public FunctionalCaseComment saveComment(FunctionalCaseCommentRequest functionalCaseCommentRequest, String userId) {
checkCase(functionalCaseCommentRequest.getCaseId());
FunctionalCase functionalCase = checkCase(functionalCaseCommentRequest.getCaseId());
FunctionalCaseComment functionalCaseComment = getFunctionalCaseComment(functionalCaseCommentRequest, userId);
functionalCaseCommentRequest.setProjectId(functionalCase.getProjectId());
if (StringUtils.equals(functionalCaseCommentRequest.getEvent(), NoticeConstants.Event.REPLY)) {
return saveCommentWidthReply(functionalCaseCommentRequest, functionalCaseComment, userId);
} else {
@ -100,11 +101,12 @@ public class FunctionalCaseCommentService {
return functionalCaseComment;
}
private void checkCase(String caseId) {
private FunctionalCase checkCase(String caseId) {
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(caseId);
if (functionalCase == null) {
throw new MSException(Translator.get("case_comment.case_is_null"));
}
return functionalCase;
}
/**

View File

@ -626,14 +626,16 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
List<TestPlanFunctionalCase> functionalCases = testPlanFunctionalCaseMapper.selectByExample(example);
List<String> caseIds = functionalCases.stream().map(TestPlanFunctionalCase::getFunctionalCaseId).collect(Collectors.toList());
Map<String, String> idsMap = functionalCases.stream().collect(Collectors.toMap(TestPlanFunctionalCase::getId, TestPlanFunctionalCase::getFunctionalCaseId));
List<TestPlanCaseExecuteHistory> historyList = getExecHistory(ids, request, logInsertModule, idsMap);
List<FunctionalCase> list = extFunctionalCaseMapper.getProjectIdByIds(caseIds);
Map<String, String> projectMap = list.stream().collect(Collectors.toMap(FunctionalCase::getId, FunctionalCase::getProjectId));
List<TestPlanCaseExecuteHistory> historyList = getExecHistory(ids, request, logInsertModule, idsMap, projectMap);
testPlanCaseExecuteHistoryMapper.batchInsert(historyList);
updateFunctionalCaseStatus(caseIds, request.getLastExecResult());
}
private List<TestPlanCaseExecuteHistory> getExecHistory(List<String> ids, TestPlanCaseBatchRunRequest request, LogInsertModule logInsertModule, Map<String, String> idsMap) {
private List<TestPlanCaseExecuteHistory> getExecHistory(List<String> ids, TestPlanCaseBatchRunRequest request, LogInsertModule logInsertModule, Map<String, String> idsMap, Map<String, String> projectMap) {
List<TestPlanCaseExecuteHistory> historyList = new ArrayList<>();
ids.forEach(id -> {
@ -649,8 +651,8 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
executeHistory.setCreateUser(logInsertModule.getOperator());
executeHistory.setCreateTime(System.currentTimeMillis());
historyList.add(executeHistory);
handleFileAndNotice(idsMap.get(id), request.getProjectId(), request.getPlanCommentFileIds(), logInsertModule.getOperator(), CaseFileSourceType.PLAN_COMMENT.toString(), request.getNotifier(), request.getTestPlanId(), request.getLastExecResult());
String caseId = idsMap.get(id);
handleFileAndNotice(caseId, projectMap.get(caseId), request.getPlanCommentFileIds(), logInsertModule.getOperator(), CaseFileSourceType.PLAN_COMMENT.toString(), request.getNotifier(), request.getTestPlanId(), request.getLastExecResult());
});