refactor(任务中心): 优化任务中心表结构&任务类型枚举

This commit is contained in:
WangXu10 2024-10-10 15:49:15 +08:00 committed by Craftsman
parent 041df4c6e8
commit cfd1bb7791
5 changed files with 153 additions and 18 deletions

View File

@ -41,6 +41,9 @@ public class ExecTask implements Serializable {
@Size(min = 1, max = 50, message = "{exec_task.task_type.length_range}", groups = {Created.class, Updated.class})
private String taskType;
@Schema(description = "测试计划id")
private String testPlanId;
@Schema(description = "执行模式", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{exec_task.trigger_mode.not_blank}", groups = {Created.class})
@Size(min = 1, max = 20, message = "{exec_task.trigger_mode.length_range}", groups = {Created.class, Updated.class})
@ -78,6 +81,7 @@ public class ExecTask implements Serializable {
caseCount("case_count", "caseCount", "BIGINT", false),
result("result", "result", "VARCHAR", true),
taskType("task_type", "taskType", "VARCHAR", false),
testPlanId("test_plan_id", "testPlanId", "VARCHAR", false),
triggerMode("trigger_mode", "triggerMode", "VARCHAR", false),
projectId("project_id", "projectId", "VARCHAR", false),
organizationId("organization_id", "organizationId", "VARCHAR", false),

View File

@ -574,6 +574,76 @@ public class ExecTaskExample {
return (Criteria) this;
}
public Criteria andTestPlanIdIsNull() {
addCriterion("test_plan_id is null");
return (Criteria) this;
}
public Criteria andTestPlanIdIsNotNull() {
addCriterion("test_plan_id is not null");
return (Criteria) this;
}
public Criteria andTestPlanIdEqualTo(String value) {
addCriterion("test_plan_id =", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotEqualTo(String value) {
addCriterion("test_plan_id <>", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThan(String value) {
addCriterion("test_plan_id >", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) {
addCriterion("test_plan_id >=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThan(String value) {
addCriterion("test_plan_id <", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThanOrEqualTo(String value) {
addCriterion("test_plan_id <=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLike(String value) {
addCriterion("test_plan_id like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotLike(String value) {
addCriterion("test_plan_id not like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdIn(List<String> values) {
addCriterion("test_plan_id in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotIn(List<String> values) {
addCriterion("test_plan_id not in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdBetween(String value1, String value2) {
addCriterion("test_plan_id between", value1, value2, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotBetween(String value1, String value2) {
addCriterion("test_plan_id not between", value1, value2, "testPlanId");
return (Criteria) this;
}
public Criteria andTriggerModeIsNull() {
addCriterion("trigger_mode is null");
return (Criteria) this;

View File

@ -9,6 +9,7 @@
<result column="case_count" jdbcType="BIGINT" property="caseCount" />
<result column="result" jdbcType="VARCHAR" property="result" />
<result column="task_type" jdbcType="VARCHAR" property="taskType" />
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
<result column="trigger_mode" jdbcType="VARCHAR" property="triggerMode" />
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
<result column="organization_id" jdbcType="VARCHAR" property="organizationId" />
@ -76,8 +77,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, num, task_name, `status`, case_count, `result`, task_type, trigger_mode, project_id,
organization_id, create_time, create_user, start_time, end_time
id, num, task_name, `status`, case_count, `result`, task_type, test_plan_id, trigger_mode,
project_id, organization_id, create_time, create_user, start_time, end_time
</sql>
<select id="selectByExample" parameterType="io.metersphere.system.domain.ExecTaskExample" resultMap="BaseResultMap">
select
@ -112,14 +113,16 @@
<insert id="insert" parameterType="io.metersphere.system.domain.ExecTask">
insert into exec_task (id, num, task_name,
`status`, case_count, `result`,
task_type, trigger_mode, project_id,
organization_id, create_time, create_user,
start_time, end_time)
task_type, test_plan_id, trigger_mode,
project_id, organization_id, create_time,
create_user, start_time, end_time
)
values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{taskName,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{caseCount,jdbcType=BIGINT}, #{result,jdbcType=VARCHAR},
#{taskType,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR},
#{organizationId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR},
#{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT})
#{taskType,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{createUser,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.system.domain.ExecTask">
insert into exec_task
@ -145,6 +148,9 @@
<if test="taskType != null">
task_type,
</if>
<if test="testPlanId != null">
test_plan_id,
</if>
<if test="triggerMode != null">
trigger_mode,
</if>
@ -189,6 +195,9 @@
<if test="taskType != null">
#{taskType,jdbcType=VARCHAR},
</if>
<if test="testPlanId != null">
#{testPlanId,jdbcType=VARCHAR},
</if>
<if test="triggerMode != null">
#{triggerMode,jdbcType=VARCHAR},
</if>
@ -242,6 +251,9 @@
<if test="record.taskType != null">
task_type = #{record.taskType,jdbcType=VARCHAR},
</if>
<if test="record.testPlanId != null">
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
</if>
<if test="record.triggerMode != null">
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
</if>
@ -277,6 +289,7 @@
case_count = #{record.caseCount,jdbcType=BIGINT},
`result` = #{record.result,jdbcType=VARCHAR},
task_type = #{record.taskType,jdbcType=VARCHAR},
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
project_id = #{record.projectId,jdbcType=VARCHAR},
organization_id = #{record.organizationId,jdbcType=VARCHAR},
@ -309,6 +322,9 @@
<if test="taskType != null">
task_type = #{taskType,jdbcType=VARCHAR},
</if>
<if test="testPlanId != null">
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
</if>
<if test="triggerMode != null">
trigger_mode = #{triggerMode,jdbcType=VARCHAR},
</if>
@ -341,6 +357,7 @@
case_count = #{caseCount,jdbcType=BIGINT},
`result` = #{result,jdbcType=VARCHAR},
task_type = #{taskType,jdbcType=VARCHAR},
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
trigger_mode = #{triggerMode,jdbcType=VARCHAR},
project_id = #{projectId,jdbcType=VARCHAR},
organization_id = #{organizationId,jdbcType=VARCHAR},
@ -352,15 +369,16 @@
</update>
<insert id="batchInsert" parameterType="map">
insert into exec_task
(id, num, task_name, `status`, case_count, `result`, task_type, trigger_mode, project_id,
organization_id, create_time, create_user, start_time, end_time)
(id, num, task_name, `status`, case_count, `result`, task_type, test_plan_id, trigger_mode,
project_id, organization_id, create_time, create_user, start_time, end_time)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.taskName,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR}, #{item.caseCount,jdbcType=BIGINT}, #{item.result,jdbcType=VARCHAR},
#{item.taskType,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR},
#{item.organizationId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR},
#{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT})
#{item.taskType,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR},
#{item.projectId,jdbcType=VARCHAR}, #{item.organizationId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT},
#{item.createUser,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}
)
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -394,6 +412,9 @@
<if test="'task_type'.toString() == column.value">
#{item.taskType,jdbcType=VARCHAR}
</if>
<if test="'test_plan_id'.toString() == column.value">
#{item.testPlanId,jdbcType=VARCHAR}
</if>
<if test="'trigger_mode'.toString() == column.value">
#{item.triggerMode,jdbcType=VARCHAR}
</if>

View File

@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS exec_task(
`case_count` BIGINT NOT NULL COMMENT '用例数量' ,
`result` VARCHAR(64) COMMENT '执行结果' ,
`task_type` VARCHAR(50) NOT NULL COMMENT '任务类型' ,
`test_plan_id` VARCHAR(50) COMMENT '测试计划id' ,
`trigger_mode` VARCHAR(20) NOT NULL COMMENT '执行模式' ,
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID' ,
`organization_id` VARCHAR(50) NOT NULL COMMENT '组织ID' ,
@ -28,8 +29,6 @@ CREATE INDEX idx_status ON exec_task(status);
CREATE INDEX idx_result ON exec_task(result);
CREATE INDEX idx_project_id ON exec_task(project_id);
CREATE INDEX idx_organization_id ON exec_task(organization_id);
CREATE INDEX idx_create_time ON exec_task(create_time desc);
CREATE INDEX idx_create_user ON exec_task(create_user);
CREATE INDEX idx_start_time ON exec_task(start_time);
CREATE INDEX idx_end_time ON exec_task(end_time);
CREATE INDEX idx_trigger_mode ON exec_task(trigger_mode);
@ -63,11 +62,8 @@ CREATE INDEX idx_resource_id ON exec_task_item(resource_id);
CREATE INDEX idx_resource_name ON exec_task_item(resource_name);
CREATE INDEX idx_status ON exec_task_item(status);
CREATE INDEX idx_result ON exec_task_item(result);
CREATE INDEX idx_resource_pool_id ON exec_task_item(resource_pool_id);
CREATE INDEX idx_resource_pool_node ON exec_task_item(resource_pool_node);
CREATE INDEX idx_project_id ON exec_task_item(project_id);
CREATE INDEX idx_organization_id ON exec_task_item(organization_id);
CREATE INDEX idx_thread_id ON exec_task_item(thread_id);
CREATE INDEX idx_start_time ON exec_task_item(start_time desc);
CREATE INDEX idx_end_time ON exec_task_item(end_time desc);
CREATE INDEX idx_executor ON exec_task_item(executor);

View File

@ -0,0 +1,44 @@
package io.metersphere.sdk.constants;
public enum ExecTaskType {
/**
* 接口用例执行
*/
API_CASE,
/**
* 接口用例批量执行
*/
API_CASE_BATCH,
/**
* 场景执行
*/
API_SCENARIO,
/**
* 场景批量执行
*/
API_SCENARIO_BATCH,
/**
* 测试计划接口用例执行
*/
TEST_PLAN_API_CASE,
/**
* 测试计划接口用例批量执行
*/
TEST_PLAN_API_CASE_BATCH,
/**
* 测试计划场景用例执行
*/
TEST_PLAN_API_SCENARIO,
/**
* 测试计划场景用例批量执行
*/
TEST_PLAN_API_SCENARIO_BATCH,
/**
* 测试计划整体执行
*/
TEST_PLAN,
/**
* 测试计划组整体执行
*/
TEST_PLAN_GROUP
}