From eb74637d82dd2599bcb8be31f45412b1dc3c7b18 Mon Sep 17 00:00:00 2001 From: "song.tianyang" <tianyang.song@fit2cloud.com> Date: Tue, 26 Jan 2021 14:17:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B5=8B=E8=AF=95=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=97=A5=E5=BF=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 测试计划日志表增加字段 --- .../base/domain/TestPlanReport.java | 2 + .../base/domain/TestPlanReportExample.java | 70 +++++++++++++++++++ .../base/mapper/TestPlanReportMapper.xml | 65 ++++++++++------- .../track/service/TestPlanReportService.java | 2 + .../V70__modify_test_plan_report.sql | 1 + 5 files changed, 116 insertions(+), 24 deletions(-) create mode 100644 backend/src/main/resources/db/migration/V70__modify_test_plan_report.sql diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanReport.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanReport.java index 400afde08b..53312b0f2d 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanReport.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanReport.java @@ -33,5 +33,7 @@ public class TestPlanReport implements Serializable { private String principal; + private String components; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanReportExample.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanReportExample.java index 43d54d3133..3133598e3c 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanReportExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanReportExample.java @@ -1013,6 +1013,76 @@ public class TestPlanReportExample { addCriterion("principal not between", value1, value2, "principal"); return (Criteria) this; } + + public Criteria andComponentsIsNull() { + addCriterion("components is null"); + return (Criteria) this; + } + + public Criteria andComponentsIsNotNull() { + addCriterion("components is not null"); + return (Criteria) this; + } + + public Criteria andComponentsEqualTo(String value) { + addCriterion("components =", value, "components"); + return (Criteria) this; + } + + public Criteria andComponentsNotEqualTo(String value) { + addCriterion("components <>", value, "components"); + return (Criteria) this; + } + + public Criteria andComponentsGreaterThan(String value) { + addCriterion("components >", value, "components"); + return (Criteria) this; + } + + public Criteria andComponentsGreaterThanOrEqualTo(String value) { + addCriterion("components >=", value, "components"); + return (Criteria) this; + } + + public Criteria andComponentsLessThan(String value) { + addCriterion("components <", value, "components"); + return (Criteria) this; + } + + public Criteria andComponentsLessThanOrEqualTo(String value) { + addCriterion("components <=", value, "components"); + return (Criteria) this; + } + + public Criteria andComponentsLike(String value) { + addCriterion("components like", value, "components"); + return (Criteria) this; + } + + public Criteria andComponentsNotLike(String value) { + addCriterion("components not like", value, "components"); + return (Criteria) this; + } + + public Criteria andComponentsIn(List<String> values) { + addCriterion("components in", values, "components"); + return (Criteria) this; + } + + public Criteria andComponentsNotIn(List<String> values) { + addCriterion("components not in", values, "components"); + return (Criteria) this; + } + + public Criteria andComponentsBetween(String value1, String value2) { + addCriterion("components between", value1, value2, "components"); + return (Criteria) this; + } + + public Criteria andComponentsNotBetween(String value1, String value2) { + addCriterion("components not between", value1, value2, "components"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml index 91e407c67a..07d1565c22 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml @@ -12,10 +12,11 @@ <result column="creator" jdbcType="VARCHAR" property="creator" /> <result column="start_time" jdbcType="BIGINT" property="startTime" /> <result column="end_time" jdbcType="BIGINT" property="endTime" /> - <result column="is_api_case_executing" jdbcType="BIT" property="isApiCaseExecuting" /> - <result column="is_scenario_executing" jdbcType="BIT" property="isScenarioExecuting" /> - <result column="is_performance_executing" jdbcType="BIT" property="isPerformanceExecuting" /> + <result column="is_api_case_executing" jdbcType="TINYINT" property="isApiCaseExecuting" /> + <result column="is_scenario_executing" jdbcType="TINYINT" property="isScenarioExecuting" /> + <result column="is_performance_executing" jdbcType="TINYINT" property="isPerformanceExecuting" /> <result column="principal" jdbcType="VARCHAR" property="principal" /> + <result column="components" jdbcType="VARCHAR" property="components" /> </resultMap> <sql id="Example_Where_Clause"> <where> @@ -78,7 +79,7 @@ <sql id="Base_Column_List"> id, test_plan_id, create_time, update_time, `name`, `status`, trigger_mode, creator, start_time, end_time, is_api_case_executing, is_scenario_executing, is_performance_executing, - principal + principal, components </sql> <select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanReportExample" resultMap="BaseResultMap"> select @@ -115,12 +116,14 @@ update_time, `name`, `status`, trigger_mode, creator, start_time, end_time, is_api_case_executing, is_scenario_executing, - is_performance_executing, principal) + is_performance_executing, principal, components + ) values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, - #{endTime,jdbcType=BIGINT}, #{isApiCaseExecuting,jdbcType=BIT}, #{isScenarioExecuting,jdbcType=BIT}, - #{isPerformanceExecuting,jdbcType=BIT}, #{principal,jdbcType=VARCHAR}) + #{endTime,jdbcType=BIGINT}, #{isApiCaseExecuting,jdbcType=TINYINT}, #{isScenarioExecuting,jdbcType=TINYINT}, + #{isPerformanceExecuting,jdbcType=TINYINT}, #{principal,jdbcType=VARCHAR}, #{components,jdbcType=VARCHAR} + ) </insert> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanReport"> insert into test_plan_report @@ -167,6 +170,9 @@ <if test="principal != null"> principal, </if> + <if test="components != null"> + components, + </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> @@ -200,17 +206,20 @@ #{endTime,jdbcType=BIGINT}, </if> <if test="isApiCaseExecuting != null"> - #{isApiCaseExecuting,jdbcType=BIT}, + #{isApiCaseExecuting,jdbcType=TINYINT}, </if> <if test="isScenarioExecuting != null"> - #{isScenarioExecuting,jdbcType=BIT}, + #{isScenarioExecuting,jdbcType=TINYINT}, </if> <if test="isPerformanceExecuting != null"> - #{isPerformanceExecuting,jdbcType=BIT}, + #{isPerformanceExecuting,jdbcType=TINYINT}, </if> <if test="principal != null"> #{principal,jdbcType=VARCHAR}, </if> + <if test="components != null"> + #{components,jdbcType=VARCHAR}, + </if> </trim> </insert> <select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanReportExample" resultType="java.lang.Long"> @@ -253,17 +262,20 @@ end_time = #{record.endTime,jdbcType=BIGINT}, </if> <if test="record.isApiCaseExecuting != null"> - is_api_case_executing = #{record.isApiCaseExecuting,jdbcType=BIT}, + is_api_case_executing = #{record.isApiCaseExecuting,jdbcType=TINYINT}, </if> <if test="record.isScenarioExecuting != null"> - is_scenario_executing = #{record.isScenarioExecuting,jdbcType=BIT}, + is_scenario_executing = #{record.isScenarioExecuting,jdbcType=TINYINT}, </if> <if test="record.isPerformanceExecuting != null"> - is_performance_executing = #{record.isPerformanceExecuting,jdbcType=BIT}, + is_performance_executing = #{record.isPerformanceExecuting,jdbcType=TINYINT}, </if> <if test="record.principal != null"> principal = #{record.principal,jdbcType=VARCHAR}, </if> + <if test="record.components != null"> + components = #{record.components,jdbcType=VARCHAR}, + </if> </set> <if test="_parameter != null"> <include refid="Update_By_Example_Where_Clause" /> @@ -281,10 +293,11 @@ creator = #{record.creator,jdbcType=VARCHAR}, start_time = #{record.startTime,jdbcType=BIGINT}, end_time = #{record.endTime,jdbcType=BIGINT}, - is_api_case_executing = #{record.isApiCaseExecuting,jdbcType=BIT}, - is_scenario_executing = #{record.isScenarioExecuting,jdbcType=BIT}, - is_performance_executing = #{record.isPerformanceExecuting,jdbcType=BIT}, - principal = #{record.principal,jdbcType=VARCHAR} + is_api_case_executing = #{record.isApiCaseExecuting,jdbcType=TINYINT}, + is_scenario_executing = #{record.isScenarioExecuting,jdbcType=TINYINT}, + is_performance_executing = #{record.isPerformanceExecuting,jdbcType=TINYINT}, + principal = #{record.principal,jdbcType=VARCHAR}, + components = #{record.components,jdbcType=VARCHAR} <if test="_parameter != null"> <include refid="Update_By_Example_Where_Clause" /> </if> @@ -320,17 +333,20 @@ end_time = #{endTime,jdbcType=BIGINT}, </if> <if test="isApiCaseExecuting != null"> - is_api_case_executing = #{isApiCaseExecuting,jdbcType=BIT}, + is_api_case_executing = #{isApiCaseExecuting,jdbcType=TINYINT}, </if> <if test="isScenarioExecuting != null"> - is_scenario_executing = #{isScenarioExecuting,jdbcType=BIT}, + is_scenario_executing = #{isScenarioExecuting,jdbcType=TINYINT}, </if> <if test="isPerformanceExecuting != null"> - is_performance_executing = #{isPerformanceExecuting,jdbcType=BIT}, + is_performance_executing = #{isPerformanceExecuting,jdbcType=TINYINT}, </if> <if test="principal != null"> principal = #{principal,jdbcType=VARCHAR}, </if> + <if test="components != null"> + components = #{components,jdbcType=VARCHAR}, + </if> </set> where id = #{id,jdbcType=VARCHAR} </update> @@ -345,10 +361,11 @@ creator = #{creator,jdbcType=VARCHAR}, start_time = #{startTime,jdbcType=BIGINT}, end_time = #{endTime,jdbcType=BIGINT}, - is_api_case_executing = #{isApiCaseExecuting,jdbcType=BIT}, - is_scenario_executing = #{isScenarioExecuting,jdbcType=BIT}, - is_performance_executing = #{isPerformanceExecuting,jdbcType=BIT}, - principal = #{principal,jdbcType=VARCHAR} + is_api_case_executing = #{isApiCaseExecuting,jdbcType=TINYINT}, + is_scenario_executing = #{isScenarioExecuting,jdbcType=TINYINT}, + is_performance_executing = #{isPerformanceExecuting,jdbcType=TINYINT}, + principal = #{principal,jdbcType=VARCHAR}, + components = #{components,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} </update> </mapper> \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index f907323391..bb19a3eac1 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -233,6 +233,8 @@ public class TestPlanReportService { testPlanReport.setEndTime(System.currentTimeMillis()); testPlanReport.setUpdateTime(System.currentTimeMillis()); + //手动触发的需要保存手工执行的信息 + JSONObject content = JSONObject.parseObject("{\"components\":[1,2,3,4,5]}"); JSONArray componentIds = content.getJSONArray("components"); List<ReportComponent> components = ReportComponentFactory.createComponents(componentIds.toJavaList(String.class), testPlan); diff --git a/backend/src/main/resources/db/migration/V70__modify_test_plan_report.sql b/backend/src/main/resources/db/migration/V70__modify_test_plan_report.sql new file mode 100644 index 0000000000..e0e32b8010 --- /dev/null +++ b/backend/src/main/resources/db/migration/V70__modify_test_plan_report.sql @@ -0,0 +1 @@ +ALTER TABLE test_plan_report ADD components VARCHAR (20); \ No newline at end of file