fix(用例评审): 修复非评审人员可以评审的问题以及更新功能用例的评审状态
This commit is contained in:
parent
7c127bd7cf
commit
d4d4fd99b3
|
@ -149,6 +149,7 @@ case_review.multiple=多人评审
|
|||
case_review.not.exist=用例评审不存在
|
||||
case_review_content.not.exist = 评审意见不能为空
|
||||
case_review_history.system=系统触发
|
||||
case_review_user=您没有评审权限
|
||||
#minder
|
||||
case.minder.all.case=全部用例
|
||||
|
||||
|
|
|
@ -169,5 +169,6 @@ case_review_history.system=System trigger
|
|||
case_review.viewFlag.not_blank=View flag cannot be empty
|
||||
functional_case_relationship_edge.type.not_blank=Relationship type cannot be empty
|
||||
cycle_relationship=There is a circular dependency after association, please check the dependency relationship
|
||||
case_review_user=You do not have review permission
|
||||
#minder
|
||||
case.minder.all.case=All Case
|
|
@ -168,5 +168,6 @@ case_review_history.system=系统触发
|
|||
case_review.viewFlag.not_blank=查看标识不能为空
|
||||
functional_case_relationship_edge.type.not_blank=类型不能为空
|
||||
cycle_relationship=关联后存在循环依赖,请检查依赖关系
|
||||
case_review_user=您没有评审权限
|
||||
#minder
|
||||
case.minder.all.case=全部用例
|
||||
|
|
|
@ -169,5 +169,6 @@ case_review_history.system=系統觸發
|
|||
case_review.viewFlag.not_blank=查看標誌不能為空
|
||||
functional_case_relationship_edge.type.not_blank=類型不能為空
|
||||
cycle_relationship=關聯后存在循環依賴,請檢查依賴關係
|
||||
case_review_user=您沒有評審權限
|
||||
#minder
|
||||
case.minder.all.case=全部用例
|
||||
|
|
|
@ -14,10 +14,10 @@ public interface CaseEvent {
|
|||
interface Param {
|
||||
String REVIEW_ID = "reviewId";
|
||||
String CASE_IDS = "caseIds";
|
||||
String STATUS = "status";
|
||||
String USER_ID = "userId";
|
||||
String EVENT_NAME = "eventName";
|
||||
String COUNT_MAP = "countMap";
|
||||
String STATUS_MAP = "statusMap";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ import io.metersphere.sdk.util.LogUtils;
|
|||
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -26,6 +30,8 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
|
|||
@Resource
|
||||
private CaseReviewMapper caseReviewMapper;
|
||||
@Resource
|
||||
private SqlSessionFactory sqlSessionFactory;
|
||||
@Resource
|
||||
private CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper;
|
||||
@Resource
|
||||
private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper;
|
||||
|
@ -210,6 +216,9 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
|
|||
if(CollectionUtils.isEmpty(caseIdList)){
|
||||
return;
|
||||
}
|
||||
Object statusObjMap = paramMap.get(CaseEvent.Param.STATUS_MAP);
|
||||
Map<String,String> statusMap = JSON.parseMap(JSON.toJSONString(statusObjMap));
|
||||
updateFunctionalCase(statusMap);
|
||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = extCaseReviewFunctionalCaseMapper.getListExcludes(List.of(reviewId), caseIdList, false);
|
||||
Map<String, Integer> caseCountMap = getCaseCountMap(caseReviewFunctionalCases);
|
||||
Object mapCount = paramMap.get(CaseEvent.Param.COUNT_MAP);
|
||||
|
@ -222,6 +231,19 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateFunctionalCase(Map<String,String> statusMap) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
FunctionalCaseMapper mapper = sqlSession.getMapper(FunctionalCaseMapper.class);
|
||||
statusMap.forEach((castId,status)->{
|
||||
FunctionalCase functionalCase = new FunctionalCase();
|
||||
functionalCase.setId(castId);
|
||||
functionalCase.setReviewStatus(status);
|
||||
mapper.updateByPrimaryKeySelective(functionalCase);
|
||||
});
|
||||
sqlSession.flushStatements();
|
||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||
}
|
||||
|
||||
|
||||
private static void updateMapCount(Map<String, Integer> map, Map<String, Integer> caseCountMap) {
|
||||
if (map.get(FunctionalCaseReviewStatus.UN_REVIEWED.toString()) != null) {
|
||||
|
|
|
@ -294,6 +294,7 @@ public class CaseReviewFunctionalCaseService {
|
|||
CaseReviewHistoryMapper caseReviewHistoryMapper = sqlSession.getMapper(CaseReviewHistoryMapper.class);
|
||||
CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class);
|
||||
|
||||
Map<String,String>statusMap = new HashMap<>();
|
||||
for (CaseReviewFunctionalCase caseReviewFunctionalCase : caseReviewFunctionalCaseList) {
|
||||
//校验当前操作人是否是该用例的评审人,是增加评审历史,不是过滤掉
|
||||
String caseId = caseReviewFunctionalCase.getCaseId();
|
||||
|
@ -315,7 +316,7 @@ public class CaseReviewFunctionalCaseService {
|
|||
}
|
||||
//根据评审规则更新用例评审和功能用例关系表中的状态 1.单人评审直接更新评审结果 2.多人评审需要计算
|
||||
setStatus(request, caseReviewFunctionalCase, caseHistoryMap, reviewerMap);
|
||||
|
||||
statusMap.put(caseReviewFunctionalCase.getCaseId(),caseReviewFunctionalCase.getStatus());
|
||||
caseReviewFunctionalCaseMapper.updateByPrimaryKeySelective(caseReviewFunctionalCase);
|
||||
|
||||
//检查是否有@,发送@通知
|
||||
|
@ -344,7 +345,7 @@ public class CaseReviewFunctionalCaseService {
|
|||
});
|
||||
param.put(CaseEvent.Param.CASE_IDS, CollectionUtils.isNotEmpty(caseIds) ? caseIds : new ArrayList<>());
|
||||
param.put(CaseEvent.Param.REVIEW_ID, reviewId);
|
||||
param.put(CaseEvent.Param.STATUS, request.getStatus());
|
||||
param.put(CaseEvent.Param.STATUS_MAP, statusMap);
|
||||
param.put(CaseEvent.Param.USER_ID, userId);
|
||||
param.put(CaseEvent.Param.EVENT_NAME, CaseEvent.Event.REVIEW_FUNCTIONAL_CASE);
|
||||
param.put(CaseEvent.Param.COUNT_MAP, countMap);
|
||||
|
@ -440,16 +441,13 @@ public class CaseReviewFunctionalCaseService {
|
|||
Map<String, List<CaseReviewHistory>> caseHistoryMap = caseReviewHistories.stream().collect(Collectors.groupingBy(CaseReviewHistory::getCaseId, Collectors.toList()));
|
||||
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
FunctionalCaseMapper functionalCaseMapper = sqlSession.getMapper(FunctionalCaseMapper.class);
|
||||
Map<String, String>statusMap = new HashMap<>();
|
||||
CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class);
|
||||
cases.forEach(caseReview -> {
|
||||
String status = multipleReview(caseReview, caseHistoryMap.get(caseReview.getCaseId()), newReviewersMap.get(caseReview.getCaseId()), oldReviewUserMap.get(caseReview.getCaseId()));
|
||||
caseReview.setStatus(status);
|
||||
caseReviewFunctionalCaseMapper.updateByPrimaryKeySelective(caseReview);
|
||||
FunctionalCase functionalCase = new FunctionalCase();
|
||||
functionalCase.setId(caseReview.getCaseId());
|
||||
functionalCase.setReviewStatus(caseReview.getStatus());
|
||||
functionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
|
||||
statusMap.put(caseReview.getCaseId(), caseReview.getStatus());
|
||||
});
|
||||
sqlSession.flushStatements();
|
||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||
|
@ -463,6 +461,7 @@ public class CaseReviewFunctionalCaseService {
|
|||
param.put(CaseEvent.Param.USER_ID, userId);
|
||||
param.put(CaseEvent.Param.CASE_IDS, caseIds);
|
||||
param.put(CaseEvent.Param.COUNT_MAP, countMap);
|
||||
param.put(CaseEvent.Param.STATUS_MAP, statusMap);
|
||||
param.put(CaseEvent.Param.EVENT_NAME, CaseEvent.Event.REVIEW_FUNCTIONAL_CASE);
|
||||
provider.updateCaseReview(param);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@ import io.metersphere.functional.constants.CaseEvent;
|
|||
import io.metersphere.functional.constants.CaseFileSourceType;
|
||||
import io.metersphere.functional.constants.CaseReviewPassRule;
|
||||
import io.metersphere.functional.constants.FunctionalCaseReviewStatus;
|
||||
import io.metersphere.functional.domain.CaseReviewFunctionalCaseUserExample;
|
||||
import io.metersphere.functional.domain.CaseReviewHistory;
|
||||
import io.metersphere.functional.domain.CaseReviewHistoryExample;
|
||||
import io.metersphere.functional.domain.*;
|
||||
import io.metersphere.functional.dto.CaseReviewHistoryDTO;
|
||||
import io.metersphere.functional.mapper.CaseReviewFunctionalCaseUserMapper;
|
||||
import io.metersphere.functional.mapper.CaseReviewHistoryMapper;
|
||||
|
@ -57,6 +55,13 @@ public class ReviewFunctionalCaseService {
|
|||
//保存评审历史
|
||||
String reviewId = request.getReviewId();
|
||||
String caseId = request.getCaseId();
|
||||
CaseReviewFunctionalCaseUserExample caseReviewFunctionalCaseUserExample = new CaseReviewFunctionalCaseUserExample();
|
||||
caseReviewFunctionalCaseUserExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo(caseId);
|
||||
List<CaseReviewFunctionalCaseUser> caseReviewFunctionalCaseUsers = caseReviewFunctionalCaseUserMapper.selectByExample(caseReviewFunctionalCaseUserExample);
|
||||
List<String> users = caseReviewFunctionalCaseUsers.stream().map(CaseReviewFunctionalCaseUser::getUserId).toList();
|
||||
if (!users.contains(userId)) {
|
||||
throw new MSException(Translator.get("case_review_user"));
|
||||
}
|
||||
CaseReviewHistory caseReviewHistory = buildReviewHistory(request, userId);
|
||||
CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample();
|
||||
caseReviewHistoryExample.createCriteria().andCaseIdEqualTo(request.getCaseId()).andReviewIdEqualTo(request.getReviewId()).andDeletedEqualTo(false);
|
||||
|
@ -90,9 +95,11 @@ public class ReviewFunctionalCaseService {
|
|||
Map<String, Object> param = new HashMap<>();
|
||||
Map<String, Integer> countMap = new HashMap<>();
|
||||
countMap.put(functionalCaseStatus,1);
|
||||
Map<String, String> statusMap = new HashMap<>();
|
||||
statusMap.put(caseId,functionalCaseStatus);
|
||||
param.put(CaseEvent.Param.CASE_IDS, List.of(caseId));
|
||||
param.put(CaseEvent.Param.REVIEW_ID, reviewId);
|
||||
param.put(CaseEvent.Param.STATUS, request.getStatus());
|
||||
param.put(CaseEvent.Param.STATUS_MAP, statusMap);
|
||||
param.put(CaseEvent.Param.USER_ID, userId);
|
||||
param.put(CaseEvent.Param.COUNT_MAP,countMap);
|
||||
param.put(CaseEvent.Param.EVENT_NAME, CaseEvent.Event.REVIEW_FUNCTIONAL_CASE);
|
||||
|
|
|
@ -105,8 +105,6 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTest");
|
||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(),FunctionalCaseReviewStatus.PASS.toString()));
|
||||
List<CaseReview> caseReviews1 = getCaseReviews("创建用例评审1");
|
||||
Assertions.assertTrue(StringUtils.equals(caseReviews1.get(0).getStatus(), CaseReviewStatus.UNDERWAY.toString()));
|
||||
//单人评审不通过
|
||||
reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest();
|
||||
reviewFunctionalCaseRequest.setReviewId(reviewId);
|
||||
|
@ -125,8 +123,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne");
|
||||
caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(),FunctionalCaseReviewStatus.UN_PASS.toString()));
|
||||
caseReviews1 = getCaseReviews("创建用例评审1");
|
||||
Assertions.assertTrue(StringUtils.equals(caseReviews1.get(0).getStatus(), CaseReviewStatus.COMPLETED.toString()));
|
||||
|
||||
|
||||
reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest();
|
||||
reviewFunctionalCaseRequest.setReviewId(reviewId);
|
||||
|
@ -145,8 +142,6 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne");
|
||||
caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(),FunctionalCaseReviewStatus.RE_REVIEWED.toString()));
|
||||
caseReviews1 = getCaseReviews("创建用例评审1");
|
||||
Assertions.assertTrue(StringUtils.equals(caseReviews1.get(0).getStatus(), CaseReviewStatus.UNDERWAY.toString()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -210,8 +205,6 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestThree");
|
||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(),FunctionalCaseReviewStatus.PASS.toString()));
|
||||
List<CaseReview> caseReviews1 = getCaseReviews("创建用例评审3");
|
||||
Assertions.assertTrue(StringUtils.equals(caseReviews1.get(0).getStatus(), CaseReviewStatus.UNDERWAY.toString()));
|
||||
|
||||
reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest();
|
||||
reviewFunctionalCaseRequest.setReviewId(reviewId);
|
||||
|
@ -230,8 +223,6 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestFour");
|
||||
caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(),FunctionalCaseReviewStatus.UN_PASS.toString()));
|
||||
caseReviews1 = getCaseReviews("创建用例评审3");
|
||||
Assertions.assertTrue(StringUtils.equals(caseReviews1.get(0).getStatus(), CaseReviewStatus.COMPLETED.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue