From 25a957cabe9876fc036a14432417ad38958e6c84 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 4 Dec 2023 19:36:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E5=85=B3=E8=81=94=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/CaseReviewFunctionalCase.java | 12 +++-- .../3.0.0/ddl/V3.0.0_10__functional_case.sql | 2 +- .../constants/CaseReviewPassRule.java | 24 +-------- .../constants/CaseReviewStatus.java | 29 ++--------- .../FunctionalCaseReviewController.java | 39 +++++++++++++++ .../functional/dto/CaseReviewDTO.java | 3 -- .../dto/FunctionalCaseReviewDTO.java | 23 +++++++++ .../ExtCaseReviewFunctionalCaseMapper.java | 16 ++++++ .../ExtCaseReviewFunctionalCaseMapper.xml | 19 +++++++ .../FunctionalCaseReviewListRequest.java | 14 ++++++ .../functional/service/CaseReviewService.java | 2 - .../service/FunctionalCaseReviewService.java | 29 +++++++++++ .../service/FunctionalCaseTestService.java | 15 ------ .../FunctionalCaseReviewControllerTests.java | 49 +++++++++++++++++++ .../dml/init_case_review_functional_case.sql | 17 +++++++ 15 files changed, 221 insertions(+), 72 deletions(-) create mode 100644 backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseReviewController.java create mode 100644 backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseReviewDTO.java create mode 100644 backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java create mode 100644 backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml create mode 100644 backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalCaseReviewListRequest.java create mode 100644 backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseReviewService.java delete mode 100644 backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseTestService.java create mode 100644 backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseReviewControllerTests.java create mode 100644 backend/services/case-management/src/test/resources/dml/init_case_review_functional_case.sql diff --git a/backend/framework/domain/src/main/java/io/metersphere/functional/domain/CaseReviewFunctionalCase.java b/backend/framework/domain/src/main/java/io/metersphere/functional/domain/CaseReviewFunctionalCase.java index f03aa83bb9..16c8d4164f 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/functional/domain/CaseReviewFunctionalCase.java +++ b/backend/framework/domain/src/main/java/io/metersphere/functional/domain/CaseReviewFunctionalCase.java @@ -1,12 +1,16 @@ package io.metersphere.functional.domain; -import io.metersphere.validation.groups.*; +import io.metersphere.validation.groups.Created; +import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Data; + import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; -import lombok.Data; @Data public class CaseReviewFunctionalCase implements Serializable { @@ -25,7 +29,7 @@ public class CaseReviewFunctionalCase implements Serializable { @Size(min = 1, max = 50, message = "{case_review_functional_case.case_id.length_range}", groups = {Created.class, Updated.class}) private String caseId; - @Schema(description = "评审状态:进行中/通过/不通过/重新提审", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "评审结果:进行中/通过/不通过/重新提审", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{case_review_functional_case.status.not_blank}", groups = {Created.class}) @Size(min = 1, max = 64, message = "{case_review_functional_case.status.length_range}", groups = {Created.class, Updated.class}) private String status; diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_10__functional_case.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_10__functional_case.sql index 9234bb7328..67daae66d4 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_10__functional_case.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_10__functional_case.sql @@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS functional_case `project_id` VARCHAR(50) NOT NULL COMMENT '项目ID', `template_id` VARCHAR(50) NOT NULL COMMENT '模板ID', `name` VARCHAR(255) NOT NULL COMMENT '名称', - `review_status` VARCHAR(64) NOT NULL DEFAULT 'UN_REVIEWED' COMMENT '评审状态:未评审/评审中/通过/不通过/重新提审', + `review_status` VARCHAR(64) NOT NULL DEFAULT 'UN_REVIEWED' COMMENT '评审结果:未评审/评审中/通过/不通过/重新提审', `tags` VARCHAR(1000) COMMENT '标签(JSON)', `case_edit_type` VARCHAR(50) NOT NULL DEFAULT 'STEP' COMMENT '编辑模式:步骤模式/文本模式', `pos` BIGINT NOT NULL DEFAULT 0 COMMENT '自定义排序,间隔5000', diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/constants/CaseReviewPassRule.java b/backend/services/case-management/src/main/java/io/metersphere/functional/constants/CaseReviewPassRule.java index 746a5c5bf0..ffb5e4fcfe 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/constants/CaseReviewPassRule.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/constants/CaseReviewPassRule.java @@ -1,26 +1,6 @@ package io.metersphere.functional.constants; -import io.metersphere.sdk.util.Translator; - public enum CaseReviewPassRule { - SINGLE("case_review.single"), - MULTIPLE("case_review.multiple"); - - private final String name; - - CaseReviewPassRule(String name) { - this.name = name; - } - - public String getName() { - return getTranslationName(this.name); - } - - /** - * 返回国际化后的规则信息 - * 如果没有匹配则返回原文 - */ - String getTranslationName(String name) { - return Translator.get(name, name); - } + SINGLE, + MULTIPLE } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/constants/CaseReviewStatus.java b/backend/services/case-management/src/main/java/io/metersphere/functional/constants/CaseReviewStatus.java index 282f01ca2e..0ff5db357a 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/constants/CaseReviewStatus.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/constants/CaseReviewStatus.java @@ -1,30 +1,9 @@ package io.metersphere.functional.constants; -import io.metersphere.sdk.util.Translator; - public enum CaseReviewStatus { - - PREPARED("case_review.prepared"), - UNDERWAY("case_review.underway"), - COMPLETED("case_review.completed"), - ARCHIVED("case_review.archived"); - - private final String name; - - CaseReviewStatus(String name) { - this.name = name; - } - - public String getName() { - return getTranslationName(this.name); - } - - /** - * 返回国际化后的状态信息 - * 如果没有匹配则返回原文 - */ - String getTranslationName(String name) { - return Translator.get(name, name); - } + PREPARED, + UNDERWAY, + COMPLETED, + ARCHIVED } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseReviewController.java b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseReviewController.java new file mode 100644 index 0000000000..97e85024c8 --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseReviewController.java @@ -0,0 +1,39 @@ +package io.metersphere.functional.controller; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import io.metersphere.functional.dto.FunctionalCaseReviewDTO; +import io.metersphere.functional.request.FunctionalCaseReviewListRequest; +import io.metersphere.functional.service.FunctionalCaseReviewService; +import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.system.utils.PageUtils; +import io.metersphere.system.utils.Pager; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@Tag(name = "用例管理-功能用例-用例评审") +@RestController +@RequestMapping("/functional/case/review") +public class FunctionalCaseReviewController { + + @Resource + private FunctionalCaseReviewService functionalCaseReviewService; + + @PostMapping("/page") + @Operation(summary = "用例管理-功能用例-用例评审-列表") + @RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ) + public Pager> getFunctionalCasePage(@Validated @RequestBody FunctionalCaseReviewListRequest request) { + Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), "update_time desc"); + return PageUtils.setPageInfo(page, functionalCaseReviewService.getFunctionalCaseReviewPage(request)); + } + +} diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/CaseReviewDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/CaseReviewDTO.java index 18f47b5d99..feb51016d9 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/CaseReviewDTO.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/CaseReviewDTO.java @@ -27,9 +27,6 @@ public class CaseReviewDTO extends CaseReview { @Schema(description = "已评审过得用例数") private int reviewedCount; - @Schema(description = "评审状态名称") - private String statusName; - @Schema(description = "关注标识") private Boolean followFlag; } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseReviewDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseReviewDTO.java new file mode 100644 index 0000000000..c1a01e447a --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseReviewDTO.java @@ -0,0 +1,23 @@ +package io.metersphere.functional.dto; + +import io.metersphere.functional.domain.CaseReviewFunctionalCase; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +@Data +public class FunctionalCaseReviewDTO extends CaseReviewFunctionalCase { + + @Schema(description = "评审Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{case_review_functional_case.review_name.not_blank}") + private String reviewNum; + + @Schema(description = "评审名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{case_review_functional_case.review_name.not_blank}") + private String reviewName; + + @Schema(description = "用例评审状态", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{case_review_functional_case.review_status.not_blank}") + private String reviewStatus; + +} 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 new file mode 100644 index 0000000000..22bcdf0ede --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java @@ -0,0 +1,16 @@ +package io.metersphere.functional.mapper; + +import io.metersphere.functional.dto.FunctionalCaseReviewDTO; +import io.metersphere.functional.request.FunctionalCaseReviewListRequest; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author guoyuqi + */ +public interface ExtCaseReviewFunctionalCaseMapper { + + List list(@Param("request") FunctionalCaseReviewListRequest request); + +} 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 new file mode 100644 index 0000000000..1ec631381f --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalCaseReviewListRequest.java b/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalCaseReviewListRequest.java new file mode 100644 index 0000000000..7b64e4334d --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalCaseReviewListRequest.java @@ -0,0 +1,14 @@ +package io.metersphere.functional.request; + +import io.metersphere.system.dto.sdk.BasePageRequest; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class FunctionalCaseReviewListRequest extends BasePageRequest { + @Schema(description = "功能用例id") + private String caseId; + +} 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 7eb3f2d79d..67d0ab6ecd 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 @@ -113,8 +113,6 @@ public class CaseReviewService { } buildReviewers(caseReviewDTO, reviewUserMap); - - caseReviewDTO.setStatusName(CaseReviewStatus.valueOf(caseReviewDTO.getStatus()).getName()); } private static void buildReviewers(CaseReviewDTO caseReviewDTO, Map> reviewUserMap) { diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseReviewService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseReviewService.java new file mode 100644 index 0000000000..6523133d66 --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseReviewService.java @@ -0,0 +1,29 @@ +package io.metersphere.functional.service; + + +import io.metersphere.functional.dto.FunctionalCaseReviewDTO; +import io.metersphere.functional.mapper.ExtCaseReviewFunctionalCaseMapper; +import io.metersphere.functional.request.FunctionalCaseReviewListRequest; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + + +/** + * 功能用例和其他用例的中间表服务实现类 + * + * @date : 2023-5-17 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class FunctionalCaseReviewService { + + @Resource + private ExtCaseReviewFunctionalCaseMapper extCaseReviewFunctionalCaseMapper; + + public List getFunctionalCaseReviewPage(FunctionalCaseReviewListRequest request) { + return extCaseReviewFunctionalCaseMapper.list(request); + } +} \ No newline at end of file diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseTestService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseTestService.java deleted file mode 100644 index a0a3768f11..0000000000 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseTestService.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.metersphere.functional.service; - - -import org.springframework.stereotype.Service; - - -/** - * 功能用例和其他用例的中间表服务实现类 - * - * @date : 2023-5-17 - */ -@Service -public class FunctionalCaseTestService { - -} \ No newline at end of file diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseReviewControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseReviewControllerTests.java new file mode 100644 index 0000000000..a0050252cb --- /dev/null +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseReviewControllerTests.java @@ -0,0 +1,49 @@ +package io.metersphere.functional.controller; + +import io.metersphere.functional.dto.FunctionalCaseReviewDTO; +import io.metersphere.functional.request.FunctionalCaseReviewListRequest; +import io.metersphere.sdk.util.JSON; +import io.metersphere.system.base.BaseTest; +import io.metersphere.system.controller.handler.ResultHolder; +import io.metersphere.system.utils.Pager; +import org.junit.jupiter.api.*; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.jdbc.SqlConfig; +import org.springframework.test.web.servlet.MvcResult; + +import java.nio.charset.StandardCharsets; +import java.util.List; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +@AutoConfigureMockMvc +public class FunctionalCaseReviewControllerTests extends BaseTest { + + private static final String URL_CASE_REVIEW_PAGE = "/functional/case/review/page"; + + @Test + @Order(1) + @Sql(scripts = {"/dml/init_case_review_functional_case.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED)) + public void testGetPageList() throws Exception { + FunctionalCaseReviewListRequest functionalCaseReviewListRequest = new FunctionalCaseReviewListRequest(); + functionalCaseReviewListRequest.setCaseId("associate_case_gyq_id"); + functionalCaseReviewListRequest.setCurrent(1); + functionalCaseReviewListRequest.setPageSize(10); + MvcResult mvcResult = this.requestPostWithOkAndReturn(URL_CASE_REVIEW_PAGE, functionalCaseReviewListRequest); + Pager> tableData = JSON.parseObject(JSON.toJSONString( + JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()), + Pager.class); + //返回值的页码和当前页码相同 + Assertions.assertEquals(tableData.getCurrent(), functionalCaseReviewListRequest.getCurrent()); + + //返回的数据量不超过规定要返回的数据量相同 + Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(tableData.getList())).size() <= functionalCaseReviewListRequest.getPageSize()); + List fileList = JSON.parseArray(JSON.toJSONString(tableData.getList()), FunctionalCaseReviewDTO.class); + String jsonString = JSON.toJSONString(fileList); + System.out.println(jsonString); + } + + +} diff --git a/backend/services/case-management/src/test/resources/dml/init_case_review_functional_case.sql b/backend/services/case-management/src/test/resources/dml/init_case_review_functional_case.sql new file mode 100644 index 0000000000..f32edfc349 --- /dev/null +++ b/backend/services/case-management/src/test/resources/dml/init_case_review_functional_case.sql @@ -0,0 +1,17 @@ + +INSERT INTO case_review(id, num, name, module_id, project_id, status, review_pass_rule, pos, start_time, end_time, case_count, pass_rate, tags, description, create_time, create_user, update_time, update_user) +VALUES ('case_review_associate_Id',10001,'用例关系名称1', 'test_module_one', 'case_review_relevence_project_gyq', 'COMPLETED', 'SINGLE', 001, null, null, 1,100.00,null,null,1698058347559,'admin',1698058347559,'admin'), + ('case_review_associate_Id2',10002,'用例关系名称2', 'test_module_one', 'case_review_relevence_project_gyq', 'COMPLETED', 'SINGLE', 001, null, null, 1,100.00,null,null,1698058347559,'admin',1698058347559,'admin'); + +INSERT INTO case_review_functional_case(id, review_id, case_id, status, create_time, create_user, update_time) +VALUES ('associate_id1', 'case_review_associate_Id', 'associate_case_gyq_id', 'PASS', 1698058347559,'admin',1698058347559), + ('associate_id2', 'case_review_associate_Id2', 'associate_case_gyq_id', 'PASS', 1698058347559,'admin',1698058347559); + + + + + + + + +