From ec4902f78b1d894dea2160a7e228805f4fcb536d Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Fri, 10 Nov 2023 14:09:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=94=A8=E4=BE=8B=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20num=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../functional/domain/FunctionalCase.java | 8 ++++---- .../domain/FunctionalCaseExample.java | 20 +++++++++---------- .../mapper/FunctionalCaseMapper.xml | 18 ++++++++--------- .../3.0.0/ddl/V3.0.0_10__functional_case.sql | 4 ++-- .../service/FunctionalCaseService.java | 7 ++----- .../FunctionalCaseModuleControllerTests.java | 2 +- 6 files changed, 28 insertions(+), 31 deletions(-) diff --git a/backend/framework/domain/src/main/java/io/metersphere/functional/domain/FunctionalCase.java b/backend/framework/domain/src/main/java/io/metersphere/functional/domain/FunctionalCase.java index 076ef11135..c3740657ea 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/functional/domain/FunctionalCase.java +++ b/backend/framework/domain/src/main/java/io/metersphere/functional/domain/FunctionalCase.java @@ -4,6 +4,7 @@ import io.metersphere.validation.groups.Created; import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import java.io.Serializable; import java.util.ArrayList; @@ -18,9 +19,8 @@ public class FunctionalCase implements Serializable { private String id; @Schema(description = "业务ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{functional_case.num.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 10, message = "{functional_case.num.length_range}", groups = {Created.class, Updated.class}) - private Integer num; + @NotNull(message = "{functional_case.num.not_blank}", groups = {Created.class}) + private Long num; @Schema(description = "模块ID", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{functional_case.module_id.not_blank}", groups = {Created.class}) @@ -112,7 +112,7 @@ public class FunctionalCase implements Serializable { public enum Column { id("id", "id", "VARCHAR", false), - num("num", "num", "INTEGER", false), + num("num", "num", "BIGINT", false), moduleId("module_id", "moduleId", "VARCHAR", false), projectId("project_id", "projectId", "VARCHAR", false), templateId("template_id", "templateId", "VARCHAR", false), diff --git a/backend/framework/domain/src/main/java/io/metersphere/functional/domain/FunctionalCaseExample.java b/backend/framework/domain/src/main/java/io/metersphere/functional/domain/FunctionalCaseExample.java index 25e5a4c6ba..02f4e5b88d 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/functional/domain/FunctionalCaseExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/functional/domain/FunctionalCaseExample.java @@ -184,52 +184,52 @@ public class FunctionalCaseExample { return (Criteria) this; } - public Criteria andNumEqualTo(Integer value) { + public Criteria andNumEqualTo(Long value) { addCriterion("num =", value, "num"); return (Criteria) this; } - public Criteria andNumNotEqualTo(Integer value) { + public Criteria andNumNotEqualTo(Long value) { addCriterion("num <>", value, "num"); return (Criteria) this; } - public Criteria andNumGreaterThan(Integer value) { + public Criteria andNumGreaterThan(Long value) { addCriterion("num >", value, "num"); return (Criteria) this; } - public Criteria andNumGreaterThanOrEqualTo(Integer value) { + public Criteria andNumGreaterThanOrEqualTo(Long value) { addCriterion("num >=", value, "num"); return (Criteria) this; } - public Criteria andNumLessThan(Integer value) { + public Criteria andNumLessThan(Long value) { addCriterion("num <", value, "num"); return (Criteria) this; } - public Criteria andNumLessThanOrEqualTo(Integer value) { + public Criteria andNumLessThanOrEqualTo(Long value) { addCriterion("num <=", value, "num"); return (Criteria) this; } - public Criteria andNumIn(List values) { + public Criteria andNumIn(List values) { addCriterion("num in", values, "num"); return (Criteria) this; } - public Criteria andNumNotIn(List values) { + public Criteria andNumNotIn(List values) { addCriterion("num not in", values, "num"); return (Criteria) this; } - public Criteria andNumBetween(Integer value1, Integer value2) { + public Criteria andNumBetween(Long value1, Long value2) { addCriterion("num between", value1, value2, "num"); return (Criteria) this; } - public Criteria andNumNotBetween(Integer value1, Integer value2) { + public Criteria andNumNotBetween(Long value1, Long value2) { addCriterion("num not between", value1, value2, "num"); return (Criteria) this; } diff --git a/backend/framework/domain/src/main/java/io/metersphere/functional/mapper/FunctionalCaseMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/functional/mapper/FunctionalCaseMapper.xml index 4c893b1462..7d976be6ff 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/functional/mapper/FunctionalCaseMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/functional/mapper/FunctionalCaseMapper.xml @@ -3,7 +3,7 @@ - + @@ -127,7 +127,7 @@ latest, create_user, update_user, delete_user, create_time, update_time, delete_time) - values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=INTEGER}, #{moduleId,jdbcType=VARCHAR}, + values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{moduleId,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{templateId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{reviewStatus,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, #{caseEditType,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT}, #{versionId,jdbcType=VARCHAR}, #{refId,jdbcType=VARCHAR}, @@ -211,7 +211,7 @@ #{id,jdbcType=VARCHAR}, - #{num,jdbcType=INTEGER}, + #{num,jdbcType=BIGINT}, #{moduleId,jdbcType=VARCHAR}, @@ -288,7 +288,7 @@ id = #{record.id,jdbcType=VARCHAR}, - num = #{record.num,jdbcType=INTEGER}, + num = #{record.num,jdbcType=BIGINT}, module_id = #{record.moduleId,jdbcType=VARCHAR}, @@ -358,7 +358,7 @@ update functional_case set id = #{record.id,jdbcType=VARCHAR}, - num = #{record.num,jdbcType=INTEGER}, + num = #{record.num,jdbcType=BIGINT}, module_id = #{record.moduleId,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR}, template_id = #{record.templateId,jdbcType=VARCHAR}, @@ -387,7 +387,7 @@ update functional_case - num = #{num,jdbcType=INTEGER}, + num = #{num,jdbcType=BIGINT}, module_id = #{moduleId,jdbcType=VARCHAR}, @@ -454,7 +454,7 @@ update functional_case - set num = #{num,jdbcType=INTEGER}, + set num = #{num,jdbcType=BIGINT}, module_id = #{moduleId,jdbcType=VARCHAR}, project_id = #{projectId,jdbcType=VARCHAR}, template_id = #{templateId,jdbcType=VARCHAR}, @@ -484,7 +484,7 @@ update_user, delete_user, create_time, update_time, delete_time) values - (#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=INTEGER}, #{item.moduleId,jdbcType=VARCHAR}, + (#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.moduleId,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.templateId,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.reviewStatus,jdbcType=VARCHAR}, #{item.tags,jdbcType=VARCHAR}, #{item.caseEditType,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT}, #{item.versionId,jdbcType=VARCHAR}, #{item.refId,jdbcType=VARCHAR}, @@ -508,7 +508,7 @@ #{item.id,jdbcType=VARCHAR} - #{item.num,jdbcType=INTEGER} + #{item.num,jdbcType=BIGINT} #{item.moduleId,jdbcType=VARCHAR} 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 74872236ef..e0f4011f80 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 @@ -3,7 +3,7 @@ SET SESSION innodb_lock_wait_timeout = 7200; CREATE TABLE IF NOT EXISTS functional_case( `id` VARCHAR(50) NOT NULL COMMENT 'ID' , - `num` INT NOT NULL COMMENT '业务ID' , + `num` BIGINT NOT NULL COMMENT '业务ID' , `module_id` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '模块ID' , `project_id` VARCHAR(50) NOT NULL COMMENT '项目ID' , `template_id` VARCHAR(50) NOT NULL COMMENT '模板ID' , @@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS functional_case( DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '功能用例'; - +CREATE INDEX idx_num ON functional_case(num); CREATE INDEX idx_module_id ON functional_case(module_id); CREATE INDEX idx_project_id_pos ON functional_case(project_id,pos); CREATE INDEX idx_public_case_pos ON functional_case(public_case,pos); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java index ebc58d6c2f..b98f22565f 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java @@ -34,7 +34,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -130,10 +129,8 @@ public class FunctionalCaseService { return (pos == null ? 0 : pos) + ORDER_STEP; } - public int getNextNum(String projectId) { - long nextNum = NumGenerator.nextNum(projectId, ApplicationNumScope.CASE_MANAGEMENT); - BigDecimal bigDecimal = new BigDecimal(nextNum); - return bigDecimal.intValue(); + public long getNextNum(String projectId) { + return NumGenerator.nextNum(projectId, ApplicationNumScope.CASE_MANAGEMENT); } diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseModuleControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseModuleControllerTests.java index d6e2cfae9d..574aea2f40 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseModuleControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseModuleControllerTests.java @@ -723,7 +723,7 @@ public class FunctionalCaseModuleControllerTests extends BaseTest { private FunctionalCase createCase(BaseTreeNode a1a1Node, Boolean deleted, String name) { FunctionalCase functionalCase = new FunctionalCase(); functionalCase.setName(name); - functionalCase.setNum(100001); + functionalCase.setNum(100001l); functionalCase.setModuleId(a1a1Node.getId()); functionalCase.setProjectId(project.getId()); functionalCase.setDeleted(deleted);