fix(接口自动化,接口定义): 修复列表数据放到回收站再恢复时状态错误问题

This commit is contained in:
fit2-zhao 2021-03-11 15:56:54 +08:00
parent b9be1ddd0e
commit be133b3cc6
11 changed files with 232 additions and 25 deletions

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class ApiDefinition implements Serializable {
@ -38,5 +37,7 @@ public class ApiDefinition implements Serializable {
private String tags;
private String originalState;
private static final long serialVersionUID = 1L;
}

View File

@ -1193,6 +1193,76 @@ public class ApiDefinitionExample {
addCriterion("tags not between", value1, value2, "tags");
return (Criteria) this;
}
public Criteria andOriginalStateIsNull() {
addCriterion("original_state is null");
return (Criteria) this;
}
public Criteria andOriginalStateIsNotNull() {
addCriterion("original_state is not null");
return (Criteria) this;
}
public Criteria andOriginalStateEqualTo(String value) {
addCriterion("original_state =", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateNotEqualTo(String value) {
addCriterion("original_state <>", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateGreaterThan(String value) {
addCriterion("original_state >", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateGreaterThanOrEqualTo(String value) {
addCriterion("original_state >=", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateLessThan(String value) {
addCriterion("original_state <", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateLessThanOrEqualTo(String value) {
addCriterion("original_state <=", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateLike(String value) {
addCriterion("original_state like", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateNotLike(String value) {
addCriterion("original_state not like", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateIn(List<String> values) {
addCriterion("original_state in", values, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateNotIn(List<String> values) {
addCriterion("original_state not in", values, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateBetween(String value1, String value2) {
addCriterion("original_state between", value1, value2, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateNotBetween(String value1, String value2) {
addCriterion("original_state not between", value1, value2, "originalState");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -43,5 +43,7 @@ public class ApiScenario implements Serializable {
private Integer num;
private String originalState;
private static final long serialVersionUID = 1L;
}

View File

@ -1393,6 +1393,76 @@ public class ApiScenarioExample {
addCriterion("num not between", value1, value2, "num");
return (Criteria) this;
}
public Criteria andOriginalStateIsNull() {
addCriterion("original_state is null");
return (Criteria) this;
}
public Criteria andOriginalStateIsNotNull() {
addCriterion("original_state is not null");
return (Criteria) this;
}
public Criteria andOriginalStateEqualTo(String value) {
addCriterion("original_state =", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateNotEqualTo(String value) {
addCriterion("original_state <>", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateGreaterThan(String value) {
addCriterion("original_state >", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateGreaterThanOrEqualTo(String value) {
addCriterion("original_state >=", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateLessThan(String value) {
addCriterion("original_state <", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateLessThanOrEqualTo(String value) {
addCriterion("original_state <=", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateLike(String value) {
addCriterion("original_state like", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateNotLike(String value) {
addCriterion("original_state not like", value, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateIn(List<String> values) {
addCriterion("original_state in", values, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateNotIn(List<String> values) {
addCriterion("original_state not in", values, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateBetween(String value1, String value2) {
addCriterion("original_state between", value1, value2, "originalState");
return (Criteria) this;
}
public Criteria andOriginalStateNotBetween(String value1, String value2) {
addCriterion("original_state not between", value1, value2, "originalState");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -18,6 +18,7 @@
<result column="path" jdbcType="VARCHAR" property="path" />
<result column="num" jdbcType="INTEGER" property="num" />
<result column="tags" jdbcType="VARCHAR" property="tags" />
<result column="original_state" jdbcType="VARCHAR" property="originalState" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiDefinitionWithBLOBs">
<result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -84,7 +85,7 @@
</sql>
<sql id="Base_Column_List">
id, project_id, `name`, `method`, module_path, environment_id, schedule, `status`,
module_id, user_id, create_time, update_time, protocol, `path`, num, tags
module_id, user_id, create_time, update_time, protocol, `path`, num, tags, original_state
</sql>
<sql id="Blob_Column_List">
description, request, response
@ -143,15 +144,15 @@
schedule, `status`, module_id,
user_id, create_time, update_time,
protocol, `path`, num,
tags, description, request,
response)
tags, original_state, description,
request, response)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{method,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR},
#{schedule,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{moduleId,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{protocol,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{num,jdbcType=INTEGER},
#{tags,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR},
#{response,jdbcType=LONGVARCHAR})
#{tags,jdbcType=VARCHAR}, #{originalState,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR},
#{request,jdbcType=LONGVARCHAR}, #{response,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiDefinitionWithBLOBs">
insert into api_definition
@ -204,6 +205,9 @@
<if test="tags != null">
tags,
</if>
<if test="originalState != null">
original_state,
</if>
<if test="description != null">
description,
</if>
@ -263,6 +267,9 @@
<if test="tags != null">
#{tags,jdbcType=VARCHAR},
</if>
<if test="originalState != null">
#{originalState,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
@ -331,6 +338,9 @@
<if test="record.tags != null">
tags = #{record.tags,jdbcType=VARCHAR},
</if>
<if test="record.originalState != null">
original_state = #{record.originalState,jdbcType=VARCHAR},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR},
</if>
@ -363,6 +373,7 @@
`path` = #{record.path,jdbcType=VARCHAR},
num = #{record.num,jdbcType=INTEGER},
tags = #{record.tags,jdbcType=VARCHAR},
original_state = #{record.originalState,jdbcType=VARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR},
request = #{record.request,jdbcType=LONGVARCHAR},
response = #{record.response,jdbcType=LONGVARCHAR}
@ -387,7 +398,8 @@
protocol = #{record.protocol,jdbcType=VARCHAR},
`path` = #{record.path,jdbcType=VARCHAR},
num = #{record.num,jdbcType=INTEGER},
tags = #{record.tags,jdbcType=VARCHAR}
tags = #{record.tags,jdbcType=VARCHAR},
original_state = #{record.originalState,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -440,6 +452,9 @@
<if test="tags != null">
tags = #{tags,jdbcType=VARCHAR},
</if>
<if test="originalState != null">
original_state = #{originalState,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
@ -469,6 +484,7 @@
`path` = #{path,jdbcType=VARCHAR},
num = #{num,jdbcType=INTEGER},
tags = #{tags,jdbcType=VARCHAR},
original_state = #{originalState,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR},
request = #{request,jdbcType=LONGVARCHAR},
response = #{response,jdbcType=LONGVARCHAR}
@ -490,7 +506,8 @@
protocol = #{protocol,jdbcType=VARCHAR},
`path` = #{path,jdbcType=VARCHAR},
num = #{num,jdbcType=INTEGER},
tags = #{tags,jdbcType=VARCHAR}
tags = #{tags,jdbcType=VARCHAR},
original_state = #{originalState,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -21,6 +21,7 @@
<result column="last_result" jdbcType="VARCHAR" property="lastResult" />
<result column="report_id" jdbcType="VARCHAR" property="reportId" />
<result column="num" jdbcType="INTEGER" property="num" />
<result column="original_state" jdbcType="VARCHAR" property="originalState" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenarioWithBLOBs">
<result column="scenario_definition" jdbcType="LONGVARCHAR" property="scenarioDefinition" />
@ -87,7 +88,7 @@
<sql id="Base_Column_List">
id, project_id, tags, user_id, api_scenario_module_id, module_path, `name`, `level`,
`status`, principal, step_total, follow_people, schedule, create_time, update_time,
pass_rate, last_result, report_id, num
pass_rate, last_result, report_id, num, original_state
</sql>
<sql id="Blob_Column_List">
scenario_definition, description
@ -147,16 +148,16 @@
principal, step_total, follow_people,
schedule, create_time, update_time,
pass_rate, last_result, report_id,
num, scenario_definition, description
)
num, original_state, scenario_definition,
description)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{apiScenarioModuleId,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{level,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{principal,jdbcType=VARCHAR}, #{stepTotal,jdbcType=INTEGER}, #{followPeople,jdbcType=VARCHAR},
#{schedule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{passRate,jdbcType=VARCHAR}, #{lastResult,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR},
#{num,jdbcType=INTEGER}, #{scenarioDefinition,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}
)
#{num,jdbcType=INTEGER}, #{originalState,jdbcType=VARCHAR}, #{scenarioDefinition,jdbcType=LONGVARCHAR},
#{description,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
insert into api_scenario
@ -218,6 +219,9 @@
<if test="num != null">
num,
</if>
<if test="originalState != null">
original_state,
</if>
<if test="scenarioDefinition != null">
scenario_definition,
</if>
@ -283,6 +287,9 @@
<if test="num != null">
#{num,jdbcType=INTEGER},
</if>
<if test="originalState != null">
#{originalState,jdbcType=VARCHAR},
</if>
<if test="scenarioDefinition != null">
#{scenarioDefinition,jdbcType=LONGVARCHAR},
</if>
@ -357,6 +364,9 @@
<if test="record.num != null">
num = #{record.num,jdbcType=INTEGER},
</if>
<if test="record.originalState != null">
original_state = #{record.originalState,jdbcType=VARCHAR},
</if>
<if test="record.scenarioDefinition != null">
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
</if>
@ -389,6 +399,7 @@
last_result = #{record.lastResult,jdbcType=VARCHAR},
report_id = #{record.reportId,jdbcType=VARCHAR},
num = #{record.num,jdbcType=INTEGER},
original_state = #{record.originalState,jdbcType=VARCHAR},
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
@ -415,7 +426,8 @@
pass_rate = #{record.passRate,jdbcType=VARCHAR},
last_result = #{record.lastResult,jdbcType=VARCHAR},
report_id = #{record.reportId,jdbcType=VARCHAR},
num = #{record.num,jdbcType=INTEGER}
num = #{record.num,jdbcType=INTEGER},
original_state = #{record.originalState,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -477,6 +489,9 @@
<if test="num != null">
num = #{num,jdbcType=INTEGER},
</if>
<if test="originalState != null">
original_state = #{originalState,jdbcType=VARCHAR},
</if>
<if test="scenarioDefinition != null">
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
</if>
@ -506,6 +521,7 @@
last_result = #{lastResult,jdbcType=VARCHAR},
report_id = #{reportId,jdbcType=VARCHAR},
num = #{num,jdbcType=INTEGER},
original_state = #{originalState,jdbcType=VARCHAR},
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
description = #{description,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
@ -529,7 +545,8 @@
pass_rate = #{passRate,jdbcType=VARCHAR},
last_result = #{lastResult,jdbcType=VARCHAR},
report_id = #{reportId,jdbcType=VARCHAR},
num = #{num,jdbcType=INTEGER}
num = #{num,jdbcType=INTEGER},
original_state = #{originalState,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -235,7 +235,7 @@
<update id="removeToGc">
update api_definition
set
set original_state=status,
status = 'Trash'
where id in
<foreach collection="ids" item="v" separator="," open="(" close=")">
@ -245,7 +245,7 @@
<update id="removeToGcByExample" parameterType="io.metersphere.base.domain.ApiDefinitionExample">
update api_definition
set
set original_state=status,
status = 'Trash', module_path = null, module_id = null
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
@ -255,7 +255,7 @@
<update id="reduction">
update api_definition
set
status = 'Underway'
status = original_state
where id in
<foreach collection="ids" item="v" separator="," open="(" close=")">
#{v}

View File

@ -275,7 +275,7 @@
<update id="removeToGc">
update api_scenario
set
set original_state=status,
status = 'Trash'
where id in
<foreach collection="ids" item="v" separator="," open="(" close=")">
@ -285,7 +285,7 @@
<update id="removeToGcByExample" parameterType="io.metersphere.base.domain.ApiScenarioExample">
update api_scenario
set
set original_state=status,
status = 'Trash', module_path = null, api_scenario_module_id = null
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
@ -295,7 +295,7 @@
<update id="reduction">
update api_scenario
set
status = 'Underway'
status = original_state
where id in
<foreach collection="ids" item="v" separator="," open="(" close=")">
#{v}

View File

@ -44,4 +44,10 @@ ALTER TABLE test_case_review ADD tags VARCHAR(2000) NULL;
alter table test_plan_api_scenario change environment_id environment longtext null comment 'Relevance environment';
-- file add sort column
alter table file_metadata add sort int default 0;
alter table file_metadata add sort int default 0;
-- add Original state
alter table api_definition add original_state varchar(64);
alter table api_scenario add original_state varchar(64);
update api_definition set original_state='Underway';
update api_scenario set original_state='Underway';

View File

@ -17,7 +17,6 @@
"@fortawesome/vue-fontawesome": "^0.1.9",
"axios": "^0.21.1",
"core-js": "^3.4.3",
"default-passive-events": "^2.0.0",
"diffable-html": "^4.0.0",
"echarts": "^4.6.0",
"el-table-infinite-scroll": "^1.0.10",

View File

@ -276,7 +276,9 @@
},
{
name: this.$t('test_track.case.batch_move_case'), handleClick: this.handleBatchMove
}
},
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
],
isSelectAllDate: false,
selectRows: new Set(),
@ -596,6 +598,29 @@
this.search();
})
},
handleDeleteBatch(row) {
if (this.trashEnable) {
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/api/automation/deleteBatch/', ids, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
return;
}
this.$alert(this.$t('api_test.definition.request.delete_confirm') + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/api/automation/removeToGc/', ids, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
}
}
});
},
execute(row) {
this.infoDb = false;
let url = "/api/automation/run";