feat(接口测试): 增加场景模块
This commit is contained in:
parent
c85e5b8a0f
commit
e56239cb5a
|
@ -21,9 +21,9 @@ public class ApiScenario implements Serializable {
|
|||
private String name;
|
||||
|
||||
@Schema(description = "场景级别/P0/P1等", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_scenario.level.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 10, message = "{api_scenario.level.length_range}", groups = {Created.class, Updated.class})
|
||||
private String level;
|
||||
@NotBlank(message = "{api_scenario.priority.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 10, message = "{api_scenario.priority.length_range}", groups = {Created.class, Updated.class})
|
||||
private String priority;
|
||||
|
||||
@Schema(description = "场景状态/未规划/已完成 等", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_scenario.status.not_blank}", groups = {Created.class})
|
||||
|
@ -50,7 +50,7 @@ public class ApiScenario implements Serializable {
|
|||
private String lastReportId;
|
||||
|
||||
@Schema(description = "编号")
|
||||
private Integer num;
|
||||
private Long num;
|
||||
|
||||
@Schema(description = "自定义id")
|
||||
private String customNum;
|
||||
|
@ -78,7 +78,7 @@ public class ApiScenario implements Serializable {
|
|||
private String projectId;
|
||||
|
||||
@Schema(description = "场景模块fk")
|
||||
private String apiScenarioModuleId;
|
||||
private String moduleId;
|
||||
|
||||
@Schema(description = "描述信息")
|
||||
private String description;
|
||||
|
@ -113,14 +113,14 @@ public class ApiScenario implements Serializable {
|
|||
public enum Column {
|
||||
id("id", "id", "VARCHAR", false),
|
||||
name("name", "name", "VARCHAR", true),
|
||||
level("level", "level", "VARCHAR", true),
|
||||
priority("priority", "priority", "VARCHAR", false),
|
||||
status("status", "status", "VARCHAR", true),
|
||||
principal("principal", "principal", "VARCHAR", false),
|
||||
stepTotal("step_total", "stepTotal", "INTEGER", false),
|
||||
passRate("pass_rate", "passRate", "BIGINT", false),
|
||||
lastReportStatus("last_report_status", "lastReportStatus", "VARCHAR", false),
|
||||
lastReportId("last_report_id", "lastReportId", "VARCHAR", false),
|
||||
num("num", "num", "INTEGER", false),
|
||||
num("num", "num", "BIGINT", false),
|
||||
customNum("custom_num", "customNum", "VARCHAR", false),
|
||||
deleted("deleted", "deleted", "BIT", false),
|
||||
pos("pos", "pos", "BIGINT", false),
|
||||
|
@ -128,7 +128,7 @@ public class ApiScenario implements Serializable {
|
|||
refId("ref_id", "refId", "VARCHAR", false),
|
||||
latest("latest", "latest", "BIT", false),
|
||||
projectId("project_id", "projectId", "VARCHAR", false),
|
||||
apiScenarioModuleId("api_scenario_module_id", "apiScenarioModuleId", "VARCHAR", false),
|
||||
moduleId("module_id", "moduleId", "VARCHAR", false),
|
||||
description("description", "description", "VARCHAR", false),
|
||||
tags("tags", "tags", "VARCHAR", false),
|
||||
grouped("grouped", "grouped", "BIT", false),
|
||||
|
|
|
@ -244,73 +244,73 @@ public class ApiScenarioExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIsNull() {
|
||||
addCriterion("`level` is null");
|
||||
public Criteria andPriorityIsNull() {
|
||||
addCriterion("priority is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIsNotNull() {
|
||||
addCriterion("`level` is not null");
|
||||
public Criteria andPriorityIsNotNull() {
|
||||
addCriterion("priority is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelEqualTo(String value) {
|
||||
addCriterion("`level` =", value, "level");
|
||||
public Criteria andPriorityEqualTo(String value) {
|
||||
addCriterion("priority =", value, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotEqualTo(String value) {
|
||||
addCriterion("`level` <>", value, "level");
|
||||
public Criteria andPriorityNotEqualTo(String value) {
|
||||
addCriterion("priority <>", value, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelGreaterThan(String value) {
|
||||
addCriterion("`level` >", value, "level");
|
||||
public Criteria andPriorityGreaterThan(String value) {
|
||||
addCriterion("priority >", value, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`level` >=", value, "level");
|
||||
public Criteria andPriorityGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("priority >=", value, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelLessThan(String value) {
|
||||
addCriterion("`level` <", value, "level");
|
||||
public Criteria andPriorityLessThan(String value) {
|
||||
addCriterion("priority <", value, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelLessThanOrEqualTo(String value) {
|
||||
addCriterion("`level` <=", value, "level");
|
||||
public Criteria andPriorityLessThanOrEqualTo(String value) {
|
||||
addCriterion("priority <=", value, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelLike(String value) {
|
||||
addCriterion("`level` like", value, "level");
|
||||
public Criteria andPriorityLike(String value) {
|
||||
addCriterion("priority like", value, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotLike(String value) {
|
||||
addCriterion("`level` not like", value, "level");
|
||||
public Criteria andPriorityNotLike(String value) {
|
||||
addCriterion("priority not like", value, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIn(List<String> values) {
|
||||
addCriterion("`level` in", values, "level");
|
||||
public Criteria andPriorityIn(List<String> values) {
|
||||
addCriterion("priority in", values, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotIn(List<String> values) {
|
||||
addCriterion("`level` not in", values, "level");
|
||||
public Criteria andPriorityNotIn(List<String> values) {
|
||||
addCriterion("priority not in", values, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelBetween(String value1, String value2) {
|
||||
addCriterion("`level` between", value1, value2, "level");
|
||||
public Criteria andPriorityBetween(String value1, String value2) {
|
||||
addCriterion("priority between", value1, value2, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotBetween(String value1, String value2) {
|
||||
addCriterion("`level` not between", value1, value2, "level");
|
||||
public Criteria andPriorityNotBetween(String value1, String value2) {
|
||||
addCriterion("priority not between", value1, value2, "priority");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
|
@ -724,52 +724,52 @@ public class ApiScenarioExample {
|
|||
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;
|
||||
}
|
||||
|
@ -1234,73 +1234,73 @@ public class ApiScenarioExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdIsNull() {
|
||||
addCriterion("api_scenario_module_id is null");
|
||||
public Criteria andModuleIdIsNull() {
|
||||
addCriterion("module_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdIsNotNull() {
|
||||
addCriterion("api_scenario_module_id is not null");
|
||||
public Criteria andModuleIdIsNotNull() {
|
||||
addCriterion("module_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdEqualTo(String value) {
|
||||
addCriterion("api_scenario_module_id =", value, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdEqualTo(String value) {
|
||||
addCriterion("module_id =", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdNotEqualTo(String value) {
|
||||
addCriterion("api_scenario_module_id <>", value, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdNotEqualTo(String value) {
|
||||
addCriterion("module_id <>", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdGreaterThan(String value) {
|
||||
addCriterion("api_scenario_module_id >", value, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdGreaterThan(String value) {
|
||||
addCriterion("module_id >", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("api_scenario_module_id >=", value, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("module_id >=", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdLessThan(String value) {
|
||||
addCriterion("api_scenario_module_id <", value, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdLessThan(String value) {
|
||||
addCriterion("module_id <", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("api_scenario_module_id <=", value, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("module_id <=", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdLike(String value) {
|
||||
addCriterion("api_scenario_module_id like", value, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdLike(String value) {
|
||||
addCriterion("module_id like", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdNotLike(String value) {
|
||||
addCriterion("api_scenario_module_id not like", value, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdNotLike(String value) {
|
||||
addCriterion("module_id not like", value, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdIn(List<String> values) {
|
||||
addCriterion("api_scenario_module_id in", values, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdIn(List<String> values) {
|
||||
addCriterion("module_id in", values, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdNotIn(List<String> values) {
|
||||
addCriterion("api_scenario_module_id not in", values, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdNotIn(List<String> values) {
|
||||
addCriterion("module_id not in", values, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdBetween(String value1, String value2) {
|
||||
addCriterion("api_scenario_module_id between", value1, value2, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdBetween(String value1, String value2) {
|
||||
addCriterion("module_id between", value1, value2, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andApiScenarioModuleIdNotBetween(String value1, String value2) {
|
||||
addCriterion("api_scenario_module_id not between", value1, value2, "apiScenarioModuleId");
|
||||
public Criteria andModuleIdNotBetween(String value1, String value2) {
|
||||
addCriterion("module_id not between", value1, value2, "moduleId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,13 +20,9 @@ public class ApiScenarioModule implements Serializable {
|
|||
@Size(min = 1, max = 255, message = "{api_scenario_module.name.length_range}", groups = {Created.class, Updated.class})
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模块级别", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "{api_scenario_module.level.not_blank}", groups = {Created.class})
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "{api_scenario_module.pos.not_blank}", groups = {Created.class})
|
||||
private Integer pos;
|
||||
private Long pos;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Long createTime;
|
||||
|
@ -55,8 +51,7 @@ public class ApiScenarioModule implements Serializable {
|
|||
public enum Column {
|
||||
id("id", "id", "VARCHAR", false),
|
||||
name("name", "name", "VARCHAR", true),
|
||||
level("level", "level", "INTEGER", true),
|
||||
pos("pos", "pos", "INTEGER", false),
|
||||
pos("pos", "pos", "BIGINT", false),
|
||||
createTime("create_time", "createTime", "BIGINT", false),
|
||||
updateTime("update_time", "updateTime", "BIGINT", false),
|
||||
updateUser("update_user", "updateUser", "VARCHAR", false),
|
||||
|
|
|
@ -244,66 +244,6 @@ public class ApiScenarioModuleExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIsNull() {
|
||||
addCriterion("`level` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIsNotNull() {
|
||||
addCriterion("`level` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelEqualTo(Integer value) {
|
||||
addCriterion("`level` =", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotEqualTo(Integer value) {
|
||||
addCriterion("`level` <>", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelGreaterThan(Integer value) {
|
||||
addCriterion("`level` >", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("`level` >=", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelLessThan(Integer value) {
|
||||
addCriterion("`level` <", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("`level` <=", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIn(List<Integer> values) {
|
||||
addCriterion("`level` in", values, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotIn(List<Integer> values) {
|
||||
addCriterion("`level` not in", values, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`level` between", value1, value2, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`level` not between", value1, value2, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosIsNull() {
|
||||
addCriterion("pos is null");
|
||||
return (Criteria) this;
|
||||
|
@ -314,52 +254,52 @@ public class ApiScenarioModuleExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosEqualTo(Integer value) {
|
||||
public Criteria andPosEqualTo(Long value) {
|
||||
addCriterion("pos =", value, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosNotEqualTo(Integer value) {
|
||||
public Criteria andPosNotEqualTo(Long value) {
|
||||
addCriterion("pos <>", value, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosGreaterThan(Integer value) {
|
||||
public Criteria andPosGreaterThan(Long value) {
|
||||
addCriterion("pos >", value, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosGreaterThanOrEqualTo(Integer value) {
|
||||
public Criteria andPosGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("pos >=", value, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosLessThan(Integer value) {
|
||||
public Criteria andPosLessThan(Long value) {
|
||||
addCriterion("pos <", value, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosLessThanOrEqualTo(Integer value) {
|
||||
public Criteria andPosLessThanOrEqualTo(Long value) {
|
||||
addCriterion("pos <=", value, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosIn(List<Integer> values) {
|
||||
public Criteria andPosIn(List<Long> values) {
|
||||
addCriterion("pos in", values, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosNotIn(List<Integer> values) {
|
||||
public Criteria andPosNotIn(List<Long> values) {
|
||||
addCriterion("pos not in", values, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosBetween(Integer value1, Integer value2) {
|
||||
public Criteria andPosBetween(Long value1, Long value2) {
|
||||
addCriterion("pos between", value1, value2, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPosNotBetween(Integer value1, Integer value2) {
|
||||
public Criteria andPosNotBetween(Long value1, Long value2) {
|
||||
addCriterion("pos not between", value1, value2, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
<resultMap id="BaseResultMap" type="io.metersphere.api.domain.ApiScenario">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="level" jdbcType="VARCHAR" property="level" />
|
||||
<result column="priority" jdbcType="VARCHAR" property="priority" />
|
||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||
<result column="principal" jdbcType="VARCHAR" property="principal" />
|
||||
<result column="step_total" jdbcType="INTEGER" property="stepTotal" />
|
||||
<result column="pass_rate" jdbcType="BIGINT" property="passRate" />
|
||||
<result column="last_report_status" jdbcType="VARCHAR" property="lastReportStatus" />
|
||||
<result column="last_report_id" jdbcType="VARCHAR" property="lastReportId" />
|
||||
<result column="num" jdbcType="INTEGER" property="num" />
|
||||
<result column="num" jdbcType="BIGINT" property="num" />
|
||||
<result column="custom_num" jdbcType="VARCHAR" property="customNum" />
|
||||
<result column="deleted" jdbcType="BIT" property="deleted" />
|
||||
<result column="pos" jdbcType="BIGINT" property="pos" />
|
||||
|
@ -19,7 +19,7 @@
|
|||
<result column="ref_id" jdbcType="VARCHAR" property="refId" />
|
||||
<result column="latest" jdbcType="BIT" property="latest" />
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<result column="api_scenario_module_id" jdbcType="VARCHAR" property="apiScenarioModuleId" />
|
||||
<result column="module_id" jdbcType="VARCHAR" property="moduleId" />
|
||||
<result column="description" jdbcType="VARCHAR" property="description" />
|
||||
<result column="tags" jdbcType="VARCHAR" property="tags" />
|
||||
<result column="grouped" jdbcType="BIT" property="grouped" />
|
||||
|
@ -89,10 +89,10 @@
|
|||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, `name`, `level`, `status`, principal, step_total, pass_rate, last_report_status,
|
||||
id, `name`, priority, `status`, principal, step_total, pass_rate, last_report_status,
|
||||
last_report_id, num, custom_num, deleted, pos, version_id, ref_id, latest, project_id,
|
||||
api_scenario_module_id, description, tags, grouped, create_user, create_time, delete_time,
|
||||
delete_user, update_user, update_time
|
||||
module_id, description, tags, grouped, create_user, create_time, delete_time, delete_user,
|
||||
update_user, update_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiScenarioExample" resultMap="BaseResultMap">
|
||||
select
|
||||
|
@ -125,22 +125,22 @@
|
|||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.api.domain.ApiScenario">
|
||||
insert into api_scenario (id, `name`, `level`,
|
||||
insert into api_scenario (id, `name`, priority,
|
||||
`status`, principal, step_total,
|
||||
pass_rate, last_report_status, last_report_id,
|
||||
num, custom_num, deleted,
|
||||
pos, version_id, ref_id,
|
||||
latest, project_id, api_scenario_module_id,
|
||||
latest, project_id, module_id,
|
||||
description, tags, grouped,
|
||||
create_user, create_time, delete_time,
|
||||
delete_user, update_user, update_time
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{level,jdbcType=VARCHAR},
|
||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR},
|
||||
#{status,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, #{stepTotal,jdbcType=INTEGER},
|
||||
#{passRate,jdbcType=BIGINT}, #{lastReportStatus,jdbcType=VARCHAR}, #{lastReportId,jdbcType=VARCHAR},
|
||||
#{num,jdbcType=INTEGER}, #{customNum,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT},
|
||||
#{num,jdbcType=BIGINT}, #{customNum,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT},
|
||||
#{pos,jdbcType=BIGINT}, #{versionId,jdbcType=VARCHAR}, #{refId,jdbcType=VARCHAR},
|
||||
#{latest,jdbcType=BIT}, #{projectId,jdbcType=VARCHAR}, #{apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
#{latest,jdbcType=BIT}, #{projectId,jdbcType=VARCHAR}, #{moduleId,jdbcType=VARCHAR},
|
||||
#{description,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, #{grouped,jdbcType=BIT},
|
||||
#{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{deleteTime,jdbcType=BIGINT},
|
||||
#{deleteUser,jdbcType=VARCHAR}, #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT}
|
||||
|
@ -155,8 +155,8 @@
|
|||
<if test="name != null">
|
||||
`name`,
|
||||
</if>
|
||||
<if test="level != null">
|
||||
`level`,
|
||||
<if test="priority != null">
|
||||
priority,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
`status`,
|
||||
|
@ -200,8 +200,8 @@
|
|||
<if test="projectId != null">
|
||||
project_id,
|
||||
</if>
|
||||
<if test="apiScenarioModuleId != null">
|
||||
api_scenario_module_id,
|
||||
<if test="moduleId != null">
|
||||
module_id,
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description,
|
||||
|
@ -238,8 +238,8 @@
|
|||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
#{level,jdbcType=VARCHAR},
|
||||
<if test="priority != null">
|
||||
#{priority,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=VARCHAR},
|
||||
|
@ -260,7 +260,7 @@
|
|||
#{lastReportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
#{num,jdbcType=INTEGER},
|
||||
#{num,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="customNum != null">
|
||||
#{customNum,jdbcType=VARCHAR},
|
||||
|
@ -283,8 +283,8 @@
|
|||
<if test="projectId != null">
|
||||
#{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="apiScenarioModuleId != null">
|
||||
#{apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
<if test="moduleId != null">
|
||||
#{moduleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
#{description,jdbcType=VARCHAR},
|
||||
|
@ -330,8 +330,8 @@
|
|||
<if test="record.name != null">
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.level != null">
|
||||
`level` = #{record.level,jdbcType=VARCHAR},
|
||||
<if test="record.priority != null">
|
||||
priority = #{record.priority,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.status != null">
|
||||
`status` = #{record.status,jdbcType=VARCHAR},
|
||||
|
@ -352,7 +352,7 @@
|
|||
last_report_id = #{record.lastReportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.num != null">
|
||||
num = #{record.num,jdbcType=INTEGER},
|
||||
num = #{record.num,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.customNum != null">
|
||||
custom_num = #{record.customNum,jdbcType=VARCHAR},
|
||||
|
@ -375,8 +375,8 @@
|
|||
<if test="record.projectId != null">
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.apiScenarioModuleId != null">
|
||||
api_scenario_module_id = #{record.apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
<if test="record.moduleId != null">
|
||||
module_id = #{record.moduleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.description != null">
|
||||
description = #{record.description,jdbcType=VARCHAR},
|
||||
|
@ -414,14 +414,14 @@
|
|||
update api_scenario
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
`level` = #{record.level,jdbcType=VARCHAR},
|
||||
priority = #{record.priority,jdbcType=VARCHAR},
|
||||
`status` = #{record.status,jdbcType=VARCHAR},
|
||||
principal = #{record.principal,jdbcType=VARCHAR},
|
||||
step_total = #{record.stepTotal,jdbcType=INTEGER},
|
||||
pass_rate = #{record.passRate,jdbcType=BIGINT},
|
||||
last_report_status = #{record.lastReportStatus,jdbcType=VARCHAR},
|
||||
last_report_id = #{record.lastReportId,jdbcType=VARCHAR},
|
||||
num = #{record.num,jdbcType=INTEGER},
|
||||
num = #{record.num,jdbcType=BIGINT},
|
||||
custom_num = #{record.customNum,jdbcType=VARCHAR},
|
||||
deleted = #{record.deleted,jdbcType=BIT},
|
||||
pos = #{record.pos,jdbcType=BIGINT},
|
||||
|
@ -429,7 +429,7 @@
|
|||
ref_id = #{record.refId,jdbcType=VARCHAR},
|
||||
latest = #{record.latest,jdbcType=BIT},
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
api_scenario_module_id = #{record.apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
module_id = #{record.moduleId,jdbcType=VARCHAR},
|
||||
description = #{record.description,jdbcType=VARCHAR},
|
||||
tags = #{record.tags,jdbcType=VARCHAR},
|
||||
grouped = #{record.grouped,jdbcType=BIT},
|
||||
|
@ -449,8 +449,8 @@
|
|||
<if test="name != null">
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
`level` = #{level,jdbcType=VARCHAR},
|
||||
<if test="priority != null">
|
||||
priority = #{priority,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
`status` = #{status,jdbcType=VARCHAR},
|
||||
|
@ -471,7 +471,7 @@
|
|||
last_report_id = #{lastReportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num = #{num,jdbcType=INTEGER},
|
||||
num = #{num,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="customNum != null">
|
||||
custom_num = #{customNum,jdbcType=VARCHAR},
|
||||
|
@ -494,8 +494,8 @@
|
|||
<if test="projectId != null">
|
||||
project_id = #{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="apiScenarioModuleId != null">
|
||||
api_scenario_module_id = #{apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
<if test="moduleId != null">
|
||||
module_id = #{moduleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
|
@ -530,14 +530,14 @@
|
|||
<update id="updateByPrimaryKey" parameterType="io.metersphere.api.domain.ApiScenario">
|
||||
update api_scenario
|
||||
set `name` = #{name,jdbcType=VARCHAR},
|
||||
`level` = #{level,jdbcType=VARCHAR},
|
||||
priority = #{priority,jdbcType=VARCHAR},
|
||||
`status` = #{status,jdbcType=VARCHAR},
|
||||
principal = #{principal,jdbcType=VARCHAR},
|
||||
step_total = #{stepTotal,jdbcType=INTEGER},
|
||||
pass_rate = #{passRate,jdbcType=BIGINT},
|
||||
last_report_status = #{lastReportStatus,jdbcType=VARCHAR},
|
||||
last_report_id = #{lastReportId,jdbcType=VARCHAR},
|
||||
num = #{num,jdbcType=INTEGER},
|
||||
num = #{num,jdbcType=BIGINT},
|
||||
custom_num = #{customNum,jdbcType=VARCHAR},
|
||||
deleted = #{deleted,jdbcType=BIT},
|
||||
pos = #{pos,jdbcType=BIGINT},
|
||||
|
@ -545,7 +545,7 @@
|
|||
ref_id = #{refId,jdbcType=VARCHAR},
|
||||
latest = #{latest,jdbcType=BIT},
|
||||
project_id = #{projectId,jdbcType=VARCHAR},
|
||||
api_scenario_module_id = #{apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
module_id = #{moduleId,jdbcType=VARCHAR},
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
tags = #{tags,jdbcType=VARCHAR},
|
||||
grouped = #{grouped,jdbcType=BIT},
|
||||
|
@ -559,18 +559,18 @@
|
|||
</update>
|
||||
<insert id="batchInsert" parameterType="map">
|
||||
insert into api_scenario
|
||||
(id, `name`, `level`, `status`, principal, step_total, pass_rate, last_report_status,
|
||||
(id, `name`, priority, `status`, principal, step_total, pass_rate, last_report_status,
|
||||
last_report_id, num, custom_num, deleted, pos, version_id, ref_id, latest, project_id,
|
||||
api_scenario_module_id, description, tags, grouped, create_user, create_time, delete_time,
|
||||
delete_user, update_user, update_time)
|
||||
module_id, description, tags, grouped, create_user, create_time, delete_time, delete_user,
|
||||
update_user, update_time)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.level,jdbcType=VARCHAR},
|
||||
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.priority,jdbcType=VARCHAR},
|
||||
#{item.status,jdbcType=VARCHAR}, #{item.principal,jdbcType=VARCHAR}, #{item.stepTotal,jdbcType=INTEGER},
|
||||
#{item.passRate,jdbcType=BIGINT}, #{item.lastReportStatus,jdbcType=VARCHAR}, #{item.lastReportId,jdbcType=VARCHAR},
|
||||
#{item.num,jdbcType=INTEGER}, #{item.customNum,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT},
|
||||
#{item.num,jdbcType=BIGINT}, #{item.customNum,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT},
|
||||
#{item.pos,jdbcType=BIGINT}, #{item.versionId,jdbcType=VARCHAR}, #{item.refId,jdbcType=VARCHAR},
|
||||
#{item.latest,jdbcType=BIT}, #{item.projectId,jdbcType=VARCHAR}, #{item.apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
#{item.latest,jdbcType=BIT}, #{item.projectId,jdbcType=VARCHAR}, #{item.moduleId,jdbcType=VARCHAR},
|
||||
#{item.description,jdbcType=VARCHAR}, #{item.tags,jdbcType=VARCHAR}, #{item.grouped,jdbcType=BIT},
|
||||
#{item.createUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.deleteTime,jdbcType=BIGINT},
|
||||
#{item.deleteUser,jdbcType=VARCHAR}, #{item.updateUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=BIGINT}
|
||||
|
@ -593,8 +593,8 @@
|
|||
<if test="'name'.toString() == column.value">
|
||||
#{item.name,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'level'.toString() == column.value">
|
||||
#{item.level,jdbcType=VARCHAR}
|
||||
<if test="'priority'.toString() == column.value">
|
||||
#{item.priority,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'status'.toString() == column.value">
|
||||
#{item.status,jdbcType=VARCHAR}
|
||||
|
@ -615,7 +615,7 @@
|
|||
#{item.lastReportId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'num'.toString() == column.value">
|
||||
#{item.num,jdbcType=INTEGER}
|
||||
#{item.num,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="'custom_num'.toString() == column.value">
|
||||
#{item.customNum,jdbcType=VARCHAR}
|
||||
|
@ -638,8 +638,8 @@
|
|||
<if test="'project_id'.toString() == column.value">
|
||||
#{item.projectId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'api_scenario_module_id'.toString() == column.value">
|
||||
#{item.apiScenarioModuleId,jdbcType=VARCHAR}
|
||||
<if test="'module_id'.toString() == column.value">
|
||||
#{item.moduleId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'description'.toString() == column.value">
|
||||
#{item.description,jdbcType=VARCHAR}
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
<resultMap id="BaseResultMap" type="io.metersphere.api.domain.ApiScenarioModule">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="level" jdbcType="INTEGER" property="level" />
|
||||
<result column="pos" jdbcType="INTEGER" property="pos" />
|
||||
<result column="pos" jdbcType="BIGINT" property="pos" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="update_user" jdbcType="VARCHAR" property="updateUser" />
|
||||
|
@ -72,7 +71,7 @@
|
|||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, `name`, `level`, pos, create_time, update_time, update_user, create_user, project_id,
|
||||
id, `name`, pos, create_time, update_time, update_user, create_user, project_id,
|
||||
parent_id
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiScenarioModuleExample" resultMap="BaseResultMap">
|
||||
|
@ -106,14 +105,14 @@
|
|||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.api.domain.ApiScenarioModule">
|
||||
insert into api_scenario_module (id, `name`, `level`,
|
||||
pos, create_time, update_time,
|
||||
update_user, create_user, project_id,
|
||||
parent_id)
|
||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER},
|
||||
#{pos,jdbcType=INTEGER}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
|
||||
#{updateUser,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR},
|
||||
#{parentId,jdbcType=VARCHAR})
|
||||
insert into api_scenario_module (id, `name`, pos,
|
||||
create_time, update_time, update_user,
|
||||
create_user, project_id, parent_id
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT},
|
||||
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{updateUser,jdbcType=VARCHAR},
|
||||
#{createUser,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiScenarioModule">
|
||||
insert into api_scenario_module
|
||||
|
@ -124,9 +123,6 @@
|
|||
<if test="name != null">
|
||||
`name`,
|
||||
</if>
|
||||
<if test="level != null">
|
||||
`level`,
|
||||
</if>
|
||||
<if test="pos != null">
|
||||
pos,
|
||||
</if>
|
||||
|
@ -156,11 +152,8 @@
|
|||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
#{level,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="pos != null">
|
||||
#{pos,jdbcType=INTEGER},
|
||||
#{pos,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=BIGINT},
|
||||
|
@ -197,11 +190,8 @@
|
|||
<if test="record.name != null">
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.level != null">
|
||||
`level` = #{record.level,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.pos != null">
|
||||
pos = #{record.pos,jdbcType=INTEGER},
|
||||
pos = #{record.pos,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
|
@ -230,8 +220,7 @@
|
|||
update api_scenario_module
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
`level` = #{record.level,jdbcType=INTEGER},
|
||||
pos = #{record.pos,jdbcType=INTEGER},
|
||||
pos = #{record.pos,jdbcType=BIGINT},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
update_user = #{record.updateUser,jdbcType=VARCHAR},
|
||||
|
@ -248,11 +237,8 @@
|
|||
<if test="name != null">
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
`level` = #{level,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="pos != null">
|
||||
pos = #{pos,jdbcType=INTEGER},
|
||||
pos = #{pos,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
|
@ -278,8 +264,7 @@
|
|||
<update id="updateByPrimaryKey" parameterType="io.metersphere.api.domain.ApiScenarioModule">
|
||||
update api_scenario_module
|
||||
set `name` = #{name,jdbcType=VARCHAR},
|
||||
`level` = #{level,jdbcType=INTEGER},
|
||||
pos = #{pos,jdbcType=INTEGER},
|
||||
pos = #{pos,jdbcType=BIGINT},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
update_user = #{updateUser,jdbcType=VARCHAR},
|
||||
|
@ -290,14 +275,14 @@
|
|||
</update>
|
||||
<insert id="batchInsert" parameterType="map">
|
||||
insert into api_scenario_module
|
||||
(id, `name`, `level`, pos, create_time, update_time, update_user, create_user, project_id,
|
||||
(id, `name`, pos, create_time, update_time, update_user, create_user, project_id,
|
||||
parent_id)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.level,jdbcType=INTEGER},
|
||||
#{item.pos,jdbcType=INTEGER}, #{item.createTime,jdbcType=BIGINT}, #{item.updateTime,jdbcType=BIGINT},
|
||||
#{item.updateUser,jdbcType=VARCHAR}, #{item.createUser,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR},
|
||||
#{item.parentId,jdbcType=VARCHAR})
|
||||
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT},
|
||||
#{item.createTime,jdbcType=BIGINT}, #{item.updateTime,jdbcType=BIGINT}, #{item.updateUser,jdbcType=VARCHAR},
|
||||
#{item.createUser,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.parentId,jdbcType=VARCHAR}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="batchInsertSelective" parameterType="map">
|
||||
|
@ -316,11 +301,8 @@
|
|||
<if test="'name'.toString() == column.value">
|
||||
#{item.name,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'level'.toString() == column.value">
|
||||
#{item.level,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="'pos'.toString() == column.value">
|
||||
#{item.pos,jdbcType=INTEGER}
|
||||
#{item.pos,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="'create_time'.toString() == column.value">
|
||||
#{item.createTime,jdbcType=BIGINT}
|
||||
|
|
|
@ -161,7 +161,7 @@ CREATE UNIQUE INDEX uq_name_project_parent_type ON api_definition_module (projec
|
|||
CREATE TABLE IF NOT EXISTS api_scenario(
|
||||
`id` VARCHAR(50) NOT NULL COMMENT '' ,
|
||||
`name` VARCHAR(255) NOT NULL COMMENT '场景名称' ,
|
||||
`level` VARCHAR(10) NOT NULL COMMENT '场景级别/P0/P1等' ,
|
||||
`priority` VARCHAR(10) NOT NULL COMMENT '场景级别/P0/P1等' ,
|
||||
`status` VARCHAR(20) NOT NULL COMMENT '场景状态/未规划/已完成 等' ,
|
||||
`principal` VARCHAR(50) NOT NULL COMMENT '责任人/用户fk' ,
|
||||
`step_total` INT NOT NULL DEFAULT 0 COMMENT '场景步骤总数' ,
|
||||
|
@ -176,7 +176,7 @@ CREATE TABLE IF NOT EXISTS api_scenario(
|
|||
`ref_id` VARCHAR(50) COMMENT '引用资源fk' ,
|
||||
`latest` BIT(1) DEFAULT 0 COMMENT '是否为最新版本 0:否,1:是' ,
|
||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目fk' ,
|
||||
`api_scenario_module_id` VARCHAR(50) COMMENT '场景模块fk' ,
|
||||
`module_id` VARCHAR(50) COMMENT '场景模块fk' ,
|
||||
`description` VARCHAR(500) COMMENT '描述信息' ,
|
||||
`tags` VARCHAR(1000) COMMENT '标签' ,
|
||||
`grouped` BIT(1) NOT NULL DEFAULT 0 COMMENT '是否为环境组' ,
|
||||
|
@ -192,7 +192,7 @@ CREATE TABLE IF NOT EXISTS api_scenario(
|
|||
COLLATE = utf8mb4_general_ci COMMENT = '场景';
|
||||
|
||||
|
||||
CREATE INDEX idx_api_scenario_module_id ON api_scenario(api_scenario_module_id);
|
||||
CREATE INDEX idx_module_id ON api_scenario(module_id);
|
||||
CREATE INDEX idx_ref_id ON api_scenario(ref_id);
|
||||
CREATE INDEX idx_version_id ON api_scenario(version_id);
|
||||
CREATE INDEX idx_project_id ON api_scenario(project_id);
|
||||
|
@ -202,7 +202,7 @@ CREATE INDEX idx_create_time ON api_scenario(create_time desc);
|
|||
CREATE INDEX idx_update_time ON api_scenario(update_time desc);
|
||||
CREATE INDEX idx_create_user ON api_scenario(create_user);
|
||||
CREATE INDEX idx_num ON api_scenario(num);
|
||||
CREATE INDEX idx_level ON api_scenario(level);
|
||||
CREATE INDEX idx_priority ON api_scenario(priority);
|
||||
CREATE INDEX idx_name ON api_scenario(name);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS api_scenario_follower(
|
||||
|
@ -219,8 +219,7 @@ CREATE INDEX uk_api_scenario_id_follow_id ON api_scenario_follower(api_scenario_
|
|||
CREATE TABLE IF NOT EXISTS api_scenario_module(
|
||||
`id` VARCHAR(50) NOT NULL COMMENT '场景模块pk' ,
|
||||
`name` VARCHAR(255) NOT NULL COMMENT '模块名称' ,
|
||||
`level` INT NOT NULL DEFAULT 1 COMMENT '模块级别' ,
|
||||
`pos` INT NOT NULL COMMENT '排序' ,
|
||||
`pos` BIGINT NOT NULL COMMENT '排序' ,
|
||||
`create_time` BIGINT NOT NULL COMMENT '创建时间' ,
|
||||
`update_time` BIGINT NOT NULL COMMENT '更新时间' ,
|
||||
`update_user` VARCHAR(50) NOT NULL COMMENT '更新人' ,
|
||||
|
@ -234,6 +233,9 @@ CREATE TABLE IF NOT EXISTS api_scenario_module(
|
|||
|
||||
|
||||
CREATE INDEX idx_project_id ON api_scenario_module(project_id);
|
||||
CREATE INDEX idx_pos ON api_scenario_module(pos);
|
||||
CREATE UNIQUE INDEX uq_name_project_parent_type ON api_scenario_module (project_id, name, parent_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS api_scenario_reference(
|
||||
`id` VARCHAR(50) NOT NULL COMMENT '引用关系pk' ,
|
||||
|
|
|
@ -152,11 +152,29 @@ INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT
|
|||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION:READ+IMPORT');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION:READ+EXPORT');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION:READ+EXECUTE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION:READ+RECOVER');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION:READ+DEBUG');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_CASE:READ');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_CASE:READ+ADD');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_CASE:READ+UPDATE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_CASE:READ+DELETE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_CASE:READ+EXECUTE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_CASE:READ+RECOVER');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_MOCK:READ');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_MOCK:READ+ADD');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_MOCK:READ+UPDATE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_MOCK:READ+DELETE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_DEFINITION_MOCK:READ+EXECUTE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_SCENARIO:READ');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_SCENARIO:READ+ADD');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_SCENARIO:READ+UPDATE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_SCENARIO:READ+DELETE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_SCENARIO:READ+EXECUTE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_SCENARIO:READ+RECOVER');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_SCENARIO:READ+IMPORT');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_SCENARIO:READ+EXPORT');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_SCENARIO:READ+DEBUG');
|
||||
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'FUNCTIONAL_CASE:READ');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'FUNCTIONAL_CASE:READ+ADD');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'FUNCTIONAL_CASE:READ+UPDATE');
|
||||
|
@ -237,11 +255,29 @@ INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT
|
|||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION:READ+IMPORT');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION:READ+EXPORT');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION:READ+EXECUTE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION:READ+RECOVER');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION:READ+DEBUG');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_CASE:READ');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_CASE:READ+ADD');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_CASE:READ+UPDATE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_CASE:READ+DELETE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_CASE:READ+EXECUTE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_CASE:READ+RECOVER');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_MOCK:READ');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_MOCK:READ+ADD');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_MOCK:READ+UPDATE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_MOCK:READ+DELETE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_DEFINITION_MOCK:READ+EXECUTE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_SCENARIO:READ');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_SCENARIO:READ+ADD');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_SCENARIO:READ+UPDATE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_SCENARIO:READ+DELETE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_SCENARIO:READ+EXECUTE');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_SCENARIO:READ+RECOVER');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_SCENARIO:READ+IMPORT');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_SCENARIO:READ+EXPORT');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'PROJECT_API_SCENARIO:READ+DEBUG');
|
||||
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'FUNCTIONAL_CASE:READ');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'FUNCTIONAL_CASE:READ+ADD');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_member', 'FUNCTIONAL_CASE:READ+UPDATE');
|
||||
|
|
|
@ -254,6 +254,7 @@ public class PermissionConstants {
|
|||
public static final String PROJECT_API_DEFINITION_IMPORT = "PROJECT_API_DEFINITION:READ+IMPORT";
|
||||
public static final String PROJECT_API_DEFINITION_EXPORT = "PROJECT_API_DEFINITION:READ+EXPORT";
|
||||
public static final String PROJECT_API_DEFINITION_EXECUTE = "PROJECT_API_DEFINITION:READ+EXECUTE";
|
||||
public static final String PROJECT_API_DEFINITION_DEBUG = "PROJECT_API_DEFINITION:READ+DEBUG";
|
||||
public static final String PROJECT_API_DEFINITION_CASE_READ = "PROJECT_API_DEFINITION_CASE:READ";
|
||||
public static final String PROJECT_API_DEFINITION_CASE_ADD = "PROJECT_API_DEFINITION_CASE:READ+ADD";
|
||||
public static final String PROJECT_API_DEFINITION_CASE_UPDATE = "PROJECT_API_DEFINITION_CASE:READ+UPDATE";
|
||||
|
@ -266,6 +267,18 @@ public class PermissionConstants {
|
|||
public static final String PROJECT_API_DEFINITION_MOCK_UPDATE = "PROJECT_API_DEFINITION_MOCK:READ+UPDATE";
|
||||
public static final String PROJECT_API_DEFINITION_MOCK_DELETE = "PROJECT_API_DEFINITION_MOCK:READ+DELETE";
|
||||
public static final String PROJECT_API_DEFINITION_MOCK_EXECUTE = "PROJECT_API_DEFINITION_MOCK:READ+EXECUTE";
|
||||
/* ----API_SCENARIO---- */
|
||||
public static final String PROJECT_API_SCENARIO_READ = "PROJECT_API_SCENARIO:READ";
|
||||
public static final String PROJECT_API_SCENARIO_ADD = "PROJECT_API_SCENARIO:READ+ADD";
|
||||
public static final String PROJECT_API_SCENARIO_UPDATE = "PROJECT_API_SCENARIO:READ+UPDATE";
|
||||
public static final String PROJECT_API_SCENARIO_DELETE = "PROJECT_API_SCENARIO:READ+DELETE";
|
||||
public static final String PROJECT_API_SCENARIO_EXECUTE = "PROJECT_API_SCENARIO:READ+EXECUTE";
|
||||
public static final String PROJECT_API_SCENARIO_IMPORT = "PROJECT_API_SCENARIO:READ+IMPORT";
|
||||
public static final String PROJECT_API_SCENARIO_EXPORT = "PROJECT_API_SCENARIO:READ+EXPORT";
|
||||
public static final String PROJECT_API_SCENARIO_DEBUG = "PROJECT_API_SCENARIO:READ+DEBUG";
|
||||
|
||||
|
||||
|
||||
|
||||
/*------ end: API_MANAGEMENT ------*/
|
||||
//个人中心
|
||||
|
|
|
@ -286,18 +286,15 @@ api_debug_module.pos.not_blank=模块位置不能为空
|
|||
api_debug_module.name.not_contain_slash=模块名称不能包含斜杠
|
||||
api_debug_module.unplanned_request=未规划请求
|
||||
api_unplanned_request=未规划接口
|
||||
|
||||
api_unplanned_scenario=未规划场景
|
||||
#module: ApiEnvironmentConfig
|
||||
api_environment_config.id.not_blank=ID不能为空
|
||||
api_environment_config.environment_id.length_range=环境ID长度必须在1-50之间
|
||||
api_environment_config.environment_id.not_blank=环境ID不能为空
|
||||
|
||||
#module:ApiDefinitionCustomField
|
||||
api_definition_custom_field.api_id.not_blank=接口ID不能为空
|
||||
api_definition_custom_field.field_id.not_blank=自定义字段ID不能为空
|
||||
|
||||
api_module.not.exist=模块不存在
|
||||
|
||||
permission.api.name=接口测试
|
||||
permission.api_mock.name=接口 MOCK
|
||||
api_debug_exist=接口已存在
|
||||
|
@ -305,6 +302,5 @@ follow=关注
|
|||
unfollow=取消关注
|
||||
api_definition_exist=接口已存在
|
||||
api_definition_mock_exist=接口 MOCK 已存在
|
||||
|
||||
execute_resource_pool_not_config_error=请在【项目管理-应用管理-接口测试】中选择资源池
|
||||
resource_pool_execute_error=资源池调用失败
|
||||
|
|
|
@ -262,7 +262,6 @@ api_scenario_report_detail.resource_id.length_range=Each step in the scenario re
|
|||
api_scenario_report_detail.resource_id.not_blank=The unique identifier requested by each step in the scenario cannot be empty
|
||||
#module:ApiDefinitionBlob
|
||||
api_definition_blob.api_definition_id.not_blank=The interface fk/one-to-one relationship cannot be empty
|
||||
|
||||
#module: ApiDebug
|
||||
api_debug.id.not_blank=ID cannot be blank
|
||||
api_debug.id.length_range=The interface ID length must be between 1-50
|
||||
|
@ -278,7 +277,6 @@ api_debug.create_user.not_blank=The creator cannot be empty
|
|||
api_debug.create_user.length_range=Creator length must be between {min}-{max}
|
||||
api_debug.update_user.not_blank=Modifier cannot be blank
|
||||
api_debug.update_user.length_range=Modifier length must be between {min}-{max}
|
||||
|
||||
#module: ApiDebugModule
|
||||
api_debug_module.id.not_blank=ID cannot be blank
|
||||
api_debug_module.id.length_range=Module ID length must be between 1-50
|
||||
|
@ -292,18 +290,15 @@ api_debug_module.pos.not_blank=Module position cannot be blank
|
|||
api_debug_module.name.not_contain_slash=Module name cannot contain slashes
|
||||
api_debug_module.unplanned_request=Unplanned request
|
||||
api_unplanned_request=Unplanned Api
|
||||
|
||||
api_unplanned_scenario=Unplanned scenario
|
||||
#module: ApiEnvironmentConfig
|
||||
api_environment_config.id.not_blank=ID cannot be blank
|
||||
api_environment_config.environment_id.length_range=Environment ID length must be between 1-50
|
||||
api_environment_config.environment_id.not_blank=Environment ID cannot be blank
|
||||
|
||||
#module:ApiDefinitionCustomField
|
||||
api_definition_custom_field.api_id.not_blank=Interface pk cannot be empty
|
||||
api_definition_custom_field.field_id.not_blank=Field ID cannot be empty
|
||||
|
||||
api_module.not.exist=The module does not exist
|
||||
|
||||
permission.api.name=API Test
|
||||
permission.api_mock.name=API MOCK
|
||||
api_debug_exist=The API already exists
|
||||
|
@ -311,6 +306,5 @@ follow=Follow
|
|||
unfollow=Unfollow
|
||||
api_definition_exist=The API already exists
|
||||
api_definition_mock_exist=The API MOCK already exists
|
||||
|
||||
execute_resource_pool_not_config_error=Select a resource pool in 【Project Management - Application Management - Interface Testing】
|
||||
resource_pool_execute_error=The resource pool call failed
|
||||
|
|
|
@ -262,7 +262,6 @@ api_scenario_report_detail.resource_id.length_range=场景中各个步骤请求
|
|||
api_scenario_report_detail.resource_id.not_blank=场景中各个步骤请求唯一标识不能为空
|
||||
#module:ApiDefinitionBlob
|
||||
api_definition_blob.api_definition_id.not_blank=接口ID/ 一对一关系不能为空
|
||||
|
||||
#module: ApiDebug
|
||||
api_debug.id.not_blank=ID不能为空
|
||||
api_debug.id.length_range=接口ID长度必须在1-50之间
|
||||
|
@ -278,7 +277,6 @@ api_debug.create_user.not_blank=创建人不能为空
|
|||
api_debug.create_user.length_range=创建人长度必须在{min}和{max}之间
|
||||
api_debug.update_user.not_blank=修改人不能为空
|
||||
api_debug.update_user.length_range=修改人长度必须在{min}和{max}之间
|
||||
|
||||
#module: ApiDebugModule
|
||||
api_debug_module.id.not_blank=ID不能为空
|
||||
api_debug_module.id.length_range=模块ID长度必须在1-50之间
|
||||
|
@ -292,18 +290,15 @@ api_debug_module.pos.not_blank=模块位置不能为空
|
|||
api_debug_module.name.not_contain_slash=名称中不能包含正反斜杠
|
||||
api_debug_module.unplanned_request=未规划请求
|
||||
api_unplanned_request=未规划接口
|
||||
|
||||
api_unplanned_scenario=未规划场景
|
||||
#module: ApiEnvironmentConfig
|
||||
api_environment_config.id.not_blank=ID不能为空
|
||||
api_environment_config.environment_id.length_range=环境ID长度必须在1-50之间
|
||||
api_environment_config.environment_id.not_blank=环境ID不能为空
|
||||
|
||||
#module:ApiDefinitionCustomField
|
||||
api_definition_custom_field.api_id.not_blank=接口ID不能为空
|
||||
api_definition_custom_field.field_id.not_blank=自定义字段ID不能为空
|
||||
|
||||
api_module.not.exist=模块不存在
|
||||
|
||||
permission.api.name=接口测试
|
||||
permission.api_mock.name=接口 MOCK
|
||||
api_debug_exist=接口已存在
|
||||
|
@ -311,6 +306,5 @@ follow=关注
|
|||
unfollow=取消关注
|
||||
api_definition_exist=接口已存在
|
||||
api_definition_mock_exist=接口 MOCK 已存在
|
||||
|
||||
execute_resource_pool_not_config_error=请在【项目管理-应用管理-接口测试】中选择资源池
|
||||
resource_pool_execute_error=资源池调用失败
|
||||
|
|
|
@ -262,7 +262,6 @@ api_scenario_report_detail.resource_id.length_range=場景中各個步驟請求
|
|||
api_scenario_report_detail.resource_id.not_blank=場景中各個步驟請求唯一標識不能為空
|
||||
#module:ApiDefinitionBlob
|
||||
api_definition_blob.api_definition_id.not_blank=接口ID/ 一對一關繫不能為空
|
||||
|
||||
#module: ApiDebug
|
||||
api_debug.id.not_blank=ID不能為空
|
||||
api_debug.id.length_range=接口ID長度必須在1-50之間
|
||||
|
@ -278,7 +277,6 @@ api_debug.create_user.not_blank=創建人不能為空
|
|||
api_debug.create_user.length_range=創建人長度必須在{min}和{max}之間
|
||||
api_debug.update_user.not_blank=修改人不能為空
|
||||
api_debug.update_user.length_range=修改人長度必須在{min}和{max}之間
|
||||
|
||||
#module: ApiDebugModule
|
||||
api_debug_module.id.not_blank=ID不能為空
|
||||
api_debug_module.id.length_range=模塊ID長度必須在1-50之間
|
||||
|
@ -291,19 +289,16 @@ api_debug_module.project_id.length_range=項目ID長度必須在1-50之間
|
|||
api_debug_module.pos.not_blank=模塊位置不能為空
|
||||
api_debug_module.name.not_contain_slash=模塊名稱不能包含斜線
|
||||
api_debug_module.unplanned_request=未規劃請求
|
||||
api_unplanned_request=未规划接口
|
||||
|
||||
api_unplanned_request=未規劃請求
|
||||
api_unplanned_scenario=未規劃場景
|
||||
#module: ApiEnvironmentConfig
|
||||
api_environment_config.id.not_blank=ID不能為空
|
||||
api_environment_config.environment_id.length_range=環境ID長度必須在1-50之間
|
||||
api_environment_config.environment_id.not_blank=環境ID不能為空
|
||||
|
||||
#module:ApiDefinitionCustomField
|
||||
api_definition_custom_field.api_id.not_blank=接口ID不能為空
|
||||
api_definition_custom_field.field_id.not_blank=自定義字段ID不能爲空
|
||||
|
||||
api_module.not.exist=模塊不存在
|
||||
|
||||
permission.api.name=接口測試
|
||||
permission.api_mock.name=接口 MOCK
|
||||
api_debug_exist=接口已存在
|
||||
|
@ -311,6 +306,5 @@ follow=关注
|
|||
unfollow=取消关注
|
||||
api_definition_exist=接口已存在
|
||||
api_definition_mock_exist=接口 MOCK 已存在
|
||||
|
||||
execute_resource_pool_not_config_error=請在【項目管理-應用管理-接口測試】中選擇資源池
|
||||
resource_pool_execute_error=資源池調用失敗
|
||||
|
|
|
@ -440,6 +440,7 @@ permission.import=导入
|
|||
permission.recover=恢复
|
||||
permission.export=导出
|
||||
permission.execute=执行
|
||||
permission.debug=调试
|
||||
|
||||
file_name_illegal_error=文件名不合法
|
||||
plugin_enable_error=插件未启用
|
||||
|
|
|
@ -443,6 +443,7 @@ permission.import=Import
|
|||
permission.recover=Recover
|
||||
permission.export=Export
|
||||
permission.execute=Execute
|
||||
permission.debug=Debug
|
||||
|
||||
file_name_illegal_error=File name is illegal
|
||||
plugin_enable_error=Plugin is not enabled
|
||||
|
|
|
@ -441,6 +441,7 @@ permission.import=导入
|
|||
permission.recover=恢复
|
||||
permission.export=导出
|
||||
permission.execute=执行
|
||||
permission.debug=调试
|
||||
|
||||
file_name_illegal_error=文件名不合法
|
||||
plugin_enable_error=插件未启用
|
||||
|
|
|
@ -439,6 +439,7 @@ permission.import=導入
|
|||
permission.recover=恢復
|
||||
permission.export=導出
|
||||
permission.execute=執行
|
||||
permission.debug=調試
|
||||
|
||||
file_name_illegal_error=文件名不合法
|
||||
plugin_enable_error=插件未啟用
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ApiDefinitionModuleController {
|
|||
@GetMapping("/delete/{id}")
|
||||
@Operation(summary = "接口测试-接口管理-模块-删除模块")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_DELETE)
|
||||
@CheckOwner(resourceId = "#=id", resourceType = "api_definition_module")
|
||||
@CheckOwner(resourceId = "#id", resourceType = "api_definition_module")
|
||||
public void deleteNode(@PathVariable String id) {
|
||||
apiDefinitionModuleService.deleteModule(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package io.metersphere.api.controller.scenario;
|
||||
|
||||
import io.metersphere.api.dto.debug.ModuleCreateRequest;
|
||||
import io.metersphere.api.dto.debug.ModuleUpdateRequest;
|
||||
import io.metersphere.api.dto.definition.ApiModuleRequest;
|
||||
import io.metersphere.api.dto.definition.ApiScenarioModuleRequest;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioModuleService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.dto.sdk.request.NodeMoveRequest;
|
||||
import io.metersphere.system.security.CheckOwner;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "接口测试-接口场景-模块")
|
||||
@RestController
|
||||
@RequestMapping("/api/scenario/module")
|
||||
public class ApiScenarioModuleController {
|
||||
|
||||
@Resource
|
||||
private ApiScenarioModuleService apiScenarioModuleService;
|
||||
|
||||
@PostMapping("/tree")
|
||||
@Operation(summary = "接口测试-接口场景-模块-查找模块")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ)
|
||||
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
||||
public List<BaseTreeNode> getTree(@RequestBody @Validated ApiScenarioModuleRequest request) {
|
||||
return apiScenarioModuleService.getTree(request);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "接口测试-接口场景-模块-添加模块")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_ADD)
|
||||
public String add(@RequestBody @Validated ModuleCreateRequest request) {
|
||||
return apiScenarioModuleService.add(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "接口测试-接口场景-模块-修改模块")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.id", resourceType = "api_scenario_module")
|
||||
public boolean update(@RequestBody @Validated ModuleUpdateRequest request) {
|
||||
apiScenarioModuleService.update(request, SessionUtils.getUserId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
@Operation(summary = "接口测试-接口场景-模块-删除模块")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_DELETE)
|
||||
@CheckOwner(resourceId = "#id", resourceType = "api_scenario_module")
|
||||
public void deleteNode(@PathVariable String id) {
|
||||
apiScenarioModuleService.deleteModule(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/move")
|
||||
@Operation(summary = "接口测试-接口场景-模块-移动模块")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_UPDATE)
|
||||
public void moveNode(@Validated @RequestBody NodeMoveRequest request) {
|
||||
apiScenarioModuleService.moveNode(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/count")
|
||||
@Operation(summary = "接口测试-接口场景-模块-统计模块数量")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ)
|
||||
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
||||
public Map<String, Long> moduleCount(@Validated @RequestBody ApiScenarioModuleRequest request) {
|
||||
return apiScenarioModuleService.moduleCount(request, false);
|
||||
}
|
||||
|
||||
@PostMapping("/trash/count")
|
||||
@Operation(summary = "接口测试-接口场景-模块-统计回收站模块数量")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ)
|
||||
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
||||
public Map<String, Long> moduleCountTrash(@Validated @RequestBody ApiScenarioModuleRequest request) {
|
||||
return apiScenarioModuleService.moduleCount(request, true);
|
||||
}
|
||||
|
||||
@PostMapping("/trash/tree")
|
||||
@Operation(summary = "接口测试-接口场景-模块-查找模块")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ)
|
||||
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
||||
public List<BaseTreeNode> getTrashTree(@RequestBody @Validated ApiModuleRequest request) {
|
||||
return apiScenarioModuleService.getTrashTree(request);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.sdk.constants.ModuleConstants;
|
||||
import io.metersphere.system.dto.sdk.BaseCondition;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
@ -9,7 +10,7 @@ import lombok.Data;
|
|||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApiModuleRequest {
|
||||
public class ApiModuleRequest extends BaseCondition {
|
||||
@Schema(description = "模块ID(根据模块树查询时要把当前节点以及子节点都放在这里。)")
|
||||
private List<@NotBlank String> moduleIds;
|
||||
|
||||
|
@ -24,4 +25,10 @@ public class ApiModuleRequest {
|
|||
|
||||
@Schema(description = "关键字")
|
||||
private String keyword;
|
||||
|
||||
@Schema(description = "版本fk")
|
||||
private String versionId;
|
||||
|
||||
@Schema(description = "版本引用fk")
|
||||
private String refId;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.system.dto.sdk.BaseCondition;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApiScenarioModuleRequest extends BaseCondition {
|
||||
@Schema(description = "模块ID(根据模块树查询时要把当前节点以及子节点都放在这里。)")
|
||||
private List<@NotBlank String> moduleIds;
|
||||
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_definition_module.project_id.not_blank}")
|
||||
private String projectId;
|
||||
|
||||
@Schema(description = "关键字")
|
||||
private String keyword;
|
||||
|
||||
@Schema(description = "版本fk")
|
||||
private String versionId;
|
||||
|
||||
@Schema(description = "版本引用fk")
|
||||
private String refId;
|
||||
}
|
|
@ -43,5 +43,7 @@ public interface ExtApiDefinitionMapper {
|
|||
|
||||
List<ApiDefinitionImportDTO> importList(@Param("request") ApiDefinitionPageRequest request);
|
||||
|
||||
List<String> selectIdsByIdsAndDeleted(@Param("ids")List<String> ids, @Param("deleted") boolean deleted);
|
||||
List<String> selectIdsByIdsAndDeleted(@Param("ids") List<String> ids, @Param("deleted") boolean deleted);
|
||||
|
||||
List<String> selectByProjectId(@Param("projectId") String projectId);
|
||||
}
|
||||
|
|
|
@ -147,6 +147,10 @@
|
|||
</foreach>
|
||||
and deleted = #{deleted}
|
||||
</select>
|
||||
<select id="selectByProjectId" resultType="java.lang.String">
|
||||
select id from api_definition
|
||||
where project_id = #{projectId}
|
||||
</select>
|
||||
|
||||
<update id="batchDeleteByRefId">
|
||||
update api_definition
|
||||
|
|
|
@ -10,4 +10,5 @@ public interface ExtApiDefinitionMockMapper {
|
|||
|
||||
List<ApiDefinitionMockDTO> list(@Param("request") ApiDefinitionMockPageRequest request);
|
||||
|
||||
List<String> getIdsByApiIds(@Param("ids") List<String> ids);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,15 @@
|
|||
where m.api_definition_id = #{request.apiDefinitionId}
|
||||
<include refid="queryWhereCondition"/>
|
||||
</select>
|
||||
<select id="getIdsByApiIds" resultType="java.lang.String">
|
||||
select
|
||||
m.id
|
||||
from api_definition_mock m
|
||||
where m.api_definition_id in
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<sql id="queryWhereCondition">
|
||||
|
|
|
@ -44,13 +44,15 @@
|
|||
method,
|
||||
protocol
|
||||
FROM api_definition
|
||||
<include refid="api_request"/>
|
||||
where api_definition.deleted = #{deleted}
|
||||
<include refid="queryWhereCondition"/>
|
||||
ORDER BY update_time DESC
|
||||
</select>
|
||||
<select id="countModuleIdByRequest" resultType="io.metersphere.project.dto.ModuleCountDTO">
|
||||
SELECT module_id AS moduleId, count(id) AS dataCount
|
||||
FROM api_definition
|
||||
<include refid="api_request"/>
|
||||
where api_definition.deleted = #{deleted}
|
||||
<include refid="queryWhereCondition"/>
|
||||
GROUP BY api_definition.module_id
|
||||
</select>
|
||||
<select id="selectBaseModuleById" resultType="io.metersphere.system.dto.sdk.BaseModule">
|
||||
|
@ -168,35 +170,214 @@
|
|||
|
||||
<sql id="api_request">
|
||||
<where>
|
||||
api_definition.deleted = #{deleted}
|
||||
<if test="request.projectId != null and request.projectId != ''">
|
||||
AND api_definition.project_id = #{request.projectId}
|
||||
AND m.project_id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
AND api_definition.name like CONCAT('%', #{request.keyword},'%')
|
||||
AND m.name like CONCAT('%', #{request.keyword},'%')
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() != 0">
|
||||
AND api_definition.module_id IN
|
||||
AND m.id IN
|
||||
<foreach collection="request.moduleIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.protocol != null and request.protocol != ''">
|
||||
AND api_definition.protocol = #{request.protocol}
|
||||
</if>
|
||||
AND api_definition.latest = 1
|
||||
<!--<if test="request.versionId != null and request.versionId != ''">
|
||||
and api_definition.version_id = #{request.versionId}
|
||||
</if>
|
||||
<if test="request.refId != null and request.refId != ''">
|
||||
and api_definition.ref_id = #{request.refId}
|
||||
</if>
|
||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||
AND api_definition.latest = 1
|
||||
</if>-->
|
||||
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<sql id="queryWhereCondition">
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
and (
|
||||
api_definition.num like concat('%', #{request.keyword},'%')
|
||||
or api_definition.name like concat('%', #{request.keyword},'%')
|
||||
or api_definition.tags like JSON_CONTAINS(tags, concat('["',#{request.keyword},'"]'))
|
||||
)
|
||||
</if>
|
||||
<if test="request.projectId != null and request.projectId != ''">
|
||||
and api_definition.project_id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.protocol != null and request.protocol != ''">
|
||||
AND api_definition.protocol = #{request.protocol}
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
and api_definition.module_id in
|
||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||
#{nodeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="filters">
|
||||
<property name="filter" value="request.filter"/>
|
||||
</include>
|
||||
|
||||
<if test="request.combine != null and request.combine != ''">
|
||||
<include refid="combine">
|
||||
<property name="condition" value="request.combine"/>
|
||||
<property name="name" value="request.name"/>
|
||||
<property name="ObjectTags" value="request.combine.tags"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<include refid="queryVersionCondition">
|
||||
<property name="versionTable" value="api_definition"/>
|
||||
</include>
|
||||
</sql>
|
||||
|
||||
<sql id="queryVersionCondition">
|
||||
<if test="request.versionId != null and request.versionId != ''">
|
||||
and ${versionTable}.version_id = #{request.versionId}
|
||||
</if>
|
||||
<if test="request.refId != null and request.refId != ''">
|
||||
and ${versionTable}.ref_id = #{request.refId}
|
||||
</if>
|
||||
<if test="request.versionId == null and request.refId == null">
|
||||
AND ${versionTable}.latest = 1
|
||||
</if>
|
||||
</sql>
|
||||
<sql id="combine">
|
||||
<if test='${condition}.name != null and (${name} == null or ${name} == "")'>
|
||||
and api_definition.name
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.name"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test='${condition}.id != null'>
|
||||
and api_definition.num
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.id"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test="${condition}.updateTime != null">
|
||||
and api_definition.update_time
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.updateTime"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test="${condition}.createTime != null">
|
||||
and api_definition.create_time
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.createTime"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test="${condition}.status != null">
|
||||
and api_definition.status
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.status"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test="${condition}.path != null">
|
||||
and api_definition.path
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.path"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test="${condition}.method != null">
|
||||
and api_definition.method
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.method"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test='${condition}.tags != null and ${ObjectTags}.operator == "not like"'>
|
||||
and (api_definition.tags is null or api_definition.tags
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.tags"/>
|
||||
</include>
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test='${condition}.tags != null and ${ObjectTags}.operator == "like"'>
|
||||
and api_definition.tags
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.tags"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test="${condition}.customs != null and ${condition}.customs.size() > 0">
|
||||
<foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
|
||||
<if test="custom.value != ''">
|
||||
<if test='custom.operator == "not like" or custom.operator == "not in"'>
|
||||
and api_definition.id not in (
|
||||
</if>
|
||||
<if test='custom.operator != "not like" and custom.operator != "not in"'>
|
||||
and api_definition.id in (
|
||||
</if>
|
||||
select api_id from api_definition_custom_field where field_id = #{custom.id}
|
||||
<choose>
|
||||
<when test="custom.type == 'richText' or custom.type == 'textarea' or custom.operator == 'current user'">
|
||||
and `value`
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="custom"/>
|
||||
</include>
|
||||
</when>
|
||||
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
|
||||
and ${custom.value}
|
||||
</when>
|
||||
<when test="custom.type == 'date' or custom.type == 'datetime'">
|
||||
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="custom"/>
|
||||
</include>
|
||||
</when>
|
||||
<otherwise>
|
||||
and trim(both '"' from `value`)
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="custom"/>
|
||||
</include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
)
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<sql id="filters">
|
||||
<if test="${filter} != null and ${filter}.size() > 0">
|
||||
<foreach collection="${filter}.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key=='status'">
|
||||
and api_definition.status in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='method'">
|
||||
and api_definition.method in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='create_user'">
|
||||
and api_definition.create_user in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='version_id'">
|
||||
and api_definition.version_id in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key.startsWith('custom_single')">
|
||||
and api_definition.id in (
|
||||
select api_id from api_definition_custom_field where concat('custom_single_', field_id) = #{key}
|
||||
and trim(both '"' from `value`) in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
)
|
||||
</when>
|
||||
<when test="key.startsWith('custom_multiple')">
|
||||
and api_definition.id in (
|
||||
select api_id from api_definition_custom_field where concat('custom_multiple_', field_id) = #{key}
|
||||
and
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterMultipleWrapper"/>
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
<sql id="module_request">
|
||||
<where>
|
||||
<if test="request.projectId != null and request.projectId != ''">
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package io.metersphere.api.mapper;
|
||||
|
||||
import io.metersphere.api.dto.definition.ApiScenarioModuleRequest;
|
||||
import io.metersphere.project.dto.ModuleCountDTO;
|
||||
import io.metersphere.project.dto.NodeSortQueryParam;
|
||||
import io.metersphere.system.dto.sdk.BaseModule;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtApiScenarioModuleMapper {
|
||||
List<BaseTreeNode> selectBaseByRequest(@Param("request") ApiScenarioModuleRequest request);
|
||||
|
||||
List<BaseTreeNode> selectIdAndParentIdByRequest(@Param("request") ApiScenarioModuleRequest request);
|
||||
|
||||
List<String> selectChildrenIdsByParentIds(@Param("ids") List<String> deleteIds);
|
||||
|
||||
List<String> selectChildrenIdsSortByPos(String parentId);
|
||||
|
||||
void deleteByIds(@Param("ids") List<String> deleteId);
|
||||
|
||||
Long getMaxPosByParentId(String parentId);
|
||||
|
||||
BaseModule selectBaseModuleById(String dragNodeId);
|
||||
|
||||
BaseModule selectModuleByParentIdAndPosOperator(NodeSortQueryParam nodeSortQueryParam);
|
||||
|
||||
List<ModuleCountDTO> countModuleIdByRequest(@Param("request") ApiScenarioModuleRequest request, @Param("deleted") boolean deleted);
|
||||
|
||||
List<BaseTreeNode> selectNodeByIds(@Param("ids") List<String> ids);
|
||||
|
||||
List<BaseTreeNode> selectBaseByIds(@Param("ids") List<String> ids);
|
||||
|
||||
void deleteScenarioToGc(@Param("ids") List<String> ids, @Param("userId") String userId, @Param("time") long time);
|
||||
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.api.mapper.ExtApiScenarioModuleMapper">
|
||||
<select id="selectIdAndParentIdByRequest" resultType="io.metersphere.system.dto.sdk.BaseTreeNode">
|
||||
SELECT m.id,
|
||||
m.parent_id AS parentId
|
||||
FROM api_scenario_module m
|
||||
<include refid="module_request"/>
|
||||
ORDER BY pos
|
||||
</select>
|
||||
<select id="selectChildrenIdsByParentIds" resultType="java.lang.String">
|
||||
SELECT id
|
||||
FROM api_scenario_module
|
||||
WHERE parent_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
<delete id="deleteByIds">
|
||||
DELETE
|
||||
FROM api_scenario_module
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<update id="deleteScenarioToGc">
|
||||
update api_scenario
|
||||
set delete_user = #{userId},delete_time = #{time}, deleted = 1 , module_id = 'root'
|
||||
where ref_id in
|
||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</update>
|
||||
<select id="getMaxPosByParentId" resultType="java.lang.Long">
|
||||
SELECT max(pos)
|
||||
FROM api_scenario_module
|
||||
WHERE parent_id = #{0}
|
||||
</select>
|
||||
<select id="selectChildrenIdsSortByPos" resultType="java.lang.String">
|
||||
SELECT id
|
||||
FROM api_scenario_module
|
||||
WHERE parent_id = #{0}
|
||||
|
||||
ORDER BY pos ASC
|
||||
</select>
|
||||
<select id="countModuleIdByRequest" resultType="io.metersphere.project.dto.ModuleCountDTO">
|
||||
SELECT api_scenario.module_id AS moduleId, count(api_scenario.id) AS dataCount
|
||||
FROM api_scenario
|
||||
where api_scenario.deleted =#{deleted}
|
||||
<include refid="queryWhereCondition"/>
|
||||
GROUP BY api_scenario.module_id
|
||||
</select>
|
||||
<select id="selectBaseModuleById" resultType="io.metersphere.system.dto.sdk.BaseModule">
|
||||
SELECT id, name, pos, project_Id, parent_id
|
||||
FROM api_scenario_module
|
||||
WHERE id = #{0}
|
||||
</select>
|
||||
|
||||
<select id="selectModuleByParentIdAndPosOperator"
|
||||
parameterType="io.metersphere.project.dto.NodeSortQueryParam"
|
||||
resultType="io.metersphere.system.dto.sdk.BaseModule">
|
||||
SELECT id, name, pos, project_Id, parent_id
|
||||
FROM api_scenario_module
|
||||
WHERE parent_id = #{parentId}
|
||||
<if test="operator == 'moreThan'">
|
||||
AND pos > #{pos}
|
||||
</if>
|
||||
<if test="operator == 'lessThan'">
|
||||
AND pos < #{pos}
|
||||
</if>
|
||||
ORDER BY pos
|
||||
<if test="operator == 'lessThan' or operator == 'latest'">
|
||||
DESC
|
||||
</if>
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectBaseByRequest" resultType="io.metersphere.system.dto.sdk.BaseTreeNode">
|
||||
SELECT m.id,
|
||||
m.parent_id AS parentId,
|
||||
m.name,
|
||||
m.pos,
|
||||
m.project_id,
|
||||
'MODULE' AS type
|
||||
FROM api_scenario_module m
|
||||
<include refid="module_request"/>
|
||||
ORDER BY pos
|
||||
</select>
|
||||
<select id="selectNodeByIds" resultType="io.metersphere.system.dto.sdk.BaseTreeNode">
|
||||
SELECT m.id,
|
||||
m.parent_id AS parentId,
|
||||
m.name,
|
||||
m.pos,
|
||||
m.project_id,
|
||||
'MODULE' AS type
|
||||
FROM api_scenario_module m
|
||||
WHERE m.id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
ORDER BY pos
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectBaseByIds" resultType="io.metersphere.system.dto.sdk.BaseTreeNode">
|
||||
SELECT id, name, parent_id AS parentId, 'module' AS type
|
||||
FROM api_scenario_module
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
ORDER BY pos
|
||||
</select>
|
||||
|
||||
<sql id="queryWhereCondition">
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
and (
|
||||
api_scenario.num like concat('%', #{request.keyword},'%')
|
||||
or api_scenario.name like concat('%', #{request.keyword},'%')
|
||||
or api_scenario.tags like JSON_CONTAINS(tags, concat('["',#{request.keyword},'"]'))
|
||||
)
|
||||
</if>
|
||||
<if test="request.projectId != null and request.projectId != ''">
|
||||
and api_scenario.project_id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
and api_scenario.module_id in
|
||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||
#{nodeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="filters">
|
||||
<property name="filter" value="request.filter"/>
|
||||
</include>
|
||||
|
||||
<if test="request.combine != null and request.combine != ''">
|
||||
<include refid="combine">
|
||||
<property name="condition" value="request.combine"/>
|
||||
<property name="name" value="request.name"/>
|
||||
<property name="ObjectTags" value="request.combine.tags"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<include refid="queryVersionCondition">
|
||||
<property name="versionTable" value="api_scenario"/>
|
||||
</include>
|
||||
</sql>
|
||||
|
||||
<sql id="queryVersionCondition">
|
||||
<if test="request.versionId != null and request.versionId != ''">
|
||||
and ${versionTable}.version_id = #{request.versionId}
|
||||
</if>
|
||||
<if test="request.refId != null and request.refId != ''">
|
||||
and ${versionTable}.ref_id = #{request.refId}
|
||||
</if>
|
||||
<if test="request.versionId == null and request.refId == null">
|
||||
AND ${versionTable}.latest = 1
|
||||
</if>
|
||||
</sql>
|
||||
<sql id="combine">
|
||||
<if test='${condition}.name != null and (${name} == null or ${name} == "")'>
|
||||
and api_scenario.name
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.name"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test='${condition}.id != null'>
|
||||
and api_scenario.num
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.id"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test="${condition}.updateTime != null">
|
||||
and api_scenario.update_time
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.updateTime"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test="${condition}.createTime != null">
|
||||
and api_scenario.create_time
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.createTime"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test="${condition}.status != null">
|
||||
and api_scenario.status
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.status"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
<if test='${condition}.tags != null and ${ObjectTags}.operator == "not like"'>
|
||||
and (api_scenario.tags is null or api_scenario.tags
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.tags"/>
|
||||
</include>
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test='${condition}.tags != null and ${ObjectTags}.operator == "like"'>
|
||||
and api_scenario.tags
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="object" value="${condition}.tags"/>
|
||||
</include>
|
||||
</if>
|
||||
|
||||
|
||||
</sql>
|
||||
|
||||
<sql id="filters">
|
||||
<if test="${filter} != null and ${filter}.size() > 0">
|
||||
<foreach collection="${filter}.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key=='status'">
|
||||
and api_scenario.status in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='create_user'">
|
||||
and api_scenario.create_user in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='version_id'">
|
||||
and api_scenario.version_id in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='level'">
|
||||
and api_scenario.level in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='principal'">
|
||||
and api_scenario.principal in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='update_user'">
|
||||
and api_scenario.update_user in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
|
||||
<sql id="module_request">
|
||||
<where>
|
||||
<if test="request.projectId != null and request.projectId != ''">
|
||||
AND m.project_id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
AND m.name like CONCAT('%', #{request.keyword},'%')
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() != 0">
|
||||
AND m.id IN
|
||||
<foreach collection="request.moduleIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
|
@ -40,7 +40,9 @@ public interface ExtApiTestCaseMapper {
|
|||
|
||||
List<String> selectIdsByCaseIds(@Param("ids") List<String> ids);
|
||||
|
||||
List<String> getCaseIds(@Param("ids")List<String> ids, @Param("deleted")boolean deleted);
|
||||
List<String> getCaseIds(@Param("ids") List<String> ids, @Param("deleted") boolean deleted);
|
||||
|
||||
List<String> getIdsByApiIds(@Param("ids") List<String> ids);
|
||||
|
||||
List<ApiTestCaseProviderDTO> listByProviderRequest(@Param("table") String resourceType, @Param("sourceName") String sourceName, @Param("apiCaseColumnName") String apiCaseColumnName,@Param("request") ApiTestCasePageProviderRequest request, @Param("deleted") boolean deleted);
|
||||
|
||||
|
|
|
@ -141,6 +141,17 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getIdsByApiIds" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.id
|
||||
FROM
|
||||
api_test_case t1
|
||||
WHERE
|
||||
t1.api_definition_id IN
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="listByProviderRequest" resultType="io.metersphere.dto.ApiTestCaseProviderDTO">
|
||||
SELECT
|
||||
|
|
|
@ -1,19 +1,162 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
import io.metersphere.api.domain.*;
|
||||
import io.metersphere.api.mapper.*;
|
||||
import io.metersphere.sdk.constants.DefaultRepositoryDir;
|
||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.metersphere.sdk.util.SubListUtils;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.service.CleanupProjectResourceService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class CleanupApiResourceService implements CleanupProjectResourceService {
|
||||
|
||||
|
||||
@Resource
|
||||
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
||||
@Resource
|
||||
private ExtApiDefinitionMapper extApiDefinitionMapper;
|
||||
@Resource
|
||||
private ApiScenarioModuleMapper apiScenarioModuleMapper;
|
||||
@Resource
|
||||
private ExtApiTestCaseMapper extApiTestCaseMapper;
|
||||
@Resource
|
||||
private ApiTestCaseFollowerMapper apiTestCaseFollowerMapper;
|
||||
@Resource
|
||||
private ApiDefinitionFollowerMapper apiDefinitionFollowerMapper;
|
||||
@Resource
|
||||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Resource
|
||||
private ApiTestCaseBlobMapper apiTestCaseBlobMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
@Resource
|
||||
private ApiFileResourceService apiFileResourceService;
|
||||
@Resource
|
||||
private ExtApiDefinitionMockMapper extApiDefinitionMockMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMockConfigMapper apiDefinitionMockConfigMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMockMapper apiDefinitionMockMapper;
|
||||
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void deleteResources(String projectId) {
|
||||
LogUtils.info("删除当前项目[" + projectId + "]相关接口测试资源");
|
||||
//删除模块
|
||||
delApiModule(projectId);
|
||||
delScenarioModule(projectId);
|
||||
//删除接口
|
||||
delApi(projectId);
|
||||
//删除场景
|
||||
|
||||
//删除执行记录
|
||||
//删除报告
|
||||
//删除定时任务
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanReportResources(String projectId) {
|
||||
LogUtils.info("清理当前项目[" + projectId + "]相关接口测试报告资源");
|
||||
}
|
||||
|
||||
private void delScenarioModule(String projectId) {
|
||||
ApiScenarioModuleExample apiScenarioModuleExample = new ApiScenarioModuleExample();
|
||||
apiScenarioModuleExample.createCriteria().andProjectIdEqualTo(projectId);
|
||||
apiScenarioModuleMapper.deleteByExample(apiScenarioModuleExample);
|
||||
}
|
||||
|
||||
private void delApiModule(String projectId) {
|
||||
ApiDefinitionModuleExample apiModuleExample = new ApiDefinitionModuleExample();
|
||||
apiModuleExample.createCriteria().andProjectIdEqualTo(projectId);
|
||||
apiDefinitionModuleMapper.deleteByExample(apiModuleExample);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口
|
||||
* 有可能及联数据没有删干净 需要补充
|
||||
*
|
||||
* @param projectId
|
||||
*/
|
||||
private void delApi(String projectId) {
|
||||
List<String> apiIds = extApiDefinitionMapper.selectByProjectId(projectId);
|
||||
if (CollectionUtils.isNotEmpty(apiIds)) {
|
||||
SubListUtils.dealForSubList(apiIds, 500, subList -> {
|
||||
List<String> caseIds = extApiTestCaseMapper.getIdsByApiIds(subList);
|
||||
if (CollectionUtils.isNotEmpty(caseIds)) {
|
||||
deleteCase(caseIds, projectId);
|
||||
}
|
||||
List<String> mockIds = extApiDefinitionMockMapper.getIdsByApiIds(subList);
|
||||
if (CollectionUtils.isNotEmpty(mockIds)) {
|
||||
deleteMock(mockIds, projectId);
|
||||
}
|
||||
deleteApi(subList, projectId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteApiFollows(List<String> ids) {
|
||||
ApiDefinitionFollowerExample apiExample = new ApiDefinitionFollowerExample();
|
||||
apiExample.createCriteria().andApiDefinitionIdIn(ids);
|
||||
apiDefinitionFollowerMapper.deleteByExample(apiExample);
|
||||
}
|
||||
|
||||
private void deleteCaseFollows(List<String> ids) {
|
||||
ApiTestCaseFollowerExample example = new ApiTestCaseFollowerExample();
|
||||
example.createCriteria().andCaseIdIn(ids);
|
||||
apiTestCaseFollowerMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
private void deleteCase(List<String> ids, String projectId) {
|
||||
deleteCaseFollows(ids);
|
||||
ids.forEach(id -> {
|
||||
String apiCaseDir = DefaultRepositoryDir.getApiCaseDir(projectId, id);
|
||||
apiFileResourceService.deleteByResourceId(apiCaseDir, id, projectId, OperationLogConstants.SYSTEM, OperationLogModule.API_DEFINITION_CASE);
|
||||
});
|
||||
ApiTestCaseExample example = new ApiTestCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
apiTestCaseMapper.deleteByExample(example);
|
||||
ApiTestCaseBlobExample blobExample = new ApiTestCaseBlobExample();
|
||||
blobExample.createCriteria().andIdIn(ids);
|
||||
apiTestCaseBlobMapper.deleteByExample(blobExample);
|
||||
}
|
||||
|
||||
private void deleteMock(List<String> ids, String projectId) {
|
||||
ids.forEach(id -> {
|
||||
String apiCaseDir = DefaultRepositoryDir.getApiDefinitionDir(projectId, id);
|
||||
apiFileResourceService.deleteByResourceId(apiCaseDir, id, projectId, OperationLogConstants.SYSTEM, OperationLogModule.API_DEFINITION_CASE);
|
||||
});
|
||||
ApiDefinitionMockConfigExample configExample = new ApiDefinitionMockConfigExample();
|
||||
configExample.createCriteria().andIdIn(ids);
|
||||
apiDefinitionMockConfigMapper.deleteByExample(configExample);
|
||||
ApiDefinitionMockExample mockExample = new ApiDefinitionMockExample();
|
||||
mockExample.createCriteria().andIdIn(ids);
|
||||
apiDefinitionMockMapper.deleteByExample(mockExample);
|
||||
}
|
||||
|
||||
private void deleteApi(List<String> ids, String projectId) {
|
||||
deleteApiFollows(ids);
|
||||
ids.forEach(id -> {
|
||||
String apiDefinitionDir = DefaultRepositoryDir.getApiDefinitionDir(projectId, id);
|
||||
apiFileResourceService.deleteByResourceId(apiDefinitionDir, id, projectId, OperationLogConstants.SYSTEM, OperationLogModule.API_DEFINITION);
|
||||
});
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
apiDefinitionMapper.deleteByExample(example);
|
||||
ApiTestCaseBlobExample blobExample = new ApiTestCaseBlobExample();
|
||||
blobExample.createCriteria().andIdIn(ids);
|
||||
apiTestCaseBlobMapper.deleteByExample(blobExample);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -174,10 +174,7 @@ public class ApiDebugModuleService extends ModuleTreeService {
|
|||
}
|
||||
|
||||
public void update(ModuleUpdateRequest request, String userId, String projectId) {
|
||||
ApiDebugModule module = apiDebugModuleMapper.selectByPrimaryKey(request.getId());
|
||||
if (module == null) {
|
||||
throw new MSException(Translator.get(MODULE_NO_EXIST));
|
||||
}
|
||||
ApiDebugModule module = checkModuleExist(request.getId());
|
||||
ApiDebugModule updateModule = new ApiDebugModule();
|
||||
updateModule.setId(request.getId());
|
||||
updateModule.setName(request.getName());
|
||||
|
@ -192,9 +189,17 @@ public class ApiDebugModuleService extends ModuleTreeService {
|
|||
apiDebugModuleLogService.saveUpdateLog(updateModule, projectId, userId);
|
||||
}
|
||||
|
||||
public ApiDebugModule checkModuleExist(String moduleId) {
|
||||
ApiDebugModule module = apiDebugModuleMapper.selectByPrimaryKey(moduleId);
|
||||
if (module == null) {
|
||||
throw new MSException(Translator.get(MODULE_NO_EXIST));
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
||||
|
||||
public void deleteModule(String deleteId, String currentUser) {
|
||||
ApiDebugModule deleteModule = apiDebugModuleMapper.selectByPrimaryKey(deleteId);
|
||||
ApiDebugModule deleteModule = checkModuleExist(deleteId);
|
||||
if (deleteModule != null) {
|
||||
this.deleteModule(Collections.singletonList(deleteId), currentUser, deleteModule.getProjectId());
|
||||
}
|
||||
|
|
|
@ -136,10 +136,7 @@ public class ApiDefinitionModuleService extends ModuleTreeService {
|
|||
}
|
||||
|
||||
public void update(ModuleUpdateRequest request, String userId) {
|
||||
ApiDefinitionModule module = apiDefinitionModuleMapper.selectByPrimaryKey(request.getId());
|
||||
if (module == null) {
|
||||
throw new MSException(Translator.get(MODULE_NO_EXIST));
|
||||
}
|
||||
ApiDefinitionModule module = checkModuleExist(request.getId());
|
||||
ApiDefinitionModule updateModule = new ApiDefinitionModule();
|
||||
updateModule.setId(request.getId());
|
||||
updateModule.setName(request.getName());
|
||||
|
@ -153,12 +150,18 @@ public class ApiDefinitionModuleService extends ModuleTreeService {
|
|||
apiDefinitionModuleLogService.saveUpdateLog(updateModule, userId);
|
||||
}
|
||||
|
||||
private ApiDefinitionModule checkModuleExist(String moduleId) {
|
||||
ApiDefinitionModule module = apiDefinitionModuleMapper.selectByPrimaryKey(moduleId);
|
||||
if (module == null) {
|
||||
throw new MSException(Translator.get(MODULE_NO_EXIST));
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
||||
|
||||
public void deleteModule(String deleteId, String currentUser) {
|
||||
ApiDefinitionModule deleteModule = apiDefinitionModuleMapper.selectByPrimaryKey(deleteId);
|
||||
if (deleteModule != null) {
|
||||
deleteModule(List.of(deleteId), currentUser, deleteModule.getProjectId());
|
||||
}
|
||||
ApiDefinitionModule deleteModule = checkModuleExist(deleteId);
|
||||
deleteModule(List.of(deleteId), currentUser, deleteModule.getProjectId());
|
||||
}
|
||||
|
||||
public void deleteModule(List<String> deleteIds, String currentUser, String projectId) {
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
package io.metersphere.api.service.scenario;
|
||||
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.domain.ApiScenarioModule;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.dto.NodeSortDTO;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.dto.builder.LogDTOBuilder;
|
||||
import io.metersphere.system.dto.sdk.BaseModule;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ApiScenarioModuleLogService {
|
||||
private static final String API_DEBUG_MODULE = "/api/scenario/module";
|
||||
private static final String ADD = API_DEBUG_MODULE + "/add";
|
||||
private static final String UPDATE = API_DEBUG_MODULE + "/update";
|
||||
private static final String DELETE = API_DEBUG_MODULE + "/delete";
|
||||
private static final String MOVE = API_DEBUG_MODULE + "/move";
|
||||
private static final String MOVE_TO = "file.log.move_to";
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
public void saveAddLog(ApiScenarioModule module, String operator) {
|
||||
Project project = projectMapper.selectByPrimaryKey(module.getProjectId());
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(module.getProjectId())
|
||||
.organizationId(project.getOrganizationId())
|
||||
.type(OperationLogType.ADD.name())
|
||||
.module(OperationLogModule.API_DEFINITION)
|
||||
.method(HttpMethodConstants.POST.name())
|
||||
.path(ADD)
|
||||
.sourceId(module.getId())
|
||||
.content(module.getName())
|
||||
.originalValue(JSON.toJSONBytes(module))
|
||||
.createUser(operator)
|
||||
.build().getLogDTO();
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
|
||||
public void saveUpdateLog(ApiScenarioModule module, String operator) {
|
||||
Project project = projectMapper.selectByPrimaryKey(module.getProjectId());
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(project.getId())
|
||||
.organizationId(project.getOrganizationId())
|
||||
.type(OperationLogType.UPDATE.name())
|
||||
.module(OperationLogModule.API_DEFINITION)
|
||||
.method(HttpMethodConstants.POST.name())
|
||||
.path(UPDATE)
|
||||
.sourceId(module.getId())
|
||||
.content(module.getName())
|
||||
.originalValue(JSON.toJSONBytes(module))
|
||||
.createUser(operator)
|
||||
.build().getLogDTO();
|
||||
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
|
||||
public void saveDeleteModuleLog(List<BaseTreeNode> deleteModule, String operator, String projectId) {
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
deleteModule.forEach(item -> {
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(project.getId())
|
||||
.organizationId(project.getOrganizationId())
|
||||
.type(OperationLogType.DELETE.name())
|
||||
.module(OperationLogModule.API_DEFINITION)
|
||||
.method(HttpMethodConstants.GET.name())
|
||||
.path(DELETE + "/%s")
|
||||
.sourceId(item.getId())
|
||||
.content(item.getName() + " " + Translator.get("file.log.delete_module"))
|
||||
.createUser(operator)
|
||||
.build().getLogDTO();
|
||||
dtoList.add(dto);
|
||||
});
|
||||
operationLogService.batchAdd(dtoList);
|
||||
}
|
||||
|
||||
public void saveDeleteDataLog(List<ApiScenario> deleteData, String operator, String projectId) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
List<LogDTO> logs = new ArrayList<>();
|
||||
deleteData.forEach(item -> {
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(project.getId())
|
||||
.organizationId(project.getOrganizationId())
|
||||
.type(OperationLogType.DELETE.name())
|
||||
.module(OperationLogModule.API_DEFINITION)
|
||||
.method(HttpMethodConstants.GET.name())
|
||||
.path(DELETE + "/%s")
|
||||
.sourceId(item.getId())
|
||||
.content(item.getName())
|
||||
.createUser(operator)
|
||||
.build().getLogDTO();
|
||||
logs.add(dto);
|
||||
}
|
||||
);
|
||||
operationLogService.batchAdd(logs);
|
||||
}
|
||||
|
||||
public void saveMoveLog(@Validated NodeSortDTO request, String operator) {
|
||||
BaseModule moveNode = request.getNode();
|
||||
BaseModule previousNode = request.getPreviousNode();
|
||||
BaseModule nextNode = request.getNextNode();
|
||||
BaseModule parentModule = request.getParent();
|
||||
|
||||
Project project = projectMapper.selectByPrimaryKey(moveNode.getProjectId());
|
||||
String logContent;
|
||||
if (nextNode == null && previousNode == null) {
|
||||
logContent = moveNode.getName() + " " + Translator.get(MOVE_TO) + parentModule.getName();
|
||||
} else if (nextNode == null) {
|
||||
logContent = moveNode.getName() + " " + Translator.get(MOVE_TO) + parentModule.getName() + " " + previousNode.getName() + Translator.get("file.log.next");
|
||||
} else if (previousNode == null) {
|
||||
logContent = moveNode.getName() + " " + Translator.get(MOVE_TO) + parentModule.getName() + " " + nextNode.getName() + Translator.get("file.log.previous");
|
||||
} else {
|
||||
logContent = moveNode.getName() + " " + Translator.get(MOVE_TO) + parentModule.getName() + " " +
|
||||
previousNode.getName() + Translator.get("file.log.next") + " " + nextNode.getName() + Translator.get("file.log.previous");
|
||||
}
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(moveNode.getProjectId())
|
||||
.organizationId(project.getOrganizationId())
|
||||
.type(OperationLogType.UPDATE.name())
|
||||
.module(OperationLogModule.API_DEFINITION)
|
||||
.method(HttpMethodConstants.POST.name())
|
||||
.path(MOVE)
|
||||
.sourceId(moveNode.getId())
|
||||
.content(logContent)
|
||||
.originalValue(JSON.toJSONBytes(moveNode))
|
||||
.createUser(operator)
|
||||
.build().getLogDTO();
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,271 @@
|
|||
package io.metersphere.api.service.scenario;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.domain.ApiScenarioExample;
|
||||
import io.metersphere.api.domain.ApiScenarioModule;
|
||||
import io.metersphere.api.domain.ApiScenarioModuleExample;
|
||||
import io.metersphere.api.dto.debug.ModuleCreateRequest;
|
||||
import io.metersphere.api.dto.debug.ModuleUpdateRequest;
|
||||
import io.metersphere.api.dto.definition.ApiModuleRequest;
|
||||
import io.metersphere.api.dto.definition.ApiScenarioModuleRequest;
|
||||
import io.metersphere.api.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.api.mapper.ApiScenarioModuleMapper;
|
||||
import io.metersphere.api.mapper.ExtApiScenarioModuleMapper;
|
||||
import io.metersphere.project.dto.ModuleCountDTO;
|
||||
import io.metersphere.project.dto.NodeSortDTO;
|
||||
import io.metersphere.project.service.ModuleTreeService;
|
||||
import io.metersphere.sdk.constants.ModuleConstants;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.dto.sdk.request.NodeMoveRequest;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ApiScenarioModuleService extends ModuleTreeService {
|
||||
private static final String UNPLANNED_SCENARIO = "api_unplanned_scenario";
|
||||
private static final String MODULE_NO_EXIST = "api_module.not.exist";
|
||||
private static final String DEBUG_MODULE_COUNT_ALL = "all";
|
||||
@Resource
|
||||
private ApiScenarioModuleLogService apiScenarioModuleLogService;
|
||||
@Resource
|
||||
private ApiScenarioModuleMapper apiScenarioModuleMapper;
|
||||
@Resource
|
||||
private ExtApiScenarioModuleMapper extApiScenarioModuleMapper;
|
||||
@Resource
|
||||
private SqlSessionFactory sqlSessionFactory;
|
||||
@Resource
|
||||
private ApiScenarioMapper apiScenarioMapper;
|
||||
|
||||
public List<BaseTreeNode> getTree(ApiScenarioModuleRequest request) {
|
||||
//接口的树结构是 模块:子模块+接口 接口为非delete状态的
|
||||
List<BaseTreeNode> fileModuleList = extApiScenarioModuleMapper.selectBaseByRequest(request);
|
||||
return super.buildTreeAndCountResource(fileModuleList, true, Translator.get(UNPLANNED_SCENARIO));
|
||||
}
|
||||
|
||||
public List<BaseTreeNode> getTreeOnlyIdsAndResourceCount(ApiScenarioModuleRequest request, List<ModuleCountDTO> moduleCountDTOList) {
|
||||
//节点内容只有Id和parentId
|
||||
List<BaseTreeNode> fileModuleList = extApiScenarioModuleMapper.selectIdAndParentIdByRequest(request);
|
||||
return super.buildTreeAndCountResource(fileModuleList, moduleCountDTOList, true, Translator.get(UNPLANNED_SCENARIO));
|
||||
}
|
||||
|
||||
public String add(ModuleCreateRequest request, String operator) {
|
||||
ApiScenarioModule module = new ApiScenarioModule();
|
||||
module.setId(IDGenerator.nextStr());
|
||||
module.setName(request.getName());
|
||||
module.setParentId(request.getParentId());
|
||||
module.setProjectId(request.getProjectId());
|
||||
module.setCreateUser(operator);
|
||||
this.checkDataValidity(module);
|
||||
module.setCreateTime(System.currentTimeMillis());
|
||||
module.setUpdateTime(module.getCreateTime());
|
||||
module.setPos(this.getNextOrder(request.getParentId()));
|
||||
module.setUpdateUser(operator);
|
||||
apiScenarioModuleMapper.insertSelective(module);
|
||||
//记录日志
|
||||
apiScenarioModuleLogService.saveAddLog(module, operator);
|
||||
return module.getId();
|
||||
}
|
||||
|
||||
public Long getNextOrder(String parentId) {
|
||||
Long maxPos = extApiScenarioModuleMapper.getMaxPosByParentId(parentId);
|
||||
if (maxPos == null) {
|
||||
return LIMIT_POS;
|
||||
} else {
|
||||
return maxPos + LIMIT_POS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查数据的合法性
|
||||
*/
|
||||
private void checkDataValidity(ApiScenarioModule module) {
|
||||
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
|
||||
if (!StringUtils.equals(module.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
|
||||
example.createCriteria().andIdEqualTo(module.getParentId())
|
||||
.andProjectIdEqualTo(module.getProjectId());
|
||||
if (apiScenarioModuleMapper.countByExample(example) == 0) {
|
||||
throw new MSException(Translator.get("parent.node.not_blank"));
|
||||
}
|
||||
example.clear();
|
||||
}
|
||||
example.createCriteria().andParentIdEqualTo(module.getParentId())
|
||||
.andNameEqualTo(module.getName()).andIdNotEqualTo(module.getId())
|
||||
.andProjectIdEqualTo(module.getProjectId());
|
||||
if (apiScenarioModuleMapper.countByExample(example) > 0) {
|
||||
throw new MSException(Translator.get("node.name.repeat"));
|
||||
}
|
||||
example.clear();
|
||||
|
||||
//非默认节点,检查该节点所在分支的总长度,确保不超过阈值
|
||||
if (!StringUtils.equals(module.getId(), ModuleConstants.DEFAULT_NODE_ID)) {
|
||||
this.checkBranchModules(this.getRootNodeId(module), extApiScenarioModuleMapper::selectChildrenIdsByParentIds);
|
||||
}
|
||||
}
|
||||
|
||||
private String getRootNodeId(ApiScenarioModule module) {
|
||||
if (StringUtils.equals(module.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
|
||||
return module.getId();
|
||||
} else {
|
||||
ApiScenarioModule parentModule = apiScenarioModuleMapper.selectByPrimaryKey(module.getParentId());
|
||||
return this.getRootNodeId(parentModule);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(ModuleUpdateRequest request, String userId) {
|
||||
ApiScenarioModule module = checkResourceExist(request.getId());
|
||||
ApiScenarioModule updateModule = new ApiScenarioModule();
|
||||
updateModule.setId(request.getId());
|
||||
updateModule.setName(request.getName());
|
||||
updateModule.setParentId(module.getParentId());
|
||||
updateModule.setProjectId(module.getProjectId());
|
||||
this.checkDataValidity(updateModule);
|
||||
updateModule.setUpdateTime(System.currentTimeMillis());
|
||||
updateModule.setUpdateUser(userId);
|
||||
apiScenarioModuleMapper.updateByPrimaryKeySelective(updateModule);
|
||||
//记录日志
|
||||
apiScenarioModuleLogService.saveUpdateLog(updateModule, userId);
|
||||
}
|
||||
|
||||
|
||||
public void deleteModule(String deleteId, String currentUser) {
|
||||
ApiScenarioModule deleteModule = checkResourceExist(deleteId);
|
||||
if (deleteModule != null) {
|
||||
deleteModule(List.of(deleteId), currentUser, deleteModule.getProjectId());
|
||||
}
|
||||
}
|
||||
|
||||
public ApiScenarioModule checkResourceExist(String id) {
|
||||
ApiScenarioModule module = apiScenarioModuleMapper.selectByPrimaryKey(id);
|
||||
if (module == null) {
|
||||
throw new MSException(Translator.get(MODULE_NO_EXIST));
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
||||
public void deleteModule(List<String> deleteIds, String currentUser, String projectId) {
|
||||
if (CollectionUtils.isEmpty(deleteIds)) {
|
||||
return;
|
||||
}
|
||||
List<BaseTreeNode> baseTreeNodes = extApiScenarioModuleMapper.selectNodeByIds(deleteIds);
|
||||
extApiScenarioModuleMapper.deleteByIds(deleteIds);
|
||||
//记录日志
|
||||
apiScenarioModuleLogService.saveDeleteModuleLog(baseTreeNodes, currentUser, projectId);
|
||||
batchDeleteData(deleteIds, currentUser, projectId);
|
||||
|
||||
List<String> childrenIds = extApiScenarioModuleMapper.selectChildrenIdsByParentIds(deleteIds);
|
||||
if (CollectionUtils.isNotEmpty(childrenIds)) {
|
||||
deleteModule(childrenIds, currentUser, projectId);
|
||||
}
|
||||
}
|
||||
|
||||
public void batchDeleteData(List<String> ids, String userId, String projectId) {
|
||||
ApiScenarioExample example = new ApiScenarioExample();
|
||||
example.createCriteria().andModuleIdIn(ids).andDeletedEqualTo(false);
|
||||
long apiCount = apiScenarioMapper.countByExample(example);
|
||||
while (apiCount > 0) {
|
||||
PageHelper.startPage(1, 500);
|
||||
List<ApiScenario> apiScenarios = apiScenarioMapper.selectByExample(example);
|
||||
//提取id为新的集合
|
||||
List<String> refIds = apiScenarios.stream().map(ApiScenario::getRefId).distinct().toList();
|
||||
//删除场景
|
||||
extApiScenarioModuleMapper.deleteScenarioToGc(refIds, userId, System.currentTimeMillis());
|
||||
apiScenarioModuleLogService.saveDeleteDataLog(apiScenarios, userId, projectId);
|
||||
apiCount = apiScenarioMapper.countByExample(example);
|
||||
}
|
||||
}
|
||||
|
||||
public void moveNode(NodeMoveRequest request, String currentUser) {
|
||||
NodeSortDTO nodeSortDTO = super.getNodeSortDTO(request,
|
||||
extApiScenarioModuleMapper::selectBaseModuleById,
|
||||
extApiScenarioModuleMapper::selectModuleByParentIdAndPosOperator);
|
||||
|
||||
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
|
||||
example.createCriteria().andParentIdEqualTo(nodeSortDTO.getParent().getId()).andIdEqualTo(request.getDragNodeId());
|
||||
//节点换到了别的节点下,要先更新parent节点.
|
||||
if (apiScenarioModuleMapper.countByExample(example) == 0) {
|
||||
ApiScenarioModule definitionModule = new ApiScenarioModule();
|
||||
ApiScenarioModule currentModule = apiScenarioModuleMapper.selectByPrimaryKey(request.getDragNodeId());
|
||||
currentModule.setParentId(nodeSortDTO.getParent().getId());
|
||||
checkDataValidity(currentModule);
|
||||
definitionModule.setId(request.getDragNodeId());
|
||||
definitionModule.setParentId(nodeSortDTO.getParent().getId());
|
||||
apiScenarioModuleMapper.updateByPrimaryKeySelective(definitionModule);
|
||||
}
|
||||
|
||||
super.sort(nodeSortDTO);
|
||||
//记录日志
|
||||
apiScenarioModuleLogService.saveMoveLog(nodeSortDTO, currentUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找当前项目下模块每个节点对应的资源统计
|
||||
*/
|
||||
public Map<String, Long> getModuleCountMap(ApiScenarioModuleRequest request, List<ModuleCountDTO> moduleCountDTOList) {
|
||||
//构建模块树,并计算每个节点下的所有数量(包含子节点)
|
||||
List<BaseTreeNode> treeNodeList = this.getTreeOnlyIdsAndResourceCount(request, moduleCountDTOList);
|
||||
return super.getIdCountMapByBreadth(treeNodeList);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updatePos(String id, long pos) {
|
||||
ApiScenarioModule updateModule = new ApiScenarioModule();
|
||||
updateModule.setPos(pos);
|
||||
updateModule.setId(id);
|
||||
apiScenarioModuleMapper.updateByPrimaryKeySelective(updateModule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshPos(String parentId) {
|
||||
List<String> childrenIdSortByPos = extApiScenarioModuleMapper.selectChildrenIdsSortByPos(parentId);
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiScenarioModuleMapper batchUpdateMapper = sqlSession.getMapper(ApiScenarioModuleMapper.class);
|
||||
for (int i = 0; i < childrenIdSortByPos.size(); i++) {
|
||||
String nodeId = childrenIdSortByPos.get(i);
|
||||
ApiScenarioModule updateModule = new ApiScenarioModule();
|
||||
updateModule.setId(nodeId);
|
||||
updateModule.setPos((i + 1) * LIMIT_POS);
|
||||
batchUpdateMapper.updateByPrimaryKeySelective(updateModule);
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||
}
|
||||
|
||||
public Map<String, Long> moduleCount(ApiScenarioModuleRequest request, boolean deleted) {
|
||||
request.setModuleIds(null);
|
||||
//查找根据moduleIds查找模块下的接口数量 查非delete状态的
|
||||
List<ModuleCountDTO> moduleCountDTOList = extApiScenarioModuleMapper.countModuleIdByRequest(request, deleted);
|
||||
long allCount = getAllCount(moduleCountDTOList);
|
||||
Map<String, Long> moduleCountMap = getModuleCountMap(request, moduleCountDTOList);
|
||||
moduleCountMap.put(DEBUG_MODULE_COUNT_ALL, allCount);
|
||||
return moduleCountMap;
|
||||
}
|
||||
|
||||
public List<BaseTreeNode> getTrashTree(ApiModuleRequest request) {
|
||||
ApiScenarioExample example = new ApiScenarioExample();
|
||||
example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andDeletedEqualTo(true);
|
||||
List<ApiScenario> apiScenarios = apiScenarioMapper.selectByExample(example);
|
||||
if (CollectionUtils.isEmpty(apiScenarios)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> moduleIds = apiScenarios.stream().map(ApiScenario::getModuleId).distinct().toList();
|
||||
List<BaseTreeNode> baseTreeNodes = extApiScenarioModuleMapper.selectBaseByIds(moduleIds);
|
||||
return super.buildTreeAndCountResource(baseTreeNodes, true, Translator.get(UNPLANNED_SCENARIO));
|
||||
}
|
||||
}
|
|
@ -52,6 +52,9 @@
|
|||
},
|
||||
{
|
||||
"id": "PROJECT_API_DEFINITION:READ+EXPORT"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_DEFINITION:READ+DEBUG"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -96,6 +99,36 @@
|
|||
"id": "PROJECT_API_DEFINITION_MOCK:READ+EXECUTE"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_SCENARIO",
|
||||
"name": "message.api_scenario_task",
|
||||
"permissions": [
|
||||
{
|
||||
"id": "PROJECT_API_SCENARIO:READ"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_SCENARIO:READ+ADD"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_SCENARIO:READ+UPDATE"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_SCENARIO:READ+DELETE"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_SCENARIO:READ+EXECUTE"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_SCENARIO:READ+IMPORT"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_SCENARIO:READ+EXPORT"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_SCENARIO:READ+DEBUG"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ public class ApiDebugModuleControllerTests extends BaseTest {
|
|||
apiDebugBlob.setResponse(new byte[0]);
|
||||
apiDebugBlobMapper.insertSelective(apiDebugBlob);
|
||||
}
|
||||
|
||||
public void initApiDebugTCPData(String moduleId) {
|
||||
ApiDebug apiDebug = new ApiDebug();
|
||||
apiDebug.setId(IDGenerator.nextStr());
|
||||
|
@ -790,9 +791,9 @@ public class ApiDebugModuleControllerTests extends BaseTest {
|
|||
checkLog(a1a1Node.getId(), OperationLogType.DELETE, URL_MODULE_DELETE);
|
||||
|
||||
//删除不存在的节点
|
||||
this.requestGetWithOk(String.format(URL_MODULE_DELETE, IDGenerator.nextNum()));
|
||||
this.requestGet(String.format(URL_MODULE_DELETE, IDGenerator.nextNum())).andExpect(ERROR_REQUEST_MATCHER);
|
||||
// 测试删除根节点
|
||||
this.requestGetWithOk(String.format(URL_MODULE_DELETE, ModuleConstants.DEFAULT_NODE_ID));
|
||||
this.requestGet(String.format(URL_MODULE_DELETE, ModuleConstants.DEFAULT_NODE_ID)).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//service层判断:测试删除空集合
|
||||
apiDebugModuleService.deleteModule(new ArrayList<>(), "admin", DEFAULT_PROJECT_ID);
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.metersphere.api.dto.debug.ApiDebugRequest;
|
|||
import io.metersphere.api.dto.debug.ModuleCreateRequest;
|
||||
import io.metersphere.api.dto.debug.ModuleUpdateRequest;
|
||||
import io.metersphere.api.dto.definition.ApiModuleRequest;
|
||||
import io.metersphere.api.dto.request.http.MsHTTPElement;
|
||||
import io.metersphere.api.mapper.*;
|
||||
import io.metersphere.api.service.definition.ApiDefinitionModuleService;
|
||||
import io.metersphere.project.domain.Project;
|
||||
|
@ -12,7 +13,6 @@ import io.metersphere.project.mapper.ProjectMapper;
|
|||
import io.metersphere.sdk.constants.ApplicationNumScope;
|
||||
import io.metersphere.sdk.constants.ModuleConstants;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.api.dto.request.http.MsHTTPElement;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
|
@ -829,9 +829,9 @@ public class ApiDefinitionModuleControllerTests extends BaseTest {
|
|||
checkLog(a1a1Node.getId(), OperationLogType.DELETE, URL_MODULE_DELETE);
|
||||
|
||||
//删除不存在的节点
|
||||
this.requestGetWithOk(String.format(URL_MODULE_DELETE, IDGenerator.nextNum()));
|
||||
this.requestGet(String.format(URL_MODULE_DELETE, IDGenerator.nextNum())).andExpect(ERROR_REQUEST_MATCHER);
|
||||
// 测试删除根节点
|
||||
this.requestGetWithOk(String.format(URL_MODULE_DELETE, ModuleConstants.DEFAULT_NODE_ID));
|
||||
this.requestGet(String.format(URL_MODULE_DELETE, ModuleConstants.DEFAULT_NODE_ID)).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//service层判断:测试删除空集合
|
||||
apiDefinitionModuleService.deleteModule(new ArrayList<>(), "admin", DEFAULT_PROJECT_ID);
|
||||
|
|
|
@ -0,0 +1,887 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.domain.ApiScenarioExample;
|
||||
import io.metersphere.api.domain.ApiScenarioModule;
|
||||
import io.metersphere.api.domain.ApiScenarioModuleExample;
|
||||
import io.metersphere.api.dto.debug.ModuleCreateRequest;
|
||||
import io.metersphere.api.dto.debug.ModuleUpdateRequest;
|
||||
import io.metersphere.api.dto.definition.ApiScenarioModuleRequest;
|
||||
import io.metersphere.api.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.api.mapper.ApiScenarioModuleMapper;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioModuleService;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.ApplicationNumScope;
|
||||
import io.metersphere.sdk.constants.ModuleConstants;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.dto.sdk.request.NodeMoveRequest;
|
||||
import io.metersphere.system.invoker.ProjectServiceInvoker;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import io.metersphere.system.uid.NumGenerator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.ResultMatcher;
|
||||
import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@AutoConfigureMockMvc
|
||||
public class ApiScenarioModuleControllerTests extends BaseTest {
|
||||
|
||||
private static final String URL_MODULE_ADD = "/api/scenario/module/add";
|
||||
private static final String URL_MODULE_UPDATE = "/api/scenario/module/update";
|
||||
private static final String URL_MODULE_DELETE = "/api/scenario/module/delete/%s";
|
||||
private static final String URL_MODULE_TREE = "/api/scenario/module/tree";
|
||||
private static final String URL_MODULE_MOVE = "/api/scenario/module/move";
|
||||
private static final String URL_FILE_MODULE_COUNT = "/api/scenario/module/count";
|
||||
private static final String URL_MODULE_TRASH_TREE = "/api/scenario/module/trash/tree";
|
||||
private static final String URL_MODULE_TRASH_COUNT = "/api/scenario/module/trash/count";
|
||||
private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest();
|
||||
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
||||
private static Project project;
|
||||
private static List<BaseTreeNode> preliminaryTreeNodes = new ArrayList<>();
|
||||
private final ProjectServiceInvoker serviceInvoker;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private ApiScenarioModuleMapper apiScenarioModuleMapper;
|
||||
@Resource
|
||||
private ApiScenarioMapper apiScenarioMapper;
|
||||
@Resource
|
||||
private ApiScenarioModuleService apiScenarioModuleService;
|
||||
|
||||
@Autowired
|
||||
public ApiScenarioModuleControllerTests(ProjectServiceInvoker serviceInvoker) {
|
||||
this.serviceInvoker = serviceInvoker;
|
||||
}
|
||||
|
||||
public static BaseTreeNode getNodeByName(List<BaseTreeNode> preliminaryTreeNodes, String nodeName) {
|
||||
for (BaseTreeNode firstLevelNode : preliminaryTreeNodes) {
|
||||
if (StringUtils.equals(firstLevelNode.getName(), nodeName) && StringUtils.equals(firstLevelNode.getType(), ModuleConstants.NODE_TYPE_DEFAULT)) {
|
||||
return firstLevelNode;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(firstLevelNode.getChildren())) {
|
||||
for (BaseTreeNode secondLevelNode : firstLevelNode.getChildren()) {
|
||||
if (StringUtils.equals(secondLevelNode.getName(), nodeName) && StringUtils.equals(secondLevelNode.getType(), ModuleConstants.NODE_TYPE_DEFAULT)) {
|
||||
return secondLevelNode;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(secondLevelNode.getChildren())) {
|
||||
for (BaseTreeNode thirdLevelNode : secondLevelNode.getChildren()) {
|
||||
if (StringUtils.equals(thirdLevelNode.getName(), nodeName) && StringUtils.equals(thirdLevelNode.getType(), ModuleConstants.NODE_TYPE_DEFAULT)) {
|
||||
return thirdLevelNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void initTestData() {
|
||||
if (project == null) {
|
||||
Project initProject = new Project();
|
||||
initProject.setId(IDGenerator.nextStr());
|
||||
initProject.setNum(null);
|
||||
initProject.setOrganizationId(DEFAULT_ORGANIZATION_ID);
|
||||
initProject.setName("场景模块项目");
|
||||
initProject.setDescription("场景模块项目");
|
||||
initProject.setCreateUser("admin");
|
||||
initProject.setUpdateUser("admin");
|
||||
initProject.setCreateTime(System.currentTimeMillis());
|
||||
initProject.setUpdateTime(System.currentTimeMillis());
|
||||
initProject.setEnable(true);
|
||||
initProject.setModuleSetting("[\"apiTest\",\"uiTest\"]");
|
||||
projectMapper.insertSelective(initProject);
|
||||
serviceInvoker.invokeCreateServices(initProject.getId());
|
||||
project = projectMapper.selectByPrimaryKey(initProject.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void initScenarioData(String moduleId) {
|
||||
ApiScenario scenario = new ApiScenario();
|
||||
scenario.setId(IDGenerator.nextStr());
|
||||
scenario.setProjectId(project.getId());
|
||||
scenario.setName(StringUtils.join("接口场景", scenario.getId()));
|
||||
scenario.setModuleId(moduleId);
|
||||
scenario.setStatus("未规划");
|
||||
scenario.setPriority("P1");
|
||||
scenario.setPrincipal("admin");
|
||||
scenario.setNum(NumGenerator.nextNum(project.getId(), ApplicationNumScope.API_SCENARIO));
|
||||
scenario.setPos(0L);
|
||||
scenario.setLatest(true);
|
||||
scenario.setVersionId("1.0");
|
||||
scenario.setRefId(scenario.getId());
|
||||
scenario.setCreateTime(System.currentTimeMillis());
|
||||
scenario.setUpdateTime(System.currentTimeMillis());
|
||||
scenario.setCreateUser("admin");
|
||||
scenario.setUpdateUser("admin");
|
||||
apiScenarioMapper.insertSelective(scenario);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void addModuleTestSuccess() throws Exception {
|
||||
//根目录下创建节点(a1)
|
||||
ModuleCreateRequest request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
request.setName("a1");
|
||||
MvcResult mvcResult = this.requestPostWithOkAndReturn(URL_MODULE_ADD, request);
|
||||
String returnId = mvcResult.getResponse().getContentAsString();
|
||||
Assertions.assertNotNull(returnId);
|
||||
List<BaseTreeNode> treeNodes = this.getModuleTreeNode();
|
||||
BaseTreeNode a1Node = null;
|
||||
for (BaseTreeNode baseTreeNode : treeNodes) {
|
||||
if (StringUtils.equals(baseTreeNode.getName(), request.getName())) {
|
||||
a1Node = baseTreeNode;
|
||||
}
|
||||
Assertions.assertNotNull(baseTreeNode.getParentId());
|
||||
}
|
||||
Assertions.assertNotNull(a1Node);
|
||||
initScenarioData(a1Node.getId());
|
||||
checkLog(a1Node.getId(), OperationLogType.ADD, URL_MODULE_ADD);
|
||||
|
||||
//根目录下创建节点a2和a3,在a1下创建子节点a1-b1
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
request.setName("a2");
|
||||
this.requestPostWithOkAndReturn(URL_MODULE_ADD, request);
|
||||
|
||||
|
||||
request.setName("a3");
|
||||
this.requestPostWithOkAndReturn(URL_MODULE_ADD, request);
|
||||
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
request.setName("a1-b1");
|
||||
request.setParentId(a1Node.getId());
|
||||
this.requestPostWithOkAndReturn(URL_MODULE_ADD, request);
|
||||
|
||||
treeNodes = this.getModuleTreeNode();
|
||||
BaseTreeNode a1b1Node = null;
|
||||
BaseTreeNode a2Node = null;
|
||||
for (BaseTreeNode baseTreeNode : treeNodes) {
|
||||
Assertions.assertNotNull(baseTreeNode.getParentId());
|
||||
if (StringUtils.equals(baseTreeNode.getName(), "a1") && CollectionUtils.isNotEmpty(baseTreeNode.getChildren())) {
|
||||
for (BaseTreeNode childNode : baseTreeNode.getChildren()) {
|
||||
if (StringUtils.equals(childNode.getName(), "a1-b1") && StringUtils.equals(childNode.getType(), ModuleConstants.NODE_TYPE_DEFAULT)) {
|
||||
a1b1Node = childNode;
|
||||
}
|
||||
Assertions.assertNotNull(childNode.getParentId());
|
||||
}
|
||||
} else if (StringUtils.equals(baseTreeNode.getName(), "a2") && StringUtils.equals(baseTreeNode.getType(), ModuleConstants.NODE_TYPE_DEFAULT)) {
|
||||
a2Node = baseTreeNode;
|
||||
}
|
||||
}
|
||||
Assertions.assertNotNull(a2Node);
|
||||
Assertions.assertNotNull(a1b1Node);
|
||||
initScenarioData(a2Node.getId());
|
||||
initScenarioData(a1b1Node.getId());
|
||||
checkLog(a2Node.getId(), OperationLogType.ADD, URL_MODULE_ADD);
|
||||
checkLog(a1b1Node.getId(), OperationLogType.ADD, URL_MODULE_ADD);
|
||||
|
||||
//a1节点下可以继续添加a1节点
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
request.setName("a1");
|
||||
request.setParentId(a1Node.getId());
|
||||
this.requestPostWithOkAndReturn(URL_MODULE_ADD, request);
|
||||
|
||||
//继续创建a1下继续创建a1-a1-b1,
|
||||
treeNodes = this.getModuleTreeNode();
|
||||
BaseTreeNode a1ChildNode = null;
|
||||
for (BaseTreeNode baseTreeNode : treeNodes) {
|
||||
Assertions.assertNotNull(baseTreeNode.getParentId());
|
||||
if (StringUtils.equals(baseTreeNode.getName(), "a1") && CollectionUtils.isNotEmpty(baseTreeNode.getChildren())) {
|
||||
for (BaseTreeNode childNode : baseTreeNode.getChildren()) {
|
||||
Assertions.assertNotNull(childNode.getParentId());
|
||||
if (StringUtils.equals(childNode.getName(), "a1") && StringUtils.equals(childNode.getType(), ModuleConstants.NODE_TYPE_DEFAULT)) {
|
||||
a1ChildNode = childNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Assertions.assertNotNull(a1ChildNode);
|
||||
initScenarioData(a1ChildNode.getId());
|
||||
checkLog(a1ChildNode.getId(), OperationLogType.ADD, URL_MODULE_ADD);
|
||||
|
||||
//a1的子节点a1下继续创建节点a1-a1-c1
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
request.setName("a1-a1-c1");
|
||||
request.setParentId(a1ChildNode.getId());
|
||||
this.requestPostWithOkAndReturn(URL_MODULE_ADD, request);
|
||||
treeNodes = this.getModuleTreeNode();
|
||||
BaseTreeNode a1a1c1Node = null;
|
||||
for (BaseTreeNode baseTreeNode : treeNodes) {
|
||||
Assertions.assertNotNull(baseTreeNode.getParentId());
|
||||
if (StringUtils.equals(baseTreeNode.getName(), "a1") && CollectionUtils.isNotEmpty(baseTreeNode.getChildren())) {
|
||||
for (BaseTreeNode secondNode : baseTreeNode.getChildren()) {
|
||||
Assertions.assertNotNull(secondNode.getParentId());
|
||||
if (StringUtils.equals(secondNode.getName(), "a1") && CollectionUtils.isNotEmpty(secondNode.getChildren())) {
|
||||
for (BaseTreeNode thirdNode : secondNode.getChildren()) {
|
||||
Assertions.assertNotNull(thirdNode.getParentId());
|
||||
if (StringUtils.equals(thirdNode.getName(), "a1-a1-c1") && StringUtils.equals(thirdNode.getType(), ModuleConstants.NODE_TYPE_DEFAULT)) {
|
||||
a1a1c1Node = thirdNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Assertions.assertNotNull(a1a1c1Node);
|
||||
initScenarioData(a1a1c1Node.getId());
|
||||
checkLog(a1a1c1Node.getId(), OperationLogType.ADD, URL_MODULE_ADD);
|
||||
|
||||
//子节点a1-b1下继续创建节点a1-b1-c1
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
request.setName("a1-b1-c1");
|
||||
request.setParentId(a1b1Node.getId());
|
||||
this.requestPostWithOkAndReturn(URL_MODULE_ADD, request);
|
||||
treeNodes = this.getModuleTreeNode();
|
||||
BaseTreeNode a1b1c1Node = null;
|
||||
for (BaseTreeNode baseTreeNode : treeNodes) {
|
||||
if (StringUtils.equals(baseTreeNode.getName(), "a1") && CollectionUtils.isNotEmpty(baseTreeNode.getChildren())) {
|
||||
for (BaseTreeNode secondNode : baseTreeNode.getChildren()) {
|
||||
if (StringUtils.equals(secondNode.getName(), "a1-b1") && CollectionUtils.isNotEmpty(secondNode.getChildren())) {
|
||||
for (BaseTreeNode thirdNode : secondNode.getChildren()) {
|
||||
if (StringUtils.equals(thirdNode.getName(), "a1-b1-c1") && StringUtils.equals(thirdNode.getType(), ModuleConstants.NODE_TYPE_DEFAULT)) {
|
||||
a1b1c1Node = thirdNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Assertions.assertNotNull(a1b1c1Node);
|
||||
initScenarioData(a1b1c1Node.getId());
|
||||
preliminaryTreeNodes = treeNodes;
|
||||
|
||||
checkLog(a1b1c1Node.getId(), OperationLogType.ADD, URL_MODULE_ADD);
|
||||
//校验权限
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setName("defaultProject");
|
||||
requestPostPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_ADD, URL_MODULE_ADD, request);
|
||||
|
||||
/**
|
||||
测试能否正常做200个节点
|
||||
*/
|
||||
String parentId = null;
|
||||
for (int i = 0; i < 210; i++) {
|
||||
ModuleCreateRequest perfRequest = new ModuleCreateRequest();
|
||||
perfRequest.setProjectId(project.getId());
|
||||
perfRequest.setName("500-test-root-" + i);
|
||||
if (StringUtils.isNotEmpty(parentId)) {
|
||||
perfRequest.setParentId(parentId);
|
||||
}
|
||||
if (i < 200) {
|
||||
MvcResult result = this.requestPostWithOkAndReturn(URL_MODULE_ADD, perfRequest);
|
||||
ResultHolder holder = JSON.parseObject(result.getResponse().getContentAsString(), ResultHolder.class);
|
||||
if (i % 50 == 0) {
|
||||
//到20换下一层级
|
||||
parentId = holder.getData().toString();
|
||||
}
|
||||
} else {
|
||||
//测试超过500会报错
|
||||
this.requestPost(URL_MODULE_ADD, perfRequest).andExpect(status().is5xxServerError());
|
||||
}
|
||||
}
|
||||
treeNodes = this.getModuleTreeNode();
|
||||
preliminaryTreeNodes = treeNodes;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void addModuleTestError() throws Exception {
|
||||
this.preliminaryData();
|
||||
|
||||
BaseTreeNode a1Node = getNodeByName(preliminaryTreeNodes, "a1");
|
||||
assert a1Node != null;
|
||||
|
||||
//参数校验
|
||||
ModuleCreateRequest request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(BAD_REQUEST_MATCHER);
|
||||
request = new ModuleCreateRequest();
|
||||
request.setName("none");
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(BAD_REQUEST_MATCHER);
|
||||
request = new ModuleCreateRequest();
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(BAD_REQUEST_MATCHER);
|
||||
request = new ModuleCreateRequest();
|
||||
request.setParentId(null);
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(BAD_REQUEST_MATCHER);
|
||||
//名称存在特殊字符
|
||||
request.setName("a1/a2");
|
||||
request.setParentId(a1Node.getId());
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(BAD_REQUEST_MATCHER);
|
||||
|
||||
//父节点ID不存在的
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
request.setName("ParentIsUUID");
|
||||
request.setParentId(IDGenerator.nextStr());
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//添加重复的a1节点
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
request.setName("a1");
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//a1节点下添加重复的a1-b1节点
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(project.getId());
|
||||
request.setName("a1-b1");
|
||||
request.setParentId(a1Node.getId());
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//子节点的项目ID和父节点的不匹配
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(IDGenerator.nextStr());
|
||||
request.setName("RandomUUID");
|
||||
request.setParentId(a1Node.getId());
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(status().is5xxServerError());
|
||||
|
||||
//项目ID和父节点的不匹配
|
||||
request = new ModuleCreateRequest();
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setName("RandomUUID");
|
||||
request.setParentId(a1Node.getId());
|
||||
this.requestPost(URL_MODULE_ADD, request).andExpect(status().is5xxServerError());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
public void updateModuleTestSuccess() throws Exception {
|
||||
if (CollectionUtils.isEmpty(preliminaryTreeNodes)) {
|
||||
this.addModuleTestSuccess();
|
||||
}
|
||||
//更改名称
|
||||
BaseTreeNode a1Node = null;
|
||||
for (BaseTreeNode node : preliminaryTreeNodes) {
|
||||
if (StringUtils.equals(node.getName(), "a1")) {
|
||||
for (BaseTreeNode a1ChildrenNode : node.getChildren()) {
|
||||
if (StringUtils.equals(a1ChildrenNode.getName(), "a1")) {
|
||||
a1Node = a1ChildrenNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert a1Node != null;
|
||||
ModuleUpdateRequest updateRequest = new ModuleUpdateRequest();
|
||||
updateRequest.setId(a1Node.getId());
|
||||
updateRequest.setName("a1-a1");
|
||||
requestPost(URL_MODULE_UPDATE, updateRequest);
|
||||
|
||||
preliminaryTreeNodes = this.getModuleTreeNode();
|
||||
checkLog(a1Node.getId(), OperationLogType.UPDATE, URL_MODULE_UPDATE);
|
||||
|
||||
//校验权限
|
||||
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
|
||||
example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("defaultProject");
|
||||
List<ApiScenarioModule> apiDebugModules = apiScenarioModuleMapper.selectByExample(example);
|
||||
assert CollectionUtils.isNotEmpty(apiDebugModules);
|
||||
updateRequest = new ModuleUpdateRequest();
|
||||
updateRequest.setId(apiDebugModules.get(0).getId());
|
||||
updateRequest.setName("default-update-Project");
|
||||
requestPostPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_UPDATE, URL_MODULE_UPDATE, updateRequest);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
public void updateModuleTestError() throws Exception {
|
||||
BaseTreeNode a1Node = getNodeByName(preliminaryTreeNodes, "a1-a1");
|
||||
assert a1Node != null;
|
||||
//反例-参数校验
|
||||
ModuleUpdateRequest updateRequest = new ModuleUpdateRequest();
|
||||
this.requestPost(URL_MODULE_UPDATE, updateRequest).andExpect(BAD_REQUEST_MATCHER);
|
||||
//参数名称带有特殊字符
|
||||
updateRequest = new ModuleUpdateRequest();
|
||||
updateRequest.setId(a1Node.getId());
|
||||
updateRequest.setName("a1/a2");
|
||||
this.requestPost(URL_MODULE_UPDATE, updateRequest).andExpect(BAD_REQUEST_MATCHER);
|
||||
|
||||
//id不存在
|
||||
updateRequest = new ModuleUpdateRequest();
|
||||
updateRequest.setId(IDGenerator.nextStr());
|
||||
updateRequest.setName(IDGenerator.nextStr());
|
||||
this.requestPost(URL_MODULE_UPDATE, updateRequest).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//名称重复 a1-a1改为a1-b1
|
||||
updateRequest = new ModuleUpdateRequest();
|
||||
updateRequest.setId(a1Node.getId());
|
||||
updateRequest.setName("a1-b1");
|
||||
this.requestPost(URL_MODULE_UPDATE, updateRequest).andExpect(ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
public void moveTest() throws Exception {
|
||||
this.preliminaryData();
|
||||
/*
|
||||
*默认节点
|
||||
|
|
||||
·a1 +
|
||||
| |
|
||||
| ·a1-b1 +
|
||||
| | |
|
||||
| | ·a1-b1-c1
|
||||
| |
|
||||
| *a1-a1 +(创建的时候是a1,通过修改改为a1-a1)
|
||||
| |
|
||||
| ·a1-a1-c1
|
||||
|
|
||||
·a2
|
||||
|
|
||||
·a3
|
||||
*/
|
||||
BaseTreeNode a1Node = getNodeByName(preliminaryTreeNodes, "a1");
|
||||
BaseTreeNode a2Node = getNodeByName(preliminaryTreeNodes, "a2");
|
||||
BaseTreeNode a3Node = getNodeByName(preliminaryTreeNodes, "a3");
|
||||
BaseTreeNode a1a1Node = getNodeByName(preliminaryTreeNodes, "a1-a1");
|
||||
BaseTreeNode a1b1Node = getNodeByName(preliminaryTreeNodes, "a1-b1");
|
||||
|
||||
//父节点内移动-移动到首位 a1挪到a3后面
|
||||
NodeMoveRequest request = new NodeMoveRequest();
|
||||
{
|
||||
assert a1Node != null;
|
||||
request.setDragNodeId(a1Node.getId());
|
||||
assert a3Node != null;
|
||||
request.setDropNodeId(a3Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a3Node.getId(), a1Node.getId(), null, false);
|
||||
}
|
||||
//父节点内移动-移动到末位 在上面的基础上,a1挪到a2上面
|
||||
{
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a1Node.getId());
|
||||
assert a2Node != null;
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(-1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a1Node.getId(), a2Node.getId(), null, false);
|
||||
}
|
||||
|
||||
//父节点内移动-移动到中位 a1移动到a2-a3中间
|
||||
{
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a1Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a2Node.getId(), a1Node.getId(), a3Node.getId(), false);
|
||||
//移动回去
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a1Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(-1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a1Node.getId(), a2Node.getId(), null, false);
|
||||
}
|
||||
|
||||
//跨节点移动-移动到首位 a3移动到a1-b1前面,然后移动回来;
|
||||
{
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a1b1Node.getId());
|
||||
request.setDropPosition(-1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a3Node.getId(), a1b1Node.getId(), null, false);
|
||||
//移动回去
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a2Node.getId(), a3Node.getId(), null, false);
|
||||
}
|
||||
|
||||
//跨节点移动-移动到末尾 a3移动到a1-a1后面,然后移动回来;
|
||||
{
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
assert a1a1Node != null;
|
||||
request.setDropNodeId(a1a1Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a1a1Node.getId(), a3Node.getId(), null, false);
|
||||
//移动回去
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a2Node.getId(), a3Node.getId(), null, false);
|
||||
}
|
||||
|
||||
//跨节点移动-移动到中位 a3移动到a1-b1和a1-a1中间,然后移动回来;
|
||||
{
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a1b1Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a1b1Node.getId(), a3Node.getId(), a1a1Node.getId(), false);
|
||||
//移动回去
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a2Node.getId(), a3Node.getId(), null, false);
|
||||
}
|
||||
|
||||
//父节点内移动-a3移动到首位pos小于2,是否触发计算函数 (先手动更改a1的pos为2,然后移动a3到a1前面)
|
||||
{
|
||||
//更改pos
|
||||
ApiScenarioModule updateModule = new ApiScenarioModule();
|
||||
updateModule.setId(a1Node.getId());
|
||||
updateModule.setPos(2L);
|
||||
apiScenarioModuleMapper.updateByPrimaryKeySelective(updateModule);
|
||||
|
||||
//开始移动
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a1Node.getId());
|
||||
request.setDropPosition(-1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a3Node.getId(), a1Node.getId(), null, true);
|
||||
|
||||
//移动回去
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a2Node.getId(), a3Node.getId(), null, false);
|
||||
}
|
||||
|
||||
//父节点内移动-移动到中位,前后节点pos差不大于2,是否触发计算函数(在上面的 a3-a1-a2的基础上, 先手动更改a1pos为3*64,a2的pos为3*64+2,然后移动a3到a1和a2中间)
|
||||
{
|
||||
//更改pos
|
||||
ApiScenarioModule updateModule = new ApiScenarioModule();
|
||||
updateModule.setId(a1Node.getId());
|
||||
updateModule.setPos(3 * 64L);
|
||||
apiScenarioModuleMapper.updateByPrimaryKeySelective(updateModule);
|
||||
updateModule.setId(a2Node.getId());
|
||||
updateModule.setPos(3 * 64 + 2L);
|
||||
apiScenarioModuleMapper.updateByPrimaryKeySelective(updateModule);
|
||||
|
||||
//开始移动
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a1Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a1Node.getId(), a3Node.getId(), a2Node.getId(), true);
|
||||
|
||||
//移动回去
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a2Node.getId(), a3Node.getId(), null, false);
|
||||
}
|
||||
//跨节点移动-移动到首位pos小于2,是否触发计算函数(先手动更改a1-b1的pos为2,然后移动a3到a1-b1前面,最后再移动回来)
|
||||
{
|
||||
//更改pos
|
||||
ApiScenarioModule updateModule = new ApiScenarioModule();
|
||||
updateModule.setId(a1b1Node.getId());
|
||||
updateModule.setPos(2L);
|
||||
apiScenarioModuleMapper.updateByPrimaryKeySelective(updateModule);
|
||||
|
||||
//开始移动
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a1b1Node.getId());
|
||||
request.setDropPosition(-1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a3Node.getId(), a1b1Node.getId(), null, true);
|
||||
|
||||
//移动回去
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a2Node.getId(), a3Node.getId(), null, false);
|
||||
}
|
||||
//跨节点移动-移动到中位,前后节点pos差不大于2,是否触发计算函数先手动更改a1-a1的pos为a1-b1+2,然后移动a3到a1-a1前面,最后再移动回来)
|
||||
{
|
||||
//更改pos
|
||||
ApiScenarioModule updateModule = new ApiScenarioModule();
|
||||
updateModule.setId(a1b1Node.getId());
|
||||
updateModule.setPos(3 * 64L);
|
||||
apiScenarioModuleMapper.updateByPrimaryKeySelective(updateModule);
|
||||
updateModule.setId(a1a1Node.getId());
|
||||
updateModule.setPos(3 * 64 + 2L);
|
||||
apiScenarioModuleMapper.updateByPrimaryKeySelective(updateModule);
|
||||
|
||||
//开始移动
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a1a1Node.getId());
|
||||
request.setDropPosition(-1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a1b1Node.getId(), a3Node.getId(), a1a1Node.getId(), true);
|
||||
|
||||
//移动回去
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a2Node.getId(), a3Node.getId(), null, false);
|
||||
}
|
||||
//移动到没有子节点的节点下 a3移动到a2下
|
||||
{
|
||||
//开始移动
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(0);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
ApiScenarioModule a3Module = apiScenarioModuleMapper.selectByPrimaryKey(a3Node.getId());
|
||||
Assertions.assertEquals(a3Module.getParentId(), a2Node.getId());
|
||||
|
||||
//移动回去
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a3Node.getId());
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPostWithOk(URL_MODULE_MOVE, request);
|
||||
this.checkModulePos(a2Node.getId(), a3Node.getId(), null, false);
|
||||
}
|
||||
|
||||
checkLog(a1Node.getId(), OperationLogType.UPDATE, URL_MODULE_MOVE);
|
||||
checkLog(a3Node.getId(), OperationLogType.UPDATE, URL_MODULE_MOVE);
|
||||
requestPostPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_UPDATE, URL_MODULE_MOVE, request);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
public void moveTestError() throws Exception {
|
||||
this.preliminaryData();
|
||||
BaseTreeNode a1Node = getNodeByName(preliminaryTreeNodes, "a1");
|
||||
BaseTreeNode a2Node = getNodeByName(preliminaryTreeNodes, "a2");
|
||||
//drag节点为空
|
||||
NodeMoveRequest request = new NodeMoveRequest();
|
||||
request.setDragNodeId(null);
|
||||
assert a1Node != null;
|
||||
request.setDropNodeId(a1Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPost(URL_MODULE_MOVE, request).andExpect(BAD_REQUEST_MATCHER);
|
||||
//drag节点不存在
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(IDGenerator.nextStr());
|
||||
request.setDropNodeId(a1Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPost(URL_MODULE_MOVE, request).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//drop节点为空
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a1Node.getId());
|
||||
request.setDropNodeId(null);
|
||||
request.setDropPosition(1);
|
||||
this.requestPost(URL_MODULE_MOVE, request).andExpect(BAD_REQUEST_MATCHER);
|
||||
|
||||
//drop节点不存在
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a1Node.getId());
|
||||
request.setDropNodeId(IDGenerator.nextStr());
|
||||
request.setDropPosition(1);
|
||||
this.requestPost(URL_MODULE_MOVE, request).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//position为0的时候节点不存在
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a1Node.getId());
|
||||
request.setDropNodeId(IDGenerator.nextStr());
|
||||
request.setDropPosition(0);
|
||||
this.requestPost(URL_MODULE_MOVE, request).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//dragNode和dropNode一样
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a1Node.getId());
|
||||
request.setDropNodeId(a1Node.getId());
|
||||
request.setDropPosition(1);
|
||||
this.requestPost(URL_MODULE_MOVE, request).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//position不是-1 0 1
|
||||
request = new NodeMoveRequest();
|
||||
request.setDragNodeId(a1Node.getId());
|
||||
assert a2Node != null;
|
||||
request.setDropNodeId(a2Node.getId());
|
||||
request.setDropPosition(4);
|
||||
this.requestPost(URL_MODULE_MOVE, request).andExpect(ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
public void TestModuleCountSuccess() throws Exception {
|
||||
this.preliminaryData();
|
||||
ApiScenarioModuleRequest request = new ApiScenarioModuleRequest() {{
|
||||
this.setProjectId(project.getId());
|
||||
}};
|
||||
MvcResult moduleCountMvcResult = this.requestPostWithOkAndReturn(URL_FILE_MODULE_COUNT, request);
|
||||
Map<String, Integer> moduleCountResult = JSON.parseObject(JSON.toJSONString(
|
||||
JSON.parseObject(moduleCountMvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
|
||||
Map.class);
|
||||
Assertions.assertTrue(moduleCountResult.containsKey("all"));
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
requestPostPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_READ, URL_FILE_MODULE_COUNT, request);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
public void deleteModuleTestSuccess() throws Exception {
|
||||
this.preliminaryData();
|
||||
this.getModuleTrashTreeNode();
|
||||
|
||||
// 删除没有文件的节点a1-b1-c1 检查是否级联删除根节点
|
||||
BaseTreeNode a1b1Node = getNodeByName(this.getModuleTreeNode(), "a1-b1");
|
||||
assert a1b1Node != null;
|
||||
this.requestGetWithOk(String.format(URL_MODULE_DELETE, a1b1Node.getId()));
|
||||
this.checkModuleIsEmpty(a1b1Node.getId());
|
||||
checkLog(a1b1Node.getId(), OperationLogType.DELETE, URL_MODULE_DELETE);
|
||||
|
||||
// 删除有文件的节点 a1-a1 检查是否级联删除根节点
|
||||
BaseTreeNode a1a1Node = getNodeByName(this.getModuleTreeNode(), "a1-a1");
|
||||
assert a1a1Node != null;
|
||||
this.requestGetWithOk(String.format(URL_MODULE_DELETE, a1a1Node.getId()));
|
||||
this.checkModuleIsEmpty(a1a1Node.getId());
|
||||
checkLog(a1a1Node.getId(), OperationLogType.DELETE, URL_MODULE_DELETE);
|
||||
|
||||
//删除不存在的节点
|
||||
this.requestGet(String.format(URL_MODULE_DELETE, IDGenerator.nextNum())).andExpect(ERROR_REQUEST_MATCHER);
|
||||
// 测试删除根节点
|
||||
this.requestGet(String.format(URL_MODULE_DELETE, ModuleConstants.DEFAULT_NODE_ID)).andExpect(ERROR_REQUEST_MATCHER);
|
||||
|
||||
//service层判断:测试删除空集合
|
||||
apiScenarioModuleService.deleteModule(new ArrayList<>(), "admin", DEFAULT_PROJECT_ID);
|
||||
//校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_DELETE, String.format(URL_MODULE_DELETE, IDGenerator.nextNum()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
public void getModuleTrashTreeNode() throws Exception {
|
||||
MvcResult result = this.requestPostWithOkAndReturn(URL_MODULE_TRASH_TREE, new ApiScenarioModuleRequest() {{
|
||||
this.setProjectId(project.getId());
|
||||
}});
|
||||
String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
public void getModuleTrashTreeCount() throws Exception {
|
||||
ApiScenarioModuleRequest request = new ApiScenarioModuleRequest() {{
|
||||
this.setProjectId(project.getId());
|
||||
}};
|
||||
MvcResult moduleCountMvcResult = this.requestPostWithOkAndReturn(URL_MODULE_TRASH_COUNT, request);
|
||||
Map<String, Integer> moduleCountResult = JSON.parseObject(JSON.toJSONString(
|
||||
JSON.parseObject(moduleCountMvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
|
||||
Map.class);
|
||||
Assertions.assertTrue(moduleCountResult.containsKey("all"));
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
requestPostPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_READ, URL_MODULE_TRASH_COUNT, request);
|
||||
}
|
||||
|
||||
|
||||
private List<BaseTreeNode> getModuleTreeNode() throws Exception {
|
||||
MvcResult result = this.requestPostWithOkAndReturn(URL_MODULE_TREE, new ApiScenarioModuleRequest() {{
|
||||
this.setProjectId(project.getId());
|
||||
}});
|
||||
String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
return JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class);
|
||||
}
|
||||
|
||||
private void preliminaryData() throws Exception {
|
||||
if (CollectionUtils.isEmpty(preliminaryTreeNodes)) {
|
||||
/*
|
||||
这里需要获取修改过的树的结构。期望的最终结构是这样的(*为测试用例中挂载文件的节点, · 为空节点):
|
||||
|
||||
*默认节点
|
||||
|
|
||||
·a1 +
|
||||
| |
|
||||
| ·a1-b1 +
|
||||
| | |
|
||||
| | ·a1-b1-c1
|
||||
| |
|
||||
| *a1-a1 +(创建的时候是a1,通过修改改为a1-a1)
|
||||
| | |
|
||||
| | ·a1-a1-c1
|
||||
|
|
||||
·a2
|
||||
|
|
||||
·a3
|
||||
*/
|
||||
this.updateModuleTestSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkModuleIsEmpty(String id) {
|
||||
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
|
||||
example.createCriteria().andParentIdEqualTo(id);
|
||||
Assertions.assertEquals(0, apiScenarioModuleMapper.countByExample(example));
|
||||
|
||||
ApiScenarioExample apiDebugExample = new ApiScenarioExample();
|
||||
example = new ApiScenarioModuleExample();
|
||||
example.createCriteria().andIdEqualTo(id);
|
||||
Assertions.assertEquals(0, apiScenarioModuleMapper.countByExample(example));
|
||||
apiDebugExample.createCriteria().andModuleIdEqualTo(id).andDeletedEqualTo(false);
|
||||
Assertions.assertEquals(0, apiScenarioMapper.countByExample(apiDebugExample));
|
||||
}
|
||||
|
||||
private void checkModulePos(String firstNode, String secondNode, String thirdNode, boolean isRecalculate) {
|
||||
ApiScenarioModule firstModule = apiScenarioModuleMapper.selectByPrimaryKey(firstNode);
|
||||
ApiScenarioModule secondModule = apiScenarioModuleMapper.selectByPrimaryKey(secondNode);
|
||||
ApiScenarioModule thirdModule = null;
|
||||
Assertions.assertTrue(firstModule.getPos() < secondModule.getPos());
|
||||
if (StringUtils.isNotBlank(thirdNode)) {
|
||||
thirdModule = apiScenarioModuleMapper.selectByPrimaryKey(thirdNode);
|
||||
Assertions.assertTrue(secondModule.getPos() < thirdModule.getPos());
|
||||
}
|
||||
if (isRecalculate) {
|
||||
int limitPos = 64;
|
||||
Assertions.assertEquals(0, firstModule.getPos() % limitPos);
|
||||
Assertions.assertEquals(0, secondModule.getPos() % limitPos);
|
||||
if (thirdModule != null) {
|
||||
Assertions.assertEquals(0, thirdModule.getPos() % limitPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.domain.*;
|
||||
import io.metersphere.api.mapper.*;
|
||||
import io.metersphere.api.service.CleanupApiResourceService;
|
||||
import io.metersphere.system.invoker.ProjectServiceInvoker;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@AutoConfigureMockMvc
|
||||
public class CleanupApiTests {
|
||||
private final ProjectServiceInvoker serviceInvoker;
|
||||
@Resource
|
||||
private CleanupApiResourceService cleanupApiResourceService;
|
||||
@Resource
|
||||
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
||||
@Resource
|
||||
private ApiScenarioModuleMapper apiScenarioModuleMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
@Resource
|
||||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMockMapper apiDefinitionMockMapper;
|
||||
|
||||
@Autowired
|
||||
public CleanupApiTests(ProjectServiceInvoker serviceInvoker) {
|
||||
this.serviceInvoker = serviceInvoker;
|
||||
}
|
||||
|
||||
public void initData() throws Exception {
|
||||
//创建接口模块
|
||||
ApiDefinitionModule apiDefinitionModule = new ApiDefinitionModule();
|
||||
apiDefinitionModule.setId("test-module");
|
||||
apiDefinitionModule.setProjectId("test");
|
||||
apiDefinitionModule.setName("test");
|
||||
apiDefinitionModule.setPos(1L);
|
||||
apiDefinitionModule.setCreateUser("admin");
|
||||
apiDefinitionModule.setUpdateUser("admin");
|
||||
apiDefinitionModule.setCreateTime(System.currentTimeMillis());
|
||||
apiDefinitionModule.setUpdateTime(System.currentTimeMillis());
|
||||
apiDefinitionModuleMapper.insertSelective(apiDefinitionModule);
|
||||
//创建场景模块
|
||||
ApiScenarioModule apiScenarioModule = new ApiScenarioModule();
|
||||
apiScenarioModule.setId("test-scenario-module");
|
||||
apiScenarioModule.setProjectId("test");
|
||||
apiScenarioModule.setName("test");
|
||||
apiScenarioModule.setPos(1L);
|
||||
apiScenarioModule.setCreateUser("admin");
|
||||
apiScenarioModule.setUpdateUser("admin");
|
||||
apiScenarioModule.setCreateTime(System.currentTimeMillis());
|
||||
apiScenarioModule.setUpdateTime(System.currentTimeMillis());
|
||||
apiScenarioModuleMapper.insertSelective(apiScenarioModule);
|
||||
//创建接口
|
||||
ApiDefinition apiDefinition = new ApiDefinition();
|
||||
apiDefinition.setId("test");
|
||||
apiDefinition.setProjectId("test");
|
||||
apiDefinition.setModuleId("test-module");
|
||||
apiDefinition.setName("test");
|
||||
apiDefinition.setPath("test");
|
||||
apiDefinition.setProtocol("http");
|
||||
apiDefinition.setMethod("test");
|
||||
apiDefinition.setCreateUser("admin");
|
||||
apiDefinition.setUpdateUser("admin");
|
||||
apiDefinition.setNum(1L);
|
||||
apiDefinition.setVersionId("test");
|
||||
apiDefinition.setRefId("test");
|
||||
apiDefinition.setPos(1L);
|
||||
apiDefinition.setLatest(true);
|
||||
apiDefinition.setStatus("api-status");
|
||||
apiDefinition.setCreateTime(System.currentTimeMillis());
|
||||
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||
apiDefinitionMapper.insertSelective(apiDefinition);
|
||||
//创建用例
|
||||
ApiTestCase apiTestCase = new ApiTestCase();
|
||||
apiTestCase.setId("test");
|
||||
apiTestCase.setProjectId("test");
|
||||
apiTestCase.setApiDefinitionId("test");
|
||||
apiTestCase.setCreateUser("admin");
|
||||
apiTestCase.setUpdateUser("admin");
|
||||
apiTestCase.setCreateTime(System.currentTimeMillis());
|
||||
apiTestCase.setUpdateTime(System.currentTimeMillis());
|
||||
apiTestCase.setPos(1L);
|
||||
apiTestCase.setNum(1L);
|
||||
apiTestCase.setStatus("test");
|
||||
apiTestCase.setVersionId("test");
|
||||
apiTestCase.setPriority("test");
|
||||
apiTestCase.setName("test");
|
||||
apiTestCaseMapper.insertSelective(apiTestCase);
|
||||
//创建mock
|
||||
ApiDefinitionMock apiDefinitionMock = new ApiDefinitionMock();
|
||||
apiDefinitionMock.setId("test");
|
||||
apiDefinitionMock.setApiDefinitionId("test");
|
||||
apiDefinitionMock.setProjectId("test");
|
||||
apiDefinitionMock.setCreateUser("admin");
|
||||
apiDefinitionMock.setCreateTime(System.currentTimeMillis());
|
||||
apiDefinitionMock.setUpdateTime(System.currentTimeMillis());
|
||||
apiDefinitionMock.setName("test");
|
||||
apiDefinitionMock.setExpectNum("test");
|
||||
apiDefinitionMockMapper.insertSelective(apiDefinitionMock);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void testCleanupResource() throws Exception {
|
||||
initData();
|
||||
serviceInvoker.invokeServices("test");
|
||||
cleanupApiResourceService.deleteResources("test");
|
||||
}
|
||||
|
||||
}
|
|
@ -85,6 +85,6 @@ minio.endpoint=http://${embedded.minio.host}:${embedded.minio.port}
|
|||
minio.access-key=${embedded.minio.accessKey}
|
||||
minio.secret-key=${embedded.minio.secretKey}
|
||||
|
||||
logging.level.org.springframework.jdbc.core=debug
|
||||
logging.level.io.metersphere.sdk.mapper=debug
|
||||
logging.level.io.metersphere.project.mapper=debug
|
||||
logging.level.org.springframework.jdbc.core=info
|
||||
logging.level.io.metersphere.sdk.mapper=info
|
||||
logging.level.io.metersphere.project.mapper=info
|
|
@ -1,17 +1,17 @@
|
|||
package io.metersphere.system.service;
|
||||
|
||||
import io.metersphere.sdk.constants.UserRoleEnum;
|
||||
import io.metersphere.system.dto.permission.Permission;
|
||||
import io.metersphere.system.dto.permission.PermissionDefinitionItem;
|
||||
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.config.PermissionCache;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.config.PermissionCache;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserRole;
|
||||
import io.metersphere.system.domain.UserRoleExample;
|
||||
import io.metersphere.system.domain.UserRoleRelation;
|
||||
import io.metersphere.system.dto.permission.Permission;
|
||||
import io.metersphere.system.dto.permission.PermissionDefinitionItem;
|
||||
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
||||
import io.metersphere.system.mapper.UserMapper;
|
||||
import io.metersphere.system.mapper.UserRoleMapper;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
|
@ -120,6 +120,7 @@ public class BaseUserRoleService {
|
|||
put("READ+RECOVER", "permission.recover");
|
||||
put("READ+EXPORT", "permission.export");
|
||||
put("READ+EXECUTE", "permission.execute");
|
||||
put("READ+DEBUG", "permission.download");
|
||||
}};
|
||||
return Translator.get(translationMap.get(permissionKey));
|
||||
}
|
||||
|
@ -260,6 +261,7 @@ public class BaseUserRoleService {
|
|||
|
||||
/**
|
||||
* 校验同名用户组是否存在
|
||||
*
|
||||
* @param userRole 用户组
|
||||
*/
|
||||
public void checkNewRoleExist(UserRole userRole) {
|
||||
|
@ -278,6 +280,7 @@ public class BaseUserRoleService {
|
|||
|
||||
/**
|
||||
* 校验用户与用户组是否存在
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param roleId 用户组ID
|
||||
*/
|
||||
|
|
|
@ -37,7 +37,7 @@ INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('aspe
|
|||
INSERT INTO api_definition(id, name, protocol, method, path, status, num, tags, pos, project_id, module_id, latest, version_id, ref_id, description, create_time, create_user, update_time, update_user, delete_user, delete_time, deleted)
|
||||
VALUES ('aspect_gyq_api_one', 'api_test','HTTP', 'POST','api/test','test-api-status', 1000001, null, 1, '100001100001' , 'test_module', true, 'v1.10','aspect_gyq_api_one', null, UNIX_TIMESTAMP() * 1000,'admin', UNIX_TIMESTAMP() * 1000,'admin', null,null,false);
|
||||
|
||||
INSERT INTO api_scenario(id, name, level, status, principal, last_report_status, last_report_id, num, custom_num, pos, version_id, ref_id, project_id, api_scenario_module_id, description, tags, create_user, create_time, delete_time, delete_user, update_user, update_time)
|
||||
INSERT INTO api_scenario(id, name, priority, status, principal, last_report_status, last_report_id, num, custom_num, pos, version_id, ref_id, project_id, module_id, description, tags, create_user, create_time, delete_time, delete_user, update_user, update_time)
|
||||
VALUES ('aspect_gyq_api_scenario_one', 'api_scenario', 'p1', 'test-api-status', 'gyq', null, null,1000001, 1000001, 1,'v1.10', 'aspect_gyq_api_scenario_one','100001100001', 'test_module', null,null,'admin', UNIX_TIMESTAMP() * 1000,null,null,'admin', UNIX_TIMESTAMP() * 1000);
|
||||
|
||||
INSERT INTO test_plan(id, project_id, parent_id, name, status, stage, tags, create_time, create_user, update_time, update_user, planned_start_time, planned_end_time, actual_start_time, actual_end_time, description)
|
||||
|
|
Loading…
Reference in New Issue