From 24b6d9b5f25c4da4f70b3f351ce7fde7c3919ccd Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 12 Dec 2023 17:35:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1):?= =?UTF-8?q?=20=E5=85=B3=E8=81=94=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=A8=E9=80=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExtCaseReviewFunctionalCaseMapper.java | 1 + .../ExtCaseReviewFunctionalCaseMapper.xml | 12 ++++ .../functional/mapper/ExtCaseReviewMapper.xml | 15 +++++ .../request/BaseAssociateCaseRequest.java | 15 +++++ .../request/CaseReviewAssociateRequest.java | 12 ++-- .../request/CaseReviewBatchRequest.java | 6 ++ .../functional/request/CaseReviewRequest.java | 6 +- .../service/CaseReviewLogService.java | 24 +++++++- .../functional/service/CaseReviewService.java | 59 +++++++++++++----- .../controller/CaseReviewControllerTests.java | 61 +++++++++++++------ .../ReviewFunctionalCaseControllerTests.java | 7 ++- .../test/resources/dml/init_case_review.sql | 12 ++-- 12 files changed, 179 insertions(+), 51 deletions(-) create mode 100644 backend/services/case-management/src/main/java/io/metersphere/functional/request/BaseAssociateCaseRequest.java diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java index 930c9c04fa..4811bb5e3e 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java @@ -24,6 +24,7 @@ public interface ExtCaseReviewFunctionalCaseMapper { List page(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId, @Param("sort") String sort); + Long getPos(@Param("reviewId") String reviewId); List getIds(@Param("request") BaseReviewCaseBatchRequest request, @Param("userId") String userId, @Param("deleted") boolean deleted); } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml index 8d4c58192f..5087e04140 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml @@ -274,4 +274,16 @@ 1=1 + + \ No newline at end of file diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml index 6c013c3adc..79b74528b7 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml @@ -83,6 +83,21 @@ + + case_review.create_user = #{request.createByMe} + + + + + + case_review.id in + ( + select case_review_user.review_id from case_review_user where case_review_user.user_id = #{request.reviewByMe} + ) + + + + diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/request/BaseAssociateCaseRequest.java b/backend/services/case-management/src/main/java/io/metersphere/functional/request/BaseAssociateCaseRequest.java new file mode 100644 index 0000000000..554b671a13 --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/request/BaseAssociateCaseRequest.java @@ -0,0 +1,15 @@ +package io.metersphere.functional.request; + +import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +@Data +public class BaseAssociateCaseRequest extends BaseFunctionalCaseBatchDTO { + + @Schema(description = "功能用例选择的项目id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{case_review_associate_request.project_id.not_blank}") + private String projectId; + +} diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewAssociateRequest.java b/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewAssociateRequest.java index 2561bed9b9..2b314c547e 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewAssociateRequest.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewAssociateRequest.java @@ -3,6 +3,7 @@ package io.metersphere.functional.request; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.Data; import java.io.Serial; @@ -14,7 +15,6 @@ import java.util.List; */ @Data public class CaseReviewAssociateRequest implements Serializable { - @Serial private static final long serialVersionUID = 1L; @@ -22,16 +22,16 @@ public class CaseReviewAssociateRequest implements Serializable { @NotBlank(message = "{case_review_associate_request.case_review_id.not_blank}") private String reviewId; - @Schema(description = "项目id", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "用例评审所在的项目id", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{case_review_associate_request.project_id.not_blank}") private String projectId; - @Schema(description = "功能用例id", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "{case_review_associate_request.case_ids.not_empty}") - private List caseIds; - @Schema(description = "评审人") @NotEmpty(message = "{case_review_associate_request.user_ids.not_empty}") private List reviewers; + @Schema(description = "查询功能用例的条件") + @NotNull(message = "{case_review_associate_request.base_associate_case_request.not_null}") + private BaseAssociateCaseRequest baseAssociateCaseRequest; + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewBatchRequest.java b/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewBatchRequest.java index 0e93669847..797ed1b689 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewBatchRequest.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewBatchRequest.java @@ -26,4 +26,10 @@ public class CaseReviewBatchRequest extends TableBatchProcessDTO implements Seri @Schema(description = "模块id") private List moduleIds; + @Schema(description = "我评审的") + private String reviewByMe; + + @Schema(description = "我创建的") + private String createByMe; + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewRequest.java b/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewRequest.java index a71a885fe0..9f3364e7e1 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewRequest.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewRequest.java @@ -28,7 +28,7 @@ public class CaseReviewRequest implements Serializable { @NotBlank(message = "{case_review.name.not_blank}") private String name; - @Schema(description = "模块id", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "用例评审的模块id", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{case_review.module_id.not_blank}") private String moduleId; @@ -52,6 +52,6 @@ public class CaseReviewRequest implements Serializable { @NotEmpty(message = "{case_review.reviewers.not_empty}") private List reviewers; - @Schema(description = "关联的用例id", requiredMode = Schema.RequiredMode.REQUIRED) - private List caseIds; + @Schema(description = "查询功能用例的条件") + private BaseAssociateCaseRequest baseAssociateCaseRequest; } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewLogService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewLogService.java index 08d2d8e419..4243907677 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewLogService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewLogService.java @@ -4,9 +4,12 @@ import io.metersphere.functional.domain.CaseReview; import io.metersphere.functional.domain.CaseReviewFunctionalCase; import io.metersphere.functional.domain.FunctionalCase; import io.metersphere.functional.domain.FunctionalCaseExample; +import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO; import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; import io.metersphere.functional.mapper.CaseReviewMapper; +import io.metersphere.functional.mapper.ExtFunctionalCaseMapper; import io.metersphere.functional.mapper.FunctionalCaseMapper; +import io.metersphere.functional.request.BaseAssociateCaseRequest; import io.metersphere.functional.request.BaseReviewCaseBatchRequest; import io.metersphere.functional.request.CaseReviewAssociateRequest; import io.metersphere.functional.request.CaseReviewRequest; @@ -41,6 +44,8 @@ public class CaseReviewLogService { @Resource private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper; + @Resource + private ExtFunctionalCaseMapper extFunctionalCaseMapper; /** * 新增用例评审 日志 @@ -144,7 +149,11 @@ public class CaseReviewLogService { return null; } List dtoList = new ArrayList<>(); - List caseIds = request.getCaseIds(); + BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest(); + List caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId()); + if (CollectionUtils.isEmpty(caseIds)) { + return null; + } FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample(); functionalCaseExample.createCriteria().andIdIn(caseIds); List functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample); @@ -221,4 +230,17 @@ public class CaseReviewLogService { return dtoList; } + public List doSelectIds(T dto, String projectId) { + BaseFunctionalCaseBatchDTO request = (BaseFunctionalCaseBatchDTO) dto; + if (request.isSelectAll()) { + List ids = extFunctionalCaseMapper.getIds(request, projectId, false); + if (CollectionUtils.isNotEmpty(request.getExcludeIds())) { + ids.removeAll(request.getExcludeIds()); + } + return ids; + } else { + return request.getSelectIds(); + } + } + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewService.java index 388c5d7f88..fbd17d4364 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewService.java @@ -4,13 +4,11 @@ package io.metersphere.functional.service; import io.metersphere.functional.constants.CaseReviewStatus; import io.metersphere.functional.constants.FunctionalCaseReviewStatus; import io.metersphere.functional.domain.*; +import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO; import io.metersphere.functional.dto.CaseReviewDTO; import io.metersphere.functional.dto.CaseReviewUserDTO; import io.metersphere.functional.mapper.*; -import io.metersphere.functional.request.CaseReviewAssociateRequest; -import io.metersphere.functional.request.CaseReviewBatchRequest; -import io.metersphere.functional.request.CaseReviewPageRequest; -import io.metersphere.functional.request.CaseReviewRequest; +import io.metersphere.functional.request.*; import io.metersphere.functional.result.CaseManagementResultCode; import io.metersphere.project.dto.ModuleCountDTO; import io.metersphere.sdk.constants.ApplicationNumScope; @@ -75,7 +73,11 @@ public class CaseReviewService { @Resource private CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper; @Resource + private ExtCaseReviewFunctionalCaseMapper extCaseReviewFunctionalCaseMapper; + @Resource private CaseReviewModuleService caseReviewModuleService; + @Resource + private ExtFunctionalCaseMapper extFunctionalCaseMapper; private static final String CASE_MODULE_COUNT_ALL = "all"; @@ -200,7 +202,9 @@ public class CaseReviewService { */ public void addCaseReview(CaseReviewRequest request, String userId) { String caseReviewId = IDGenerator.nextStr(); - addCaseReview(request, userId, caseReviewId); + BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest(); + List caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId()); + addCaseReview(request, userId, caseReviewId, caseIds); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); CaseReviewUserMapper mapper = sqlSession.getMapper(CaseReviewUserMapper.class); CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class); @@ -209,9 +213,9 @@ public class CaseReviewService { //保存和评审人的关系 addCaseReviewUser(request, caseReviewId, mapper); //保存和用例的关系 - addCaseReviewFunctionalCase(request.getCaseIds(), request.getProjectId(), userId, caseReviewId, caseReviewFunctionalCaseMapper); + addCaseReviewFunctionalCase(caseIds, request.getProjectId(), userId, caseReviewId, caseReviewFunctionalCaseMapper); //保存用例和用例评审人的关系 - addCaseReviewFunctionalCaseUser(request.getCaseIds(), request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper); + addCaseReviewFunctionalCaseUser(caseIds, request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper); sqlSession.flushStatements(); } finally { SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); @@ -316,7 +320,7 @@ public class CaseReviewService { * @param userId 当前操作人 * @param caseReviewId 用例评审id */ - private void addCaseReview(CaseReviewRequest request, String userId, String caseReviewId) { + private void addCaseReview(CaseReviewRequest request, String userId, String caseReviewId, List caseIds) { CaseReview caseReview = new CaseReview(); caseReview.setId(caseReviewId); caseReview.setNum(getNextNum(request.getProjectId())); @@ -330,10 +334,10 @@ public class CaseReviewService { caseReview.setTags(JSON.toJSONString(request.getTags())); } caseReview.setPassRate(BigDecimal.valueOf(0.00)); - if (CollectionUtils.isEmpty(request.getCaseIds())) { + if (CollectionUtils.isEmpty(caseIds)) { caseReview.setCaseCount(0); } else { - caseReview.setCaseCount(request.getCaseIds().size()); + caseReview.setCaseCount(caseIds.size()); } caseReview.setStartTime(request.getStartTime()); caseReview.setEndTime(request.getEndTime()); @@ -350,8 +354,6 @@ public class CaseReviewService { * @param caseReviewId 用例评审id */ private CaseReview checkCaseReview(String caseReviewId) { - CaseReviewExample caseReviewExample = new CaseReviewExample(); - caseReviewExample.createCriteria().andIdEqualTo(caseReviewId); CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(caseReviewId); if (caseReview == null) { throw new MSException(CaseManagementResultCode.CASE_REVIEW_NOT_FOUND); @@ -368,6 +370,15 @@ public class CaseReviewService { return (pos == null ? 0 : pos) + POS_STEP; } + /** + * @param caseReviewId 用例评审id + * @return pos + */ + public Long getCaseFunctionalCaseNextPos(String caseReviewId) { + Long pos = extCaseReviewFunctionalCaseMapper.getPos(caseReviewId); + return (pos == null ? 0 : pos) + POS_STEP; + } + /** * @param projectId 项目id * @return num @@ -396,7 +407,7 @@ public class CaseReviewService { caseReviewFunctionalCase.setCreateTime(System.currentTimeMillis()); caseReviewFunctionalCase.setUpdateTime(System.currentTimeMillis()); caseReviewFunctionalCase.setId(IDGenerator.nextStr()); - caseReviewFunctionalCase.setPos(getNextPos(projectId)); + caseReviewFunctionalCase.setPos(getCaseFunctionalCaseNextPos(caseReviewId)); caseReviewFunctionalCaseMapper.insert(caseReviewFunctionalCase); }); } @@ -428,8 +439,13 @@ public class CaseReviewService { public void associateCase(CaseReviewAssociateRequest request, String userId) { String caseReviewId = request.getReviewId(); CaseReview caseReviewExist = checkCaseReview(caseReviewId); + BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest(); + List caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId()); + if (CollectionUtils.isEmpty(caseIds)) { + return; + } FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample(); - functionalCaseExample.createCriteria().andIdIn(request.getCaseIds()); + functionalCaseExample.createCriteria().andIdIn(caseIds); List functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample); if (CollectionUtils.isEmpty(functionalCases)) { return; @@ -438,7 +454,7 @@ public class CaseReviewService { caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(caseReviewId); List caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); List castIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getCaseId).toList(); - List caseRealIds = request.getCaseIds().stream().filter(t -> !castIds.contains(t)).toList(); + List caseRealIds = caseIds.stream().filter(t -> !castIds.contains(t)).toList(); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class); CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper = sqlSession.getMapper(CaseReviewFunctionalCaseUserMapper.class); @@ -464,6 +480,19 @@ public class CaseReviewService { caseReviewMapper.updateByPrimaryKeySelective(caseReview); } + public List doSelectIds(T dto, String projectId) { + BaseFunctionalCaseBatchDTO request = (BaseFunctionalCaseBatchDTO) dto; + if (request.isSelectAll()) { + List ids = extFunctionalCaseMapper.getIds(request, projectId, false); + if (CollectionUtils.isNotEmpty(request.getExcludeIds())) { + ids.removeAll(request.getExcludeIds()); + } + return ids; + } else { + return request.getSelectIds(); + } + } + /** * 用例评审列表拖拽排序 * diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java index 78acf3a3be..2b5aea3e66 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java @@ -127,6 +127,9 @@ public class CaseReviewControllerTests extends BaseTest { caseReviewRequest.setName(name); caseReviewRequest.setModuleId("CASE_REVIEW_REAL_MODULE_ID"); caseReviewRequest.setReviewPassRule(reviewPassRule); + BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest(); + baseAssociateCaseRequest.setProjectId(projectId); + baseAssociateCaseRequest.setSelectAll(false); List reviewers = new ArrayList<>(); reviewers.add("admin"); if (reviewer) { @@ -135,13 +138,14 @@ public class CaseReviewControllerTests extends BaseTest { if (StringUtils.isNotBlank(caseId)) { List caseIds = new ArrayList<>(); caseIds.add(caseId); - caseReviewRequest.setCaseIds(caseIds); + baseAssociateCaseRequest.setSelectIds(caseIds); } if (tag) { List tags = new ArrayList<>(); tags.add("11"); caseReviewRequest.setTags(tags); } + caseReviewRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest); return caseReviewRequest; } @@ -276,13 +280,11 @@ public class CaseReviewControllerTests extends BaseTest { CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest(); caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setReviewId(caseReviewId); - List caseIds = new ArrayList<>(); - caseIds.add("CASE_REVIEW_TEST_GYQ_ID2"); - caseIds.add("CASE_REVIEW_TEST_GYQ_ID3"); - caseIds.add("CASE_REVIEW_TEST_GYQ_ID4"); - caseIds.add("CASE_REVIEW_TEST_GYQ_ID5"); - caseIds.add("CASE_REVIEW_TEST_GYQ_ID6"); - caseReviewAssociateRequest.setCaseIds(caseIds); + BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest(); + baseAssociateCaseRequest.setProjectId(projectId); + baseAssociateCaseRequest.setSelectAll(true); + baseAssociateCaseRequest.setExcludeIds(List.of("CASE_REVIEW_TEST_GYQ_ID")); + caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest); List userIds = new ArrayList<>(); userIds.add("gyq_review_test"); userIds.add("gyq_review_test2"); @@ -307,9 +309,10 @@ public class CaseReviewControllerTests extends BaseTest { CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest(); caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setReviewId("caseReviewIdXXXX"); - List caseIds = new ArrayList<>(); - caseIds.add("CASE_REVIEW_TEST_GYQ_ID2"); - caseReviewAssociateRequest.setCaseIds(caseIds); + BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest(); + baseAssociateCaseRequest.setProjectId(projectId); + baseAssociateCaseRequest.setSelectAll(true); + caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest); List userIds = new ArrayList<>(); userIds.add("gyq_review_test"); userIds.add("gyq_review_test2"); @@ -319,9 +322,25 @@ public class CaseReviewControllerTests extends BaseTest { caseReviewAssociateRequest = new CaseReviewAssociateRequest(); caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setReviewId(caseReviews.get(0).getId()); - caseIds = new ArrayList<>(); - caseIds.add("CASE_REVIEW_TEST_GYQ_XX"); - caseReviewAssociateRequest.setCaseIds(caseIds); + baseAssociateCaseRequest = new BaseAssociateCaseRequest(); + baseAssociateCaseRequest.setProjectId(projectId); + baseAssociateCaseRequest.setSelectAll(false); + baseAssociateCaseRequest.setSelectIds(List.of("CASE_REVIEW_TEST_GYQ_XX")); + caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest); + userIds = new ArrayList<>(); + userIds.add("gyq_review_test"); + userIds.add("gyq_review_test2"); + caseReviewAssociateRequest.setReviewers(userIds); + this.requestPostWithOk(ASSOCIATE_CASE_REVIEW, caseReviewAssociateRequest); + + caseReviewAssociateRequest = new CaseReviewAssociateRequest(); + caseReviewAssociateRequest.setProjectId(projectId); + caseReviewAssociateRequest.setReviewId(caseReviews.get(0).getId()); + baseAssociateCaseRequest = new BaseAssociateCaseRequest(); + baseAssociateCaseRequest.setProjectId("project-gyq-case-review-testYY"); + baseAssociateCaseRequest.setSelectAll(true); + baseAssociateCaseRequest.setSelectIds(List.of("CASE_REVIEW_TEST_GYQ_XX")); + caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest); userIds = new ArrayList<>(); userIds.add("gyq_review_test"); userIds.add("gyq_review_test2"); @@ -509,15 +528,15 @@ public class CaseReviewControllerTests extends BaseTest { request.setSelectAll(false); this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request); request.setSelectAll(true); + request.setExcludeIds(List.of(caseReviews.get(0).getId())); this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request); caseReviews = getCaseReviews("创建评审更新1"); String moduleIdNew = caseReviews.get(0).getModuleId(); - Assertions.assertFalse(StringUtils.equals(moduleId, moduleIdNew)); + Assertions.assertTrue(StringUtils.equals(moduleId, moduleIdNew)); request = new CaseReviewBatchRequest(); request.setProjectId(projectId); request.setMoveModuleId("CASE_REVIEW_REAL_MODULE_ID2"); request.setSelectAll(false); - request.setExcludeIds(List.of(caseReviews.get(0).getId())); this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request); caseReviews = getCaseReviews("创建评审更新1"); String moduleIdNewOne = caseReviews.get(0).getModuleId(); @@ -533,6 +552,8 @@ public class CaseReviewControllerTests extends BaseTest { notificationExample.createCriteria().andResourceTypeEqualTo(NoticeConstants.TaskType.CASE_REVIEW_TASK).andResourceIdEqualTo(caseReviews.get(0).getId()).andOperationEqualTo("DELETE"); List notifications = notificationMapper.selectByExampleWithBLOBs(notificationExample); Assertions.assertEquals(1, notifications.size()); + + delCaseReview("caseReviewIdX"); } @@ -563,9 +584,11 @@ public class CaseReviewControllerTests extends BaseTest { CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest(); caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setReviewId(caseReviewId); - List caseIds = new ArrayList<>(); - caseIds.add("CASE_REVIEW_TEST_GYQ_ID2"); - caseReviewAssociateRequest.setCaseIds(caseIds); + BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest(); + baseAssociateCaseRequest.setProjectId(projectId); + baseAssociateCaseRequest.setSelectAll(false); + baseAssociateCaseRequest.setSelectIds(List.of("CASE_REVIEW_TEST_GYQ_ID2")); + caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest); List userIds = new ArrayList<>(); userIds.add("gyq_review_test"); userIds.add("gyq_review_test2"); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/ReviewFunctionalCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/ReviewFunctionalCaseControllerTests.java index 18d0a426d8..5dff0a8ce0 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/ReviewFunctionalCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/ReviewFunctionalCaseControllerTests.java @@ -8,6 +8,7 @@ import io.metersphere.functional.dto.CaseReviewHistoryDTO; import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; import io.metersphere.functional.mapper.CaseReviewHistoryMapper; import io.metersphere.functional.mapper.CaseReviewMapper; +import io.metersphere.functional.request.BaseAssociateCaseRequest; import io.metersphere.functional.request.CaseReviewRequest; import io.metersphere.functional.request.ReviewFunctionalCaseRequest; import io.metersphere.project.domain.Notification; @@ -255,7 +256,11 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { caseReviewRequest.setModuleId("CASE_REVIEW_REAL_MODULE_ID"); caseReviewRequest.setReviewPassRule(CaseReviewPassRule.SINGLE.toString()); caseReviewRequest.setReviewers(reviewers); - caseReviewRequest.setCaseIds(caseIds); + BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest(); + baseAssociateCaseRequest.setSelectAll(false); + baseAssociateCaseRequest.setProjectId(projectId); + baseAssociateCaseRequest.setSelectIds(caseIds); + caseReviewRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest); List tags = new ArrayList<>(); tags.add("11"); caseReviewRequest.setTags(tags); diff --git a/backend/services/case-management/src/test/resources/dml/init_case_review.sql b/backend/services/case-management/src/test/resources/dml/init_case_review.sql index 61a9d964c4..cffb634941 100644 --- a/backend/services/case-management/src/test/resources/dml/init_case_review.sql +++ b/backend/services/case-management/src/test/resources/dml/init_case_review.sql @@ -9,22 +9,22 @@ INSERT INTO template (id, name, remark, internal, update_time, create_time, crea VALUES ('test_template_case_review_gyq_id', 'functional_case_review_gyq', '', b'0', 1696992836000, 1696992836000, 'admin', 'PROJECT', 'project-gyq-case-review-test', b'0', NULL, 'FUNCTIONAL'); INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) -VALUES ('CASE_REVIEW_TEST_GYQ_ID', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试1', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); +VALUES ('CASE_REVIEW_TEST_GYQ_ID', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试1', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) -VALUES ('CASE_REVIEW_TEST_GYQ_ID2', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试2', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID2', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); +VALUES ('CASE_REVIEW_TEST_GYQ_ID2', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试2', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID2', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) -VALUES ('CASE_REVIEW_TEST_GYQ_ID3', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试3', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID3', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); +VALUES ('CASE_REVIEW_TEST_GYQ_ID3', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试3', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID3', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) -VALUES ('CASE_REVIEW_TEST_GYQ_ID4', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试4', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID4', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); +VALUES ('CASE_REVIEW_TEST_GYQ_ID4', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试4', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID4', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) -VALUES ('CASE_REVIEW_TEST_GYQ_ID5', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试5', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID5', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); +VALUES ('CASE_REVIEW_TEST_GYQ_ID5', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试5', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID5', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) -VALUES ('CASE_REVIEW_TEST_GYQ_ID6', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试6', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID6', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); +VALUES ('CASE_REVIEW_TEST_GYQ_ID6', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试6', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID6', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('CASE_REVIEW_TEST_GYQ_ID', 'gyq_custom_id_review1', '22'); INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('CASE_REVIEW_TEST_GYQ_ID', 'gyq_custom_id_review2', '33');