refactor(用例管理): num字段类型优化

This commit is contained in:
WangXu10 2023-11-10 14:09:32 +08:00 committed by 刘瑞斌
parent e46b2d1eaf
commit ec4902f78b
6 changed files with 28 additions and 31 deletions

View File

@ -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),

View File

@ -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<Integer> values) {
public Criteria andNumIn(List<Long> values) {
addCriterion("num in", values, "num");
return (Criteria) this;
}
public Criteria andNumNotIn(List<Integer> values) {
public Criteria andNumNotIn(List<Long> 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;
}

View File

@ -3,7 +3,7 @@
<mapper namespace="io.metersphere.functional.mapper.FunctionalCaseMapper">
<resultMap id="BaseResultMap" type="io.metersphere.functional.domain.FunctionalCase">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="num" jdbcType="INTEGER" property="num" />
<result column="num" jdbcType="BIGINT" property="num" />
<result column="module_id" jdbcType="VARCHAR" property="moduleId" />
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
<result column="template_id" jdbcType="VARCHAR" property="templateId" />
@ -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},
</if>
<if test="num != null">
#{num,jdbcType=INTEGER},
#{num,jdbcType=BIGINT},
</if>
<if test="moduleId != null">
#{moduleId,jdbcType=VARCHAR},
@ -288,7 +288,7 @@
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.num != null">
num = #{record.num,jdbcType=INTEGER},
num = #{record.num,jdbcType=BIGINT},
</if>
<if test="record.moduleId != null">
module_id = #{record.moduleId,jdbcType=VARCHAR},
@ -358,7 +358,7 @@
<update id="updateByExample" parameterType="map">
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
<set>
<if test="num != null">
num = #{num,jdbcType=INTEGER},
num = #{num,jdbcType=BIGINT},
</if>
<if test="moduleId != null">
module_id = #{moduleId,jdbcType=VARCHAR},
@ -454,7 +454,7 @@
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.functional.domain.FunctionalCase">
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
<foreach collection="list" item="item" separator=",">
(#{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}
</if>
<if test="'num'.toString() == column.value">
#{item.num,jdbcType=INTEGER}
#{item.num,jdbcType=BIGINT}
</if>
<if test="'module_id'.toString() == column.value">
#{item.moduleId,jdbcType=VARCHAR}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);