refactor(测试计划): 部分接口优化

This commit is contained in:
WangXu10 2024-06-05 15:12:11 +08:00 committed by Craftsman
parent 382526854a
commit a7356c2d98
18 changed files with 168 additions and 46 deletions

View File

@ -40,10 +40,15 @@ public class TestPlanFunctionalCase implements Serializable {
@Schema(description = "最后执行结果") @Schema(description = "最后执行结果")
private String lastExecResult; private String lastExecResult;
@Schema(description = "自定义排序,间隔5000", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "自定义排序,间隔为2的n次幂", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{test_plan_functional_case.pos.not_blank}", groups = {Created.class}) @NotNull(message = "{test_plan_functional_case.pos.not_blank}", groups = {Created.class})
private Long pos; private Long pos;
@Schema(description = "测试计划集id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{test_plan_functional_case.test_plan_collection_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{test_plan_functional_case.test_plan_collection_id.length_range}", groups = {Created.class, Updated.class})
private String testPlanCollectionId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public enum Column { public enum Column {
@ -55,7 +60,8 @@ public class TestPlanFunctionalCase implements Serializable {
executeUser("execute_user", "executeUser", "VARCHAR", false), executeUser("execute_user", "executeUser", "VARCHAR", false),
lastExecTime("last_exec_time", "lastExecTime", "BIGINT", false), lastExecTime("last_exec_time", "lastExecTime", "BIGINT", false),
lastExecResult("last_exec_result", "lastExecResult", "VARCHAR", false), lastExecResult("last_exec_result", "lastExecResult", "VARCHAR", false),
pos("pos", "pos", "BIGINT", false); pos("pos", "pos", "BIGINT", false),
testPlanCollectionId("test_plan_collection_id", "testPlanCollectionId", "VARCHAR", false);
private static final String BEGINNING_DELIMITER = "`"; private static final String BEGINNING_DELIMITER = "`";

View File

@ -703,6 +703,76 @@ public class TestPlanFunctionalCaseExample {
addCriterion("pos not between", value1, value2, "pos"); addCriterion("pos not between", value1, value2, "pos");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestPlanCollectionIdIsNull() {
addCriterion("test_plan_collection_id is null");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdIsNotNull() {
addCriterion("test_plan_collection_id is not null");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdEqualTo(String value) {
addCriterion("test_plan_collection_id =", value, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdNotEqualTo(String value) {
addCriterion("test_plan_collection_id <>", value, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdGreaterThan(String value) {
addCriterion("test_plan_collection_id >", value, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdGreaterThanOrEqualTo(String value) {
addCriterion("test_plan_collection_id >=", value, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdLessThan(String value) {
addCriterion("test_plan_collection_id <", value, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdLessThanOrEqualTo(String value) {
addCriterion("test_plan_collection_id <=", value, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdLike(String value) {
addCriterion("test_plan_collection_id like", value, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdNotLike(String value) {
addCriterion("test_plan_collection_id not like", value, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdIn(List<String> values) {
addCriterion("test_plan_collection_id in", values, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdNotIn(List<String> values) {
addCriterion("test_plan_collection_id not in", values, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdBetween(String value1, String value2) {
addCriterion("test_plan_collection_id between", value1, value2, "testPlanCollectionId");
return (Criteria) this;
}
public Criteria andTestPlanCollectionIdNotBetween(String value1, String value2) {
addCriterion("test_plan_collection_id not between", value1, value2, "testPlanCollectionId");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -11,6 +11,7 @@
<result column="last_exec_time" jdbcType="BIGINT" property="lastExecTime" /> <result column="last_exec_time" jdbcType="BIGINT" property="lastExecTime" />
<result column="last_exec_result" jdbcType="VARCHAR" property="lastExecResult" /> <result column="last_exec_result" jdbcType="VARCHAR" property="lastExecResult" />
<result column="pos" jdbcType="BIGINT" property="pos" /> <result column="pos" jdbcType="BIGINT" property="pos" />
<result column="test_plan_collection_id" jdbcType="VARCHAR" property="testPlanCollectionId" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -72,7 +73,7 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, test_plan_id, functional_case_id, create_time, create_user, execute_user, last_exec_time, id, test_plan_id, functional_case_id, create_time, create_user, execute_user, last_exec_time,
last_exec_result, pos last_exec_result, pos, test_plan_collection_id
</sql> </sql>
<select id="selectByExample" parameterType="io.metersphere.plan.domain.TestPlanFunctionalCaseExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.metersphere.plan.domain.TestPlanFunctionalCaseExample" resultMap="BaseResultMap">
select select
@ -107,12 +108,12 @@
<insert id="insert" parameterType="io.metersphere.plan.domain.TestPlanFunctionalCase"> <insert id="insert" parameterType="io.metersphere.plan.domain.TestPlanFunctionalCase">
insert into test_plan_functional_case (id, test_plan_id, functional_case_id, insert into test_plan_functional_case (id, test_plan_id, functional_case_id,
create_time, create_user, execute_user, create_time, create_user, execute_user,
last_exec_time, last_exec_result, pos last_exec_time, last_exec_result, pos,
) test_plan_collection_id)
values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{functionalCaseId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{functionalCaseId,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{executeUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{executeUser,jdbcType=VARCHAR},
#{lastExecTime,jdbcType=BIGINT}, #{lastExecResult,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT} #{lastExecTime,jdbcType=BIGINT}, #{lastExecResult,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT},
) #{testPlanCollectionId,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.plan.domain.TestPlanFunctionalCase"> <insert id="insertSelective" parameterType="io.metersphere.plan.domain.TestPlanFunctionalCase">
insert into test_plan_functional_case insert into test_plan_functional_case
@ -144,6 +145,9 @@
<if test="pos != null"> <if test="pos != null">
pos, pos,
</if> </if>
<if test="testPlanCollectionId != null">
test_plan_collection_id,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -173,6 +177,9 @@
<if test="pos != null"> <if test="pos != null">
#{pos,jdbcType=BIGINT}, #{pos,jdbcType=BIGINT},
</if> </if>
<if test="testPlanCollectionId != null">
#{testPlanCollectionId,jdbcType=VARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.plan.domain.TestPlanFunctionalCaseExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.plan.domain.TestPlanFunctionalCaseExample" resultType="java.lang.Long">
@ -211,6 +218,9 @@
<if test="record.pos != null"> <if test="record.pos != null">
pos = #{record.pos,jdbcType=BIGINT}, pos = #{record.pos,jdbcType=BIGINT},
</if> </if>
<if test="record.testPlanCollectionId != null">
test_plan_collection_id = #{record.testPlanCollectionId,jdbcType=VARCHAR},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -226,7 +236,8 @@
execute_user = #{record.executeUser,jdbcType=VARCHAR}, execute_user = #{record.executeUser,jdbcType=VARCHAR},
last_exec_time = #{record.lastExecTime,jdbcType=BIGINT}, last_exec_time = #{record.lastExecTime,jdbcType=BIGINT},
last_exec_result = #{record.lastExecResult,jdbcType=VARCHAR}, last_exec_result = #{record.lastExecResult,jdbcType=VARCHAR},
pos = #{record.pos,jdbcType=BIGINT} pos = #{record.pos,jdbcType=BIGINT},
test_plan_collection_id = #{record.testPlanCollectionId,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -258,6 +269,9 @@
<if test="pos != null"> <if test="pos != null">
pos = #{pos,jdbcType=BIGINT}, pos = #{pos,jdbcType=BIGINT},
</if> </if>
<if test="testPlanCollectionId != null">
test_plan_collection_id = #{testPlanCollectionId,jdbcType=VARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -270,19 +284,20 @@
execute_user = #{executeUser,jdbcType=VARCHAR}, execute_user = #{executeUser,jdbcType=VARCHAR},
last_exec_time = #{lastExecTime,jdbcType=BIGINT}, last_exec_time = #{lastExecTime,jdbcType=BIGINT},
last_exec_result = #{lastExecResult,jdbcType=VARCHAR}, last_exec_result = #{lastExecResult,jdbcType=VARCHAR},
pos = #{pos,jdbcType=BIGINT} pos = #{pos,jdbcType=BIGINT},
test_plan_collection_id = #{testPlanCollectionId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<insert id="batchInsert" parameterType="map"> <insert id="batchInsert" parameterType="map">
insert into test_plan_functional_case insert into test_plan_functional_case
(id, test_plan_id, functional_case_id, create_time, create_user, execute_user, last_exec_time, (id, test_plan_id, functional_case_id, create_time, create_user, execute_user, last_exec_time,
last_exec_result, pos) last_exec_result, pos, test_plan_collection_id)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, #{item.functionalCaseId,jdbcType=VARCHAR}, (#{item.id,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, #{item.functionalCaseId,jdbcType=VARCHAR},
#{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, #{item.executeUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, #{item.executeUser,jdbcType=VARCHAR},
#{item.lastExecTime,jdbcType=BIGINT}, #{item.lastExecResult,jdbcType=VARCHAR}, #{item.lastExecTime,jdbcType=BIGINT}, #{item.lastExecResult,jdbcType=VARCHAR},
#{item.pos,jdbcType=BIGINT}) #{item.pos,jdbcType=BIGINT}, #{item.testPlanCollectionId,jdbcType=VARCHAR})
</foreach> </foreach>
</insert> </insert>
<insert id="batchInsertSelective" parameterType="map"> <insert id="batchInsertSelective" parameterType="map">
@ -322,6 +337,9 @@
<if test="'pos'.toString() == column.value"> <if test="'pos'.toString() == column.value">
#{item.pos,jdbcType=BIGINT} #{item.pos,jdbcType=BIGINT}
</if> </if>
<if test="'test_plan_collection_id'.toString() == column.value">
#{item.testPlanCollectionId,jdbcType=VARCHAR}
</if>
</foreach> </foreach>
) )
</foreach> </foreach>

View File

@ -59,20 +59,24 @@ ALTER TABLE test_plan_report_bug MODIFY `bug_case_count` BIGINT NOT NULL DEFAUL
-- 修改测试计划关联接口表字段 -- 修改测试计划关联接口表字段
ALTER TABLE test_plan_api_case DROP COLUMN num; ALTER TABLE test_plan_api_case DROP COLUMN num;
ALTER TABLE test_plan_api_case ADD COLUMN test_plan_collection_id VARCHAR(50) NOT NULL COMMENT '测试计划集id'; ALTER TABLE test_plan_api_case ADD COLUMN test_plan_collection_id VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '测试计划集id';
ALTER TABLE test_plan_api_case ADD COLUMN last_exec_time BIGINT COMMENT '最后执行时间'; ALTER TABLE test_plan_api_case ADD COLUMN last_exec_time BIGINT COMMENT '最后执行时间';
CREATE INDEX idx_test_plan_collection_id ON test_plan_api_case(test_plan_collection_id); CREATE INDEX idx_test_plan_collection_id ON test_plan_api_case(test_plan_collection_id);
CREATE INDEX idx_pos ON test_plan_api_case(pos); CREATE INDEX idx_pos ON test_plan_api_case(pos);
-- 修改测试计划关联场景表字段 -- 修改测试计划关联场景表字段
ALTER TABLE test_plan_api_scenario DROP COLUMN num; ALTER TABLE test_plan_api_scenario DROP COLUMN num;
ALTER TABLE test_plan_api_scenario ADD COLUMN test_plan_collection_id VARCHAR(50) NOT NULL COMMENT '测试计划集id'; ALTER TABLE test_plan_api_scenario ADD COLUMN test_plan_collection_id VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '测试计划集id';
ALTER TABLE test_plan_api_scenario ADD COLUMN grouped BIT DEFAULT 0 COMMENT '是否为环境组'; ALTER TABLE test_plan_api_scenario ADD COLUMN grouped BIT DEFAULT 0 COMMENT '是否为环境组';
ALTER TABLE test_plan_api_scenario MODIFY COLUMN `environment_id` VARCHAR(50) COMMENT '所属环境或环境组id'; ALTER TABLE test_plan_api_scenario MODIFY COLUMN `environment_id` VARCHAR(50) COMMENT '所属环境或环境组id';
ALTER TABLE test_plan_api_scenario ADD COLUMN last_exec_time BIGINT COMMENT '最后执行时间'; ALTER TABLE test_plan_api_scenario ADD COLUMN last_exec_time BIGINT COMMENT '最后执行时间';
CREATE INDEX idx_test_plan_collection_id ON test_plan_api_scenario(test_plan_collection_id); CREATE INDEX idx_test_plan_collection_id ON test_plan_api_scenario(test_plan_collection_id);
CREATE INDEX idx_pos ON test_plan_api_scenario(pos); CREATE INDEX idx_pos ON test_plan_api_scenario(pos);
-- 修改测试计划关联功能用例表字段
ALTER TABLE test_plan_functional_case ADD COLUMN test_plan_collection_id VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '测试计划集id';
CREATE INDEX idx_test_plan_collection_id ON test_plan_functional_case(test_plan_collection_id);
-- 修改测试规划配置表 -- 修改测试规划配置表
ALTER TABLE test_plan_allocation DROP `run_mode_config`; ALTER TABLE test_plan_allocation DROP `run_mode_config`;
ALTER TABLE test_plan_allocation ADD `test_resource_pool_id` VARCHAR(50) NOT NULL COMMENT '资源池ID'; ALTER TABLE test_plan_allocation ADD `test_resource_pool_id` VARCHAR(50) NOT NULL COMMENT '资源池ID';

View File

@ -50,9 +50,9 @@ VALUES
INSERT INTO test_plan(id, num, project_id, group_id, module_id, name, status, type, tags, create_time, create_user, update_time, update_user, planned_start_time, planned_end_time, actual_start_time, actual_end_time, description) INSERT INTO test_plan(id, num, project_id, group_id, module_id, name, status, type, tags, create_time, create_user, update_time, update_user, planned_start_time, planned_end_time, actual_start_time, actual_end_time, description)
VALUE ('TEST_MINDER_PLAN_ID_1', 1000, 'project-case-minder-test', 'none', 'TEST_MINDER_PLAN_MODULE', '脑图测试计划', 'PREPARED', 'TEST_PLAN', null, 1669174143999, 'admin', 1669174143999, 'admin', null, null, null,null,null); VALUE ('TEST_MINDER_PLAN_ID_1', 1000, 'project-case-minder-test', 'none', 'TEST_MINDER_PLAN_MODULE', '脑图测试计划', 'PREPARED', 'TEST_PLAN', null, 1669174143999, 'admin', 1669174143999, 'admin', null, null, null,null,null);
INSERT INTO test_plan_functional_case(id, test_plan_id, functional_case_id, create_time, create_user, execute_user, last_exec_time, last_exec_result, pos) INSERT INTO test_plan_functional_case(id, test_plan_id, functional_case_id, create_time, create_user, execute_user, last_exec_time, last_exec_result, pos, test_plan_collection_id)
VALUES ('test_plan_functional_case_minder_id1', 'TEST_MINDER_PLAN_ID_1', 'TEST_FUNCTIONAL_MINDER_CASE_ID_5', 1669174143999, 'admin', 'admin', 1669174143999, 'SUCCESS', 5000), VALUES ('test_plan_functional_case_minder_id1', 'TEST_MINDER_PLAN_ID_1', 'TEST_FUNCTIONAL_MINDER_CASE_ID_5', 1669174143999, 'admin', 'admin', 1669174143999, 'SUCCESS', 5000, '123'),
('test_plan_functional_case_minder_id2', 'TEST_MINDER_PLAN_ID_1', 'TEST_FUNCTIONAL_MINDER_CASE_ID_5', 1669174143999, 'admin', 'admin', 1669174143999, 'SUCCESS', 10000); ('test_plan_functional_case_minder_id2', 'TEST_MINDER_PLAN_ID_1', 'TEST_FUNCTIONAL_MINDER_CASE_ID_5', 1669174143999, 'admin', 'admin', 1669174143999, 'SUCCESS', 10000, '123');
INSERT INTO custom_field (id, name, scene, type, remark, internal, scope_type, create_time, update_time, create_user, scope_id) VALUES INSERT INTO custom_field (id, name, scene, type, remark, internal, scope_type, create_time, update_time, create_user, scope_id) VALUES
('custom_field_minder_gyq_id_2', 'functional_priority', 'FUNCTIONAL', 'SELECT', '', true, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', '100001'), ('custom_field_minder_gyq_id_2', 'functional_priority', 'FUNCTIONAL', 'SELECT', '', true, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', '100001'),

View File

@ -15,7 +15,7 @@ INSERT INTO project(id, num, organization_id, name, description, create_time, up
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', null, false, null, true, null); UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', null, false, null, true, null);
INSERT INTO test_plan_functional_case(id, test_plan_id, functional_case_id, create_time, create_user, last_exec_time, last_exec_result, pos) INSERT INTO test_plan_functional_case(id, test_plan_id, functional_case_id, create_time, create_user, last_exec_time, last_exec_result, pos, test_plan_collection_id)
VALUES ('associate_case_plan_gyq_one','test_plan_associate_case_gyq_one', 'gyq_associate_function_case', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'SUCCESS', 200), VALUES ('associate_case_plan_gyq_one','test_plan_associate_case_gyq_one', 'gyq_associate_function_case', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'SUCCESS', 200, '123'),
('associate_case_plan_gyq_three','test_plan_associate_case_gyq_one', 'gyq_associate_function_case', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'SUCCESS', 200), ('associate_case_plan_gyq_three','test_plan_associate_case_gyq_one', 'gyq_associate_function_case', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'SUCCESS', 200, '123'),
('associate_case_plan_gyq_two','test_plan_associate_case_gyq_two', 'gyq_associate_function_case', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'SUCCESS', 200); ('associate_case_plan_gyq_two','test_plan_associate_case_gyq_two', 'gyq_associate_function_case', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'SUCCESS', 200, '123');

View File

@ -46,7 +46,7 @@ public class TestPlanApiCaseController {
public Pager<List<TestPlanApiCasePageResponse>> page(@Validated @RequestBody TestPlanApiCaseRequest request) { public Pager<List<TestPlanApiCasePageResponse>> page(@Validated @RequestBody TestPlanApiCaseRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString("id")) ? request.getSortString("id") : "create_time desc"); StringUtils.isNotBlank(request.getSortString("id")) ? request.getSortString("id") : "create_time desc");
return PageUtils.setPageInfo(page, testPlanApiCaseService.HasRelateApiCaseList(request, false)); return PageUtils.setPageInfo(page, testPlanApiCaseService.hasRelateApiCaseList(request, false));
} }

View File

@ -24,4 +24,7 @@ public class BasePlanCaseBatchRequest extends TableBatchProcessDTO implements Se
@Schema(description = "模块id") @Schema(description = "模块id")
private List<String> moduleIds; private List<String> moduleIds;
@Schema(description = "计划集id")
private List<String> collectionIds;
} }

View File

@ -33,4 +33,7 @@ public class TestPlanCaseRequest extends BasePageRequest implements Serializable
@Schema(description = "模块id") @Schema(description = "模块id")
private List<String> moduleIds; private List<String> moduleIds;
@Schema(description = "计划集id")
private List<String> collectionIds;
} }

View File

@ -68,4 +68,7 @@ public class TestPlanApiCasePageResponse implements Serializable {
@Schema(description = "计划集环境") @Schema(description = "计划集环境")
private String collectEnvironmentId; private String collectEnvironmentId;
@Schema(description = "报告id")
private String lastExecReportId;
} }

View File

@ -205,7 +205,7 @@
<sql id="combine"> <sql id="combine">
<!-- 名称 --> <!-- 名称 -->
<if test='${condition}.name != null and (${name} == null or ${name} == "")'> <if test='${condition}.name != null'>
api_definition.name api_definition.name
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.name"/> <property name="object" value="${condition}.name"/>
@ -416,6 +416,7 @@
t.last_exec_result, t.last_exec_result,
t.execute_user, t.execute_user,
t.last_exec_time, t.last_exec_time,
t.last_exec_report_id,
tpc.environment_id as collectEnvironmentId tpc.environment_id as collectEnvironmentId
FROM FROM
api_test_case atc api_test_case atc

View File

@ -142,6 +142,12 @@
or functional_case.num like concat('%', #{request.keyword},'%') or functional_case.num like concat('%', #{request.keyword},'%')
) )
</if> </if>
<if test="request.collectionIds != null and request.collectionIds.size() > 0">
and test_plan_functional_case.test_plan_collection_id in
<foreach collection="request.collectionIds" item="collectionId" separator="," open="(" close=")">
#{collectionId}
</foreach>
</if>
<include refid="filters"> <include refid="filters">
<property name="filter" value="request.filter"/> <property name="filter" value="request.filter"/>
</include> </include>
@ -174,6 +180,12 @@
or functional_case.tags like concat('%', #{request.condition.keyword},'%') or functional_case.tags like concat('%', #{request.condition.keyword},'%')
) )
</if> </if>
<if test="request.collectionIds != null and request.collectionIds.size() > 0">
and test_plan_functional_case.test_plan_collection_id in
<foreach collection="request.collectionIds" item="collectionId" separator="," open="(" close=")">
#{collectionId}
</foreach>
</if>
<include refid="filters"> <include refid="filters">
<property name="filter" value="request.condition.filter"/> <property name="filter" value="request.condition.filter"/>
</include> </include>

View File

@ -170,7 +170,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
* @param deleted * @param deleted
* @return * @return
*/ */
public List<TestPlanApiCasePageResponse> HasRelateApiCaseList(TestPlanApiCaseRequest request, boolean deleted) { public List<TestPlanApiCasePageResponse> hasRelateApiCaseList(TestPlanApiCaseRequest request, boolean deleted) {
List<TestPlanApiCasePageResponse> list = extTestPlanApiCaseMapper.relateApiCaseList(request, deleted); List<TestPlanApiCasePageResponse> list = extTestPlanApiCaseMapper.relateApiCaseList(request, deleted);
buildApiCaseResponse(list); buildApiCaseResponse(list);
return list; return list;

View File

@ -50,6 +50,8 @@ public class TestPlanCaseService {
testPlanFunctionalCase.setLastExecResult(ExecStatus.PENDING.name()); testPlanFunctionalCase.setLastExecResult(ExecStatus.PENDING.name());
testPlanFunctionalCase.setExecuteUser(associationParam.getOperator()); testPlanFunctionalCase.setExecuteUser(associationParam.getOperator());
testPlanFunctionalCaseList.add(testPlanFunctionalCase); testPlanFunctionalCaseList.add(testPlanFunctionalCase);
// TODO 关联逻辑后续改进 默认先写死
testPlanFunctionalCase.setTestPlanCollectionId("NONE");
pox += ServiceUtils.POS_STEP; pox += ServiceUtils.POS_STEP;
} }
testPlanFunctionalCaseMapper.batchInsert(testPlanFunctionalCaseList); testPlanFunctionalCaseMapper.batchInsert(testPlanFunctionalCaseList);

View File

@ -9,8 +9,8 @@ VALUES
('wxx_1', b'0', b'0', 100), ('wxx_1', b'0', b'0', 100),
('wxx_2', b'0', b'0', 100); ('wxx_2', b'0', b'0', 100);
INSERT INTO `test_plan_functional_case`(`id`, `test_plan_id`, `functional_case_id`, `create_time`, `create_user`, `execute_user`, `last_exec_time`, `last_exec_result`, `pos`) INSERT INTO `test_plan_functional_case`(`id`, `test_plan_id`, `functional_case_id`, `create_time`, `create_user`, `execute_user`, `last_exec_time`, `last_exec_result`, `pos`, `test_plan_collection_id`)
VALUES ('wxx_tpfc_1', 'wxx_1', 'wxx_test_1', 1714980158000, 'admin', NULL, NULL, NULL, 1); VALUES ('wxx_tpfc_1', 'wxx_1', 'wxx_test_1', 1714980158000, 'admin', NULL, NULL, NULL, 1, '123');
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) 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)

View File

@ -14,15 +14,15 @@ VALUES
('gyq_disassociate_plan_2', 25000, 'gyq_disassociate', 'gyq_test_plan_id_1', 'root', '测试取消关联2', 'PREPARED', 'TEST_PLAN', NULL, 1714980158000, 'WX', 1714980158000, 'WX', 1714980158000, 1714980158000, 1714980158000, 1714980158000, '11'); ('gyq_disassociate_plan_2', 25000, 'gyq_disassociate', 'gyq_test_plan_id_1', 'root', '测试取消关联2', 'PREPARED', 'TEST_PLAN', NULL, 1714980158000, 'WX', 1714980158000, 'WX', 1714980158000, 1714980158000, 1714980158000, 1714980158000, '11');
; ;
INSERT INTO `test_plan_functional_case`(`id`, `test_plan_id`, `functional_case_id`, `create_time`, `create_user`, `execute_user`, `last_exec_time`, `last_exec_result`, `pos`) INSERT INTO `test_plan_functional_case`(`id`, `test_plan_id`, `functional_case_id`, `create_time`, `create_user`, `execute_user`, `last_exec_time`, `last_exec_result`, `pos`, `test_plan_collection_id`)
VALUES VALUES
('relate_case_1', 'plan_1', 'fc_1', 1714980158000, 'admin', NULL, NULL, NULL, 1), ('relate_case_1', 'plan_1', 'fc_1', 1714980158000, 'admin', NULL, NULL, NULL, 1, '123'),
('relate_case_2', 'plan_1', 'fc_2', 1714980158000, 'admin', NULL, NULL, NULL, 1), ('relate_case_2', 'plan_1', 'fc_2', 1714980158000, 'admin', NULL, NULL, NULL, 1, '123'),
('relate_case_3', 'plan_2', 'fc_3', 1714980158000, 'admin', NULL, NULL, NULL, 1), ('relate_case_3', 'plan_2', 'fc_3', 1714980158000, 'admin', NULL, NULL, NULL, 1, '123'),
('gyq_disassociate_case_1', 'gyq_disassociate_plan_1', 'gyq_disassociate_fc_1', 1714980158000, 'admin', NULL, NULL, NULL, 1), ('gyq_disassociate_case_1', 'gyq_disassociate_plan_1', 'gyq_disassociate_fc_1', 1714980158000, 'admin', NULL, NULL, NULL, 1, '123'),
('gyq_disassociate_case_2', 'gyq_disassociate_plan_1', 'gyq_disassociate_fc_2', 1714980158000, 'admin', NULL, NULL, NULL, 1), ('gyq_disassociate_case_2', 'gyq_disassociate_plan_1', 'gyq_disassociate_fc_2', 1714980158000, 'admin', NULL, NULL, NULL, 1, '123'),
('gyq_disassociate_case_3', 'gyq_disassociate_plan_1', 'gyq_disassociate_fc_3', 1714980158000, 'admin', NULL, NULL, NULL, 1), ('gyq_disassociate_case_3', 'gyq_disassociate_plan_1', 'gyq_disassociate_fc_3', 1714980158000, 'admin', NULL, NULL, NULL, 1, '123'),
('gyq_disassociate_case_4', 'gyq_disassociate_plan_2', 'gyq_disassociate_fc_4', 1714980158000, 'admin', NULL, NULL, NULL, 1); ('gyq_disassociate_case_4', 'gyq_disassociate_plan_2', 'gyq_disassociate_fc_4', 1714980158000, 'admin', NULL, NULL, NULL, 1, '123');
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) 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 VALUES

View File

@ -7,12 +7,12 @@ INSERT INTO `test_plan_config`(`test_plan_id`, `automatic_status_update`, `repea
('plan_id_for_gen_report_1', b'0', b'0', 0.00); ('plan_id_for_gen_report_1', b'0', b'0', 0.00);
-- 计划关联用例执行的测试数据 -- 计划关联用例执行的测试数据
INSERT INTO `test_plan_functional_case` (`id`, `test_plan_id`, `functional_case_id`, `create_time`, `create_user`, `execute_user`, `last_exec_time`, `last_exec_result`, `pos`) VALUES INSERT INTO `test_plan_functional_case` (`id`, `test_plan_id`, `functional_case_id`, `create_time`, `create_user`, `execute_user`, `last_exec_time`, `last_exec_result`, `pos`, `test_plan_collection_id`) VALUES
('plan_id_for_gen_report_case_1', 'plan_id_for_gen_report', 'f1_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'PENDING', 1), ('plan_id_for_gen_report_case_1', 'plan_id_for_gen_report', 'f1_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'PENDING', 1, '123'),
('plan_id_for_gen_report_case_2', 'plan_id_for_gen_report', 'f2_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'SUCCESS', 2), ('plan_id_for_gen_report_case_2', 'plan_id_for_gen_report', 'f2_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'SUCCESS', 2, '123'),
('plan_id_for_gen_report_case_3', 'plan_id_for_gen_report', 'f3_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'ERROR', 3), ('plan_id_for_gen_report_case_3', 'plan_id_for_gen_report', 'f3_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'ERROR', 3, '123'),
('plan_id_for_gen_report_case_4', 'plan_id_for_gen_report', 'f4_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'BLOCKED', 4), ('plan_id_for_gen_report_case_4', 'plan_id_for_gen_report', 'f4_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'BLOCKED', 4, '123'),
('plan_id_for_gen_report_case_5', 'plan_id_for_gen_report', 'f5_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'FAKE_ERROR', 5); ('plan_id_for_gen_report_case_5', 'plan_id_for_gen_report', 'f5_gen', CURRENT_TIMESTAMP, 'admin', 'admin', CURRENT_TIMESTAMP, 'FAKE_ERROR', 5, '123');
-- 计划关联缺陷的测试数据 -- 计划关联缺陷的测试数据
INSERT INTO `bug_relation_case` (`id`, `case_id`, `bug_id`, `case_type`, `test_plan_id`, `test_plan_case_id`, `create_user`, `create_time`, `update_time`) VALUES INSERT INTO `bug_relation_case` (`id`, `case_id`, `bug_id`, `case_type`, `test_plan_id`, `test_plan_case_id`, `create_user`, `create_time`, `update_time`) VALUES

View File

@ -23,13 +23,13 @@ VALUES ('wx_test_plan_id_1', 5000, 'songtianyang-fix-wx', 'NONE', '1', '测试
1714980158000, 'WX', 1714980158000, 'WX', 1714980158000, 1714980158000, 1714980158000, 1714980158000, '11'); 1714980158000, 'WX', 1714980158000, 'WX', 1714980158000, 1714980158000, 1714980158000, 1714980158000, '11');
INSERT INTO `test_plan_functional_case`(`id`, `test_plan_id`, `functional_case_id`, `create_time`, `create_user`, `execute_user`, `last_exec_time`, `last_exec_result`, `pos`) VALUES INSERT INTO `test_plan_functional_case`(`id`, `test_plan_id`, `functional_case_id`, `create_time`, `create_user`, `execute_user`, `last_exec_time`, `last_exec_result`, `pos`, `test_plan_collection_id`) VALUES
('wx_tpfc_1', 'wx_test_plan_id_4', 'wx_fc_1', 1714980158000, 'admin', NULL, NULL, NULL, 1), ('wx_tpfc_1', 'wx_test_plan_id_4', 'wx_fc_1', 1714980158000, 'admin', NULL, NULL, NULL, 1, '123'),
('oasis_1', 'wx_test_plan_id_7', 'oasis_fc_1', 1714980158000, 'admin', NULL, NULL, 'UN_EXECUTED', 1), ('oasis_1', 'wx_test_plan_id_7', 'oasis_fc_1', 1714980158000, 'admin', NULL, NULL, 'UN_EXECUTED', 1, '123'),
('oasis_2', 'wx_test_plan_id_7', 'oasis_fc_2', 1714980158000, 'admin', NULL, NULL, 'PASSED', 1), ('oasis_2', 'wx_test_plan_id_7', 'oasis_fc_2', 1714980158000, 'admin', NULL, NULL, 'PASSED', 1, '123'),
('oasis_3', 'wx_test_plan_id_7', 'oasis_fc_3', 1714980158000, 'admin', NULL, NULL, 'FAILED', 1), ('oasis_3', 'wx_test_plan_id_7', 'oasis_fc_3', 1714980158000, 'admin', NULL, NULL, 'FAILED', 1, '123'),
('oasis_4', 'wx_test_plan_id_7', 'oasis_fc_4', 1714980158000, 'admin', NULL, NULL, 'BLOCKED', 1), ('oasis_4', 'wx_test_plan_id_7', 'oasis_fc_4', 1714980158000, 'admin', NULL, NULL, 'BLOCKED', 1, '123'),
('oasis_5', 'wx_test_plan_id_7', 'oasis_fc_5', 1714980158000, 'admin', NULL, NULL, 'FAKE_ERROR', 1); ('oasis_5', 'wx_test_plan_id_7', 'oasis_fc_5', 1714980158000, 'admin', NULL, NULL, 'FAKE_ERROR', 1, '123');
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 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
('oasis_fc_1', 10001, 'TEST_MODULE_ID', 'project-associate-case-test', '100001', '测试', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'v1.0.0', 'PENDING', b'0', b'0', b'1', 'admin', 'admin', '', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL), ('oasis_fc_1', 10001, 'TEST_MODULE_ID', 'project-associate-case-test', '100001', '测试', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'v1.0.0', 'PENDING', b'0', b'0', b'1', 'admin', 'admin', '', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL),