feat(任务中心): 新增报告与任务关联关系表

This commit is contained in:
WangXu10 2024-10-15 19:00:35 +08:00 committed by Craftsman
parent 6cfd35c261
commit e421ab7681
12 changed files with 668 additions and 211 deletions

View File

@ -148,9 +148,6 @@ public class ApiReport implements Serializable {
@NotNull(message = "{api_report.plan.not_blank}", groups = {Created.class})
private Boolean plan;
@Schema(description = "关联任务id(集合报告)/任务项id")
private String associatedTaskId;
private static final long serialVersionUID = 1L;
public enum Column {
@ -186,8 +183,7 @@ public class ApiReport implements Serializable {
assertionPassRate("assertion_pass_rate", "assertionPassRate", "VARCHAR", false),
scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false),
execStatus("exec_status", "execStatus", "VARCHAR", false),
plan("plan", "plan", "BIT", true),
associatedTaskId("associated_task_id", "associatedTaskId", "VARCHAR", false);
plan("plan", "plan", "BIT", true);
private static final String BEGINNING_DELIMITER = "`";

View File

@ -2273,76 +2273,6 @@ public class ApiReportExample {
addCriterion("`plan` not between", value1, value2, "plan");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIsNull() {
addCriterion("associated_task_id is null");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIsNotNull() {
addCriterion("associated_task_id is not null");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdEqualTo(String value) {
addCriterion("associated_task_id =", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotEqualTo(String value) {
addCriterion("associated_task_id <>", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdGreaterThan(String value) {
addCriterion("associated_task_id >", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdGreaterThanOrEqualTo(String value) {
addCriterion("associated_task_id >=", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLessThan(String value) {
addCriterion("associated_task_id <", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLessThanOrEqualTo(String value) {
addCriterion("associated_task_id <=", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLike(String value) {
addCriterion("associated_task_id like", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotLike(String value) {
addCriterion("associated_task_id not like", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIn(List<String> values) {
addCriterion("associated_task_id in", values, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotIn(List<String> values) {
addCriterion("associated_task_id not in", values, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdBetween(String value1, String value2) {
addCriterion("associated_task_id between", value1, value2, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotBetween(String value1, String value2) {
addCriterion("associated_task_id not between", value1, value2, "associatedTaskId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -0,0 +1,98 @@
package io.metersphere.api.domain;
import io.metersphere.validation.groups.Created;
import io.metersphere.validation.groups.Updated;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import lombok.Data;
@Data
public class ApiReportRelateTask implements Serializable {
@Schema(title = "任务id/任务项id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{api_report_relate_task.task_resource_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{api_report_relate_task.task_resource_id.length_range}", groups = {Created.class, Updated.class})
private String taskResourceId;
@Schema(title = "报告id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{api_report_relate_task.report_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{api_report_relate_task.report_id.length_range}", groups = {Created.class, Updated.class})
private String reportId;
private static final long serialVersionUID = 1L;
public enum Column {
taskResourceId("task_resource_id", "taskResourceId", "VARCHAR", false),
reportId("report_id", "reportId", "VARCHAR", false);
private static final String BEGINNING_DELIMITER = "`";
private static final String ENDING_DELIMITER = "`";
private final String column;
private final boolean isColumnNameDelimited;
private final String javaProperty;
private final String jdbcType;
public String value() {
return this.column;
}
public String getValue() {
return this.column;
}
public String getJavaProperty() {
return this.javaProperty;
}
public String getJdbcType() {
return this.jdbcType;
}
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
public static Column[] all() {
return Column.values();
}
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
public String getAliasedEscapedColumnName() {
return this.getEscapedColumnName();
}
}
}

View File

@ -0,0 +1,340 @@
package io.metersphere.api.domain;
import java.util.ArrayList;
import java.util.List;
public class ApiReportRelateTaskExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public ApiReportRelateTaskExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andTaskResourceIdIsNull() {
addCriterion("task_resource_id is null");
return (Criteria) this;
}
public Criteria andTaskResourceIdIsNotNull() {
addCriterion("task_resource_id is not null");
return (Criteria) this;
}
public Criteria andTaskResourceIdEqualTo(String value) {
addCriterion("task_resource_id =", value, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdNotEqualTo(String value) {
addCriterion("task_resource_id <>", value, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdGreaterThan(String value) {
addCriterion("task_resource_id >", value, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdGreaterThanOrEqualTo(String value) {
addCriterion("task_resource_id >=", value, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdLessThan(String value) {
addCriterion("task_resource_id <", value, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdLessThanOrEqualTo(String value) {
addCriterion("task_resource_id <=", value, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdLike(String value) {
addCriterion("task_resource_id like", value, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdNotLike(String value) {
addCriterion("task_resource_id not like", value, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdIn(List<String> values) {
addCriterion("task_resource_id in", values, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdNotIn(List<String> values) {
addCriterion("task_resource_id not in", values, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdBetween(String value1, String value2) {
addCriterion("task_resource_id between", value1, value2, "taskResourceId");
return (Criteria) this;
}
public Criteria andTaskResourceIdNotBetween(String value1, String value2) {
addCriterion("task_resource_id not between", value1, value2, "taskResourceId");
return (Criteria) this;
}
public Criteria andReportIdIsNull() {
addCriterion("report_id is null");
return (Criteria) this;
}
public Criteria andReportIdIsNotNull() {
addCriterion("report_id is not null");
return (Criteria) this;
}
public Criteria andReportIdEqualTo(String value) {
addCriterion("report_id =", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotEqualTo(String value) {
addCriterion("report_id <>", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThan(String value) {
addCriterion("report_id >", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThanOrEqualTo(String value) {
addCriterion("report_id >=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThan(String value) {
addCriterion("report_id <", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThanOrEqualTo(String value) {
addCriterion("report_id <=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLike(String value) {
addCriterion("report_id like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotLike(String value) {
addCriterion("report_id not like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdIn(List<String> values) {
addCriterion("report_id in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotIn(List<String> values) {
addCriterion("report_id not in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdBetween(String value1, String value2) {
addCriterion("report_id between", value1, value2, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotBetween(String value1, String value2) {
addCriterion("report_id not between", value1, value2, "reportId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -151,9 +151,6 @@ public class ApiScenarioReport implements Serializable {
@NotNull(message = "{api_scenario_report.plan.not_blank}", groups = {Created.class})
private Boolean plan;
@Schema(description = "关联任务id(集合报告)/任务项id")
private String associatedTaskId;
private static final long serialVersionUID = 1L;
public enum Column {
@ -190,8 +187,7 @@ public class ApiScenarioReport implements Serializable {
scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false),
waitingTime("waiting_time", "waitingTime", "BIGINT", false),
execStatus("exec_status", "execStatus", "VARCHAR", false),
plan("plan", "plan", "BIT", true),
associatedTaskId("associated_task_id", "associatedTaskId", "VARCHAR", false);
plan("plan", "plan", "BIT", true);
private static final String BEGINNING_DELIMITER = "`";

View File

@ -2333,76 +2333,6 @@ public class ApiScenarioReportExample {
addCriterion("`plan` not between", value1, value2, "plan");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIsNull() {
addCriterion("associated_task_id is null");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIsNotNull() {
addCriterion("associated_task_id is not null");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdEqualTo(String value) {
addCriterion("associated_task_id =", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotEqualTo(String value) {
addCriterion("associated_task_id <>", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdGreaterThan(String value) {
addCriterion("associated_task_id >", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdGreaterThanOrEqualTo(String value) {
addCriterion("associated_task_id >=", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLessThan(String value) {
addCriterion("associated_task_id <", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLessThanOrEqualTo(String value) {
addCriterion("associated_task_id <=", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdLike(String value) {
addCriterion("associated_task_id like", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotLike(String value) {
addCriterion("associated_task_id not like", value, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdIn(List<String> values) {
addCriterion("associated_task_id in", values, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotIn(List<String> values) {
addCriterion("associated_task_id not in", values, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdBetween(String value1, String value2) {
addCriterion("associated_task_id between", value1, value2, "associatedTaskId");
return (Criteria) this;
}
public Criteria andAssociatedTaskIdNotBetween(String value1, String value2) {
addCriterion("associated_task_id not between", value1, value2, "associatedTaskId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -35,7 +35,6 @@
<result column="script_identifier" jdbcType="VARCHAR" property="scriptIdentifier" />
<result column="exec_status" jdbcType="VARCHAR" property="execStatus" />
<result column="plan" jdbcType="BIT" property="plan" />
<result column="associated_task_id" jdbcType="VARCHAR" property="associatedTaskId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -101,7 +100,7 @@
pool_id, integrated, project_id, environment_id, error_count, fake_error_count, pending_count,
success_count, assertion_count, assertion_success_count, request_error_rate, request_pending_rate,
request_fake_error_rate, request_pass_rate, assertion_pass_rate, script_identifier,
exec_status, `plan`, associated_task_id
exec_status, `plan`
</sql>
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiReportExample" resultMap="BaseResultMap">
select
@ -145,8 +144,7 @@
assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate,
request_pass_rate, assertion_pass_rate, script_identifier,
exec_status, `plan`, associated_task_id
)
exec_status, `plan`)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{testPlanCaseId,jdbcType=VARCHAR},
#{createUser,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, #{deleteUser,jdbcType=VARCHAR},
#{deleted,jdbcType=BIT}, #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT},
@ -158,8 +156,7 @@
#{assertionSuccessCount,jdbcType=BIGINT}, #{requestErrorRate,jdbcType=VARCHAR},
#{requestPendingRate,jdbcType=VARCHAR}, #{requestFakeErrorRate,jdbcType=VARCHAR},
#{requestPassRate,jdbcType=VARCHAR}, #{assertionPassRate,jdbcType=VARCHAR}, #{scriptIdentifier,jdbcType=VARCHAR},
#{execStatus,jdbcType=VARCHAR}, #{plan,jdbcType=BIT}, #{associatedTaskId,jdbcType=VARCHAR}
)
#{execStatus,jdbcType=VARCHAR}, #{plan,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiReport">
insert into api_report
@ -263,9 +260,6 @@
<if test="plan != null">
`plan`,
</if>
<if test="associatedTaskId != null">
associated_task_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -367,9 +361,6 @@
<if test="plan != null">
#{plan,jdbcType=BIT},
</if>
<if test="associatedTaskId != null">
#{associatedTaskId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.api.domain.ApiReportExample" resultType="java.lang.Long">
@ -480,9 +471,6 @@
<if test="record.plan != null">
`plan` = #{record.plan,jdbcType=BIT},
</if>
<if test="record.associatedTaskId != null">
associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -522,8 +510,7 @@
assertion_pass_rate = #{record.assertionPassRate,jdbcType=VARCHAR},
script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR},
exec_status = #{record.execStatus,jdbcType=VARCHAR},
`plan` = #{record.plan,jdbcType=BIT},
associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR}
`plan` = #{record.plan,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -627,9 +614,6 @@
<if test="plan != null">
`plan` = #{plan,jdbcType=BIT},
</if>
<if test="associatedTaskId != null">
associated_task_id = #{associatedTaskId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -666,8 +650,7 @@
assertion_pass_rate = #{assertionPassRate,jdbcType=VARCHAR},
script_identifier = #{scriptIdentifier,jdbcType=VARCHAR},
exec_status = #{execStatus,jdbcType=VARCHAR},
`plan` = #{plan,jdbcType=BIT},
associated_task_id = #{associatedTaskId,jdbcType=VARCHAR}
`plan` = #{plan,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
@ -677,7 +660,7 @@
pool_id, integrated, project_id, environment_id, error_count, fake_error_count,
pending_count, success_count, assertion_count, assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate,
script_identifier, exec_status, `plan`, associated_task_id)
script_identifier, exec_status, `plan`)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanCaseId,jdbcType=VARCHAR},
@ -692,7 +675,7 @@
#{item.requestPendingRate,jdbcType=VARCHAR}, #{item.requestFakeErrorRate,jdbcType=VARCHAR},
#{item.requestPassRate,jdbcType=VARCHAR}, #{item.assertionPassRate,jdbcType=VARCHAR},
#{item.scriptIdentifier,jdbcType=VARCHAR}, #{item.execStatus,jdbcType=VARCHAR},
#{item.plan,jdbcType=BIT}, #{item.associatedTaskId,jdbcType=VARCHAR})
#{item.plan,jdbcType=BIT})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -804,9 +787,6 @@
<if test="'plan'.toString() == column.value">
#{item.plan,jdbcType=BIT}
</if>
<if test="'associated_task_id'.toString() == column.value">
#{item.associatedTaskId,jdbcType=VARCHAR}
</if>
</foreach>
)
</foreach>

View File

@ -0,0 +1,28 @@
package io.metersphere.api.mapper;
import io.metersphere.api.domain.ApiReportRelateTask;
import io.metersphere.api.domain.ApiReportRelateTaskExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ApiReportRelateTaskMapper {
long countByExample(ApiReportRelateTaskExample example);
int deleteByExample(ApiReportRelateTaskExample example);
int deleteByPrimaryKey(@Param("taskResourceId") String taskResourceId, @Param("reportId") String reportId);
int insert(ApiReportRelateTask record);
int insertSelective(ApiReportRelateTask record);
List<ApiReportRelateTask> selectByExample(ApiReportRelateTaskExample example);
int updateByExampleSelective(@Param("record") ApiReportRelateTask record, @Param("example") ApiReportRelateTaskExample example);
int updateByExample(@Param("record") ApiReportRelateTask record, @Param("example") ApiReportRelateTaskExample example);
int batchInsert(@Param("list") List<ApiReportRelateTask> list);
int batchInsertSelective(@Param("list") List<ApiReportRelateTask> list, @Param("selective") ApiReportRelateTask.Column ... selective);
}

View File

@ -0,0 +1,173 @@
<?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.ApiReportRelateTaskMapper">
<resultMap id="BaseResultMap" type="io.metersphere.api.domain.ApiReportRelateTask">
<id column="task_resource_id" jdbcType="VARCHAR" property="taskResourceId" />
<id column="report_id" jdbcType="VARCHAR" property="reportId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
task_resource_id, report_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiReportRelateTaskExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from api_report_relate_task
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="map">
delete from api_report_relate_task
where task_resource_id = #{taskResourceId,jdbcType=VARCHAR}
and report_id = #{reportId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.api.domain.ApiReportRelateTaskExample">
delete from api_report_relate_task
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.api.domain.ApiReportRelateTask">
insert into api_report_relate_task (task_resource_id, report_id)
values (#{taskResourceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiReportRelateTask">
insert into api_report_relate_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskResourceId != null">
task_resource_id,
</if>
<if test="reportId != null">
report_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskResourceId != null">
#{taskResourceId,jdbcType=VARCHAR},
</if>
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.api.domain.ApiReportRelateTaskExample" resultType="java.lang.Long">
select count(*) from api_report_relate_task
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update api_report_relate_task
<set>
<if test="record.taskResourceId != null">
task_resource_id = #{record.taskResourceId,jdbcType=VARCHAR},
</if>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update api_report_relate_task
set task_resource_id = #{record.taskResourceId,jdbcType=VARCHAR},
report_id = #{record.reportId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<insert id="batchInsert" parameterType="map">
insert into api_report_relate_task
(task_resource_id, report_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.taskResourceId,jdbcType=VARCHAR}, #{item.reportId,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
insert into api_report_relate_task (
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
)
values
<foreach collection="list" item="item" separator=",">
(
<foreach collection="selective" item="column" separator=",">
<if test="'task_resource_id'.toString() == column.value">
#{item.taskResourceId,jdbcType=VARCHAR}
</if>
<if test="'report_id'.toString() == column.value">
#{item.reportId,jdbcType=VARCHAR}
</if>
</foreach>
)
</foreach>
</insert>
</mapper>

View File

@ -36,7 +36,6 @@
<result column="waiting_time" jdbcType="BIGINT" property="waitingTime" />
<result column="exec_status" jdbcType="VARCHAR" property="execStatus" />
<result column="plan" jdbcType="BIT" property="plan" />
<result column="associated_task_id" jdbcType="VARCHAR" property="associatedTaskId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -102,7 +101,7 @@
run_mode, pool_id, integrated, project_id, environment_id, error_count, fake_error_count,
pending_count, success_count, assertion_count, assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate,
script_identifier, waiting_time, exec_status, `plan`, associated_task_id
script_identifier, waiting_time, exec_status, `plan`
</sql>
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiScenarioReportExample" resultMap="BaseResultMap">
select
@ -146,8 +145,8 @@
assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate,
request_pass_rate, assertion_pass_rate, script_identifier,
waiting_time, exec_status, `plan`,
associated_task_id)
waiting_time, exec_status, `plan`
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{testPlanScenarioId,jdbcType=VARCHAR},
#{createUser,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, #{deleteUser,jdbcType=VARCHAR},
#{deleted,jdbcType=BIT}, #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT},
@ -159,8 +158,8 @@
#{assertionSuccessCount,jdbcType=BIGINT}, #{requestErrorRate,jdbcType=VARCHAR},
#{requestPendingRate,jdbcType=VARCHAR}, #{requestFakeErrorRate,jdbcType=VARCHAR},
#{requestPassRate,jdbcType=VARCHAR}, #{assertionPassRate,jdbcType=VARCHAR}, #{scriptIdentifier,jdbcType=VARCHAR},
#{waitingTime,jdbcType=BIGINT}, #{execStatus,jdbcType=VARCHAR}, #{plan,jdbcType=BIT},
#{associatedTaskId,jdbcType=VARCHAR})
#{waitingTime,jdbcType=BIGINT}, #{execStatus,jdbcType=VARCHAR}, #{plan,jdbcType=BIT}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiScenarioReport">
insert into api_scenario_report
@ -267,9 +266,6 @@
<if test="plan != null">
`plan`,
</if>
<if test="associatedTaskId != null">
associated_task_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -374,9 +370,6 @@
<if test="plan != null">
#{plan,jdbcType=BIT},
</if>
<if test="associatedTaskId != null">
#{associatedTaskId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.api.domain.ApiScenarioReportExample" resultType="java.lang.Long">
@ -490,9 +483,6 @@
<if test="record.plan != null">
`plan` = #{record.plan,jdbcType=BIT},
</if>
<if test="record.associatedTaskId != null">
associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -533,8 +523,7 @@
script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR},
waiting_time = #{record.waitingTime,jdbcType=BIGINT},
exec_status = #{record.execStatus,jdbcType=VARCHAR},
`plan` = #{record.plan,jdbcType=BIT},
associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR}
`plan` = #{record.plan,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -641,9 +630,6 @@
<if test="plan != null">
`plan` = #{plan,jdbcType=BIT},
</if>
<if test="associatedTaskId != null">
associated_task_id = #{associatedTaskId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -681,8 +667,7 @@
script_identifier = #{scriptIdentifier,jdbcType=VARCHAR},
waiting_time = #{waitingTime,jdbcType=BIGINT},
exec_status = #{execStatus,jdbcType=VARCHAR},
`plan` = #{plan,jdbcType=BIT},
associated_task_id = #{associatedTaskId,jdbcType=VARCHAR}
`plan` = #{plan,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
@ -692,7 +677,7 @@
run_mode, pool_id, integrated, project_id, environment_id, error_count, fake_error_count,
pending_count, success_count, assertion_count, assertion_success_count, request_error_rate,
request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate,
script_identifier, waiting_time, exec_status, `plan`, associated_task_id)
script_identifier, waiting_time, exec_status, `plan`)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanScenarioId,jdbcType=VARCHAR},
@ -707,8 +692,7 @@
#{item.requestPendingRate,jdbcType=VARCHAR}, #{item.requestFakeErrorRate,jdbcType=VARCHAR},
#{item.requestPassRate,jdbcType=VARCHAR}, #{item.assertionPassRate,jdbcType=VARCHAR},
#{item.scriptIdentifier,jdbcType=VARCHAR}, #{item.waitingTime,jdbcType=BIGINT},
#{item.execStatus,jdbcType=VARCHAR}, #{item.plan,jdbcType=BIT}, #{item.associatedTaskId,jdbcType=VARCHAR}
)
#{item.execStatus,jdbcType=VARCHAR}, #{item.plan,jdbcType=BIT})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -823,9 +807,6 @@
<if test="'plan'.toString() == column.value">
#{item.plan,jdbcType=BIT}
</if>
<if test="'associated_task_id'.toString() == column.value">
#{item.associatedTaskId,jdbcType=VARCHAR}
</if>
</foreach>
)
</foreach>

View File

@ -8,7 +8,7 @@ CREATE TABLE IF NOT EXISTS exec_task(
`task_name` VARCHAR(255) NOT NULL COMMENT '任务名称' ,
`status` VARCHAR(20) NOT NULL COMMENT '状态' ,
`case_count` BIGINT NOT NULL COMMENT '用例数量' ,
`result` VARCHAR(64) NOT NULL DEFAULT 'PENDING' COMMENT '执行结果' ,
`result` VARCHAR(20) NOT NULL DEFAULT 'PENDING' COMMENT '执行结果' ,
`task_type` VARCHAR(50) NOT NULL COMMENT '任务类型' ,
`resource_id` VARCHAR(50) COMMENT '测试计划id/测试计划组id' ,
`trigger_mode` VARCHAR(20) NOT NULL COMMENT '执行模式' ,
@ -43,7 +43,7 @@ CREATE TABLE IF NOT EXISTS exec_task_item(
`resource_name` VARCHAR(255) NOT NULL COMMENT '资源名称' ,
`task_origin` VARCHAR(50) COMMENT '任务来源任务组下的任务id' ,
`status` VARCHAR(20) NOT NULL COMMENT '执行状态' ,
`result` VARCHAR(255) NOT NULL DEFAULT 'PENDING' COMMENT '执行结果' ,
`result` VARCHAR(20) NOT NULL DEFAULT 'PENDING' COMMENT '执行结果' ,
`resource_pool_id` VARCHAR(50) NOT NULL COMMENT '资源池ID' ,
`resource_pool_node` VARCHAR(50) COMMENT '节点' ,
`resource_type` VARCHAR(50) NOT NULL COMMENT '资源类型' ,
@ -99,9 +99,14 @@ CREATE TABLE api_doc_share (
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = '接口文档分享';
ALTER TABLE api_report ADD COLUMN associated_task_id VARCHAR(50) COMMENT '关联任务id(集合报告)/任务项id';
ALTER TABLE api_scenario_report ADD COLUMN associated_task_id VARCHAR(50) COMMENT '关联任务id(集合报告)/任务项id';
-- 报告与任务关联表
CREATE TABLE IF NOT EXISTS api_report_relate_task(
`task_resource_id` VARCHAR(50) NOT NULL COMMENT '任务id/任务项id' ,
`report_id` VARCHAR(50) NOT NULL COMMENT '报告id' ,
PRIMARY KEY (task_resource_id,report_id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = '报告与任务关联表';
-- set innodb lock wait timeout to default
SET SESSION innodb_lock_wait_timeout = DEFAULT;

View File

@ -108,7 +108,7 @@ public class BaseTaskHubService {
return;
}
List<String> projectIds = list.stream().map(TaskHubDTO::getProjectId).distinct().toList();
List<String> organizationIds = list.stream().map(TaskHubDTO::getProjectId).distinct().toList();
List<String> organizationIds = list.stream().map(TaskHubDTO::getOrganizationId).distinct().toList();
List<String> userIds = list.stream().map(TaskHubDTO::getCreateUser).distinct().toList();
Map<String, String> projectMaps = getProjectMaps(projectIds);
Map<String, String> organizationMaps = getOrganizationMaps(organizationIds);