fix: 解决冲突

This commit is contained in:
chenjianxing 2021-01-20 11:51:27 +08:00
commit deb0a636d9
11 changed files with 222 additions and 127 deletions

View File

@ -6,6 +6,7 @@ import io.metersphere.api.dto.definition.request.ParameterConfig;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.extractor.JSR223PostProcessor; import org.apache.jmeter.extractor.JSR223PostProcessor;
import org.apache.jmeter.extractor.RegexExtractor; import org.apache.jmeter.extractor.RegexExtractor;
import org.apache.jmeter.extractor.XPath2Extractor; import org.apache.jmeter.extractor.XPath2Extractor;
@ -57,6 +58,8 @@ public class MsExtract extends MsTestElement {
JSR223PostProcessor shell = new JSR223PostProcessor(); JSR223PostProcessor shell = new JSR223PostProcessor();
shell.setEnabled(true); shell.setEnabled(true);
shell.setName(this.getName()); shell.setName(this.getName());
shell.setProperty(TestElement.TEST_CLASS, JSR223PostProcessor.class.getName());
shell.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
shell.setProperty("script", "io.metersphere.api.jmeter.JMeterVars.addVars(prev.hashCode(),vars," + "\"" + extract.toString() + "\"" + ");"); shell.setProperty("script", "io.metersphere.api.jmeter.JMeterVars.addVars(prev.hashCode(),vars," + "\"" + extract.toString() + "\"" + ");");
samplerHashTree.add(shell); samplerHashTree.add(shell);
} }

View File

@ -5,8 +5,10 @@ import io.metersphere.api.dto.datacount.ExecutedCaseInfoResult;
import io.metersphere.api.jmeter.TestResult; import io.metersphere.api.jmeter.TestResult;
import io.metersphere.base.domain.ApiDefinitionExecResult; import io.metersphere.base.domain.ApiDefinitionExecResult;
import io.metersphere.base.domain.ApiDefinitionExecResultExample; import io.metersphere.base.domain.ApiDefinitionExecResultExample;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import io.metersphere.base.domain.TestPlanApiCase; import io.metersphere.base.domain.TestPlanApiCase;
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.utils.DateUtils; import io.metersphere.commons.utils.DateUtils;
@ -15,15 +17,15 @@ import io.metersphere.track.dto.TestPlanDTO;
import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.service.TestPlanApiCaseService; import io.metersphere.track.service.TestPlanApiCaseService;
import io.metersphere.track.service.TestPlanService; import io.metersphere.track.service.TestPlanService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; 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.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.*; import java.util.*;
@Service @Service
@ -37,9 +39,16 @@ public class ApiDefinitionExecResultService {
private TestPlanApiCaseService testPlanApiCaseService; private TestPlanApiCaseService testPlanApiCaseService;
@Resource @Resource
private TestPlanService testPlanService; private TestPlanService testPlanService;
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
SqlSessionFactory sqlSessionFactory;
public void saveApiResult(TestResult result, String type) { public void saveApiResult(TestResult result, String type) {
if (CollectionUtils.isNotEmpty(result.getScenarios())) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiDefinitionExecResultMapper definitionExecResultMapper = sqlSession.getMapper(ApiDefinitionExecResultMapper.class);
result.getScenarios().get(0).getRequestResults().forEach(item -> { result.getScenarios().get(0).getRequestResults().forEach(item -> {
ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult(); ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult();
saveResult.setId(UUID.randomUUID().toString()); saveResult.setId(UUID.randomUUID().toString());
@ -56,13 +65,22 @@ public class ApiDefinitionExecResultService {
if (StringUtils.equals(type, ApiRunMode.API_PLAN.name())) { if (StringUtils.equals(type, ApiRunMode.API_PLAN.name())) {
testPlanApiCaseService.setExecResult(item.getName(), status); testPlanApiCaseService.setExecResult(item.getName(), status);
} }
apiDefinitionExecResultMapper.insert(saveResult); // 更新用例最后执行结果
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = new ApiTestCaseWithBLOBs();
apiTestCaseWithBLOBs.setId(saveResult.getResourceId());
apiTestCaseWithBLOBs.setLastResultId(saveResult.getId());
apiTestCaseMapper.updateByPrimaryKeySelective(apiTestCaseWithBLOBs);
definitionExecResultMapper.insert(saveResult);
}); });
sqlSession.flushStatements();
}
} }
/** /**
* 定时任务触发的保存逻辑 * 定时任务触发的保存逻辑
* 定时任务时userID要改为定时任务中的用户 * 定时任务时userID要改为定时任务中的用户
*
* @param result * @param result
* @param type * @param type
*/ */

View File

@ -222,7 +222,6 @@ public class ApiTestCaseService {
test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
test.setProjectId(request.getProjectId()); test.setProjectId(request.getProjectId());
test.setRequest(JSONObject.toJSONString(request.getRequest())); test.setRequest(JSONObject.toJSONString(request.getRequest()));
test.setResponse(JSONObject.toJSONString(request.getResponse()));
test.setPriority(request.getPriority()); test.setPriority(request.getPriority());
test.setUpdateTime(System.currentTimeMillis()); test.setUpdateTime(System.currentTimeMillis());
test.setDescription(request.getDescription()); test.setDescription(request.getDescription());
@ -242,7 +241,6 @@ public class ApiTestCaseService {
test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
test.setProjectId(request.getProjectId()); test.setProjectId(request.getProjectId());
test.setRequest(JSONObject.toJSONString(request.getRequest())); test.setRequest(JSONObject.toJSONString(request.getRequest()));
test.setResponse(JSONObject.toJSONString(request.getResponse()));
test.setCreateTime(System.currentTimeMillis()); test.setCreateTime(System.currentTimeMillis());
test.setPriority(request.getPriority()); test.setPriority(request.getPriority());
test.setUpdateTime(System.currentTimeMillis()); test.setUpdateTime(System.currentTimeMillis());
@ -449,6 +447,7 @@ public class ApiTestCaseService {
} }
return request.getReportId(); return request.getReportId();
} }
public String run(ApiTestCaseWithBLOBs apiCaseBolbs, String id, String debugReportId, String testPlanID, String runMode) { public String run(ApiTestCaseWithBLOBs apiCaseBolbs, String id, String debugReportId, String testPlanID, String runMode) {
// 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取 // 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取
if (apiCaseBolbs != null && StringUtils.isNotEmpty(apiCaseBolbs.getRequest())) { if (apiCaseBolbs != null && StringUtils.isNotEmpty(apiCaseBolbs.getRequest())) {
@ -467,6 +466,7 @@ public class ApiTestCaseService {
} }
return id; return id;
} }
public HashTree generateHashTree(RunCaseRequest request, ApiTestCaseWithBLOBs testCaseWithBLOBs) throws Exception { public HashTree generateHashTree(RunCaseRequest request, ApiTestCaseWithBLOBs testCaseWithBLOBs) throws Exception {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

View File

@ -28,5 +28,7 @@ public class ApiTestCase implements Serializable {
private String tags; private String tags;
private String lastResultId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -843,6 +843,76 @@ public class ApiTestCaseExample {
addCriterion("tags not between", value1, value2, "tags"); addCriterion("tags not between", value1, value2, "tags");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andLastResultIdIsNull() {
addCriterion("last_result_id is null");
return (Criteria) this;
}
public Criteria andLastResultIdIsNotNull() {
addCriterion("last_result_id is not null");
return (Criteria) this;
}
public Criteria andLastResultIdEqualTo(String value) {
addCriterion("last_result_id =", value, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdNotEqualTo(String value) {
addCriterion("last_result_id <>", value, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdGreaterThan(String value) {
addCriterion("last_result_id >", value, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdGreaterThanOrEqualTo(String value) {
addCriterion("last_result_id >=", value, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdLessThan(String value) {
addCriterion("last_result_id <", value, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdLessThanOrEqualTo(String value) {
addCriterion("last_result_id <=", value, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdLike(String value) {
addCriterion("last_result_id like", value, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdNotLike(String value) {
addCriterion("last_result_id not like", value, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdIn(List<String> values) {
addCriterion("last_result_id in", values, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdNotIn(List<String> values) {
addCriterion("last_result_id not in", values, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdBetween(String value1, String value2) {
addCriterion("last_result_id between", value1, value2, "lastResultId");
return (Criteria) this;
}
public Criteria andLastResultIdNotBetween(String value1, String value2) {
addCriterion("last_result_id not between", value1, value2, "lastResultId");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -13,7 +13,5 @@ public class ApiTestCaseWithBLOBs extends ApiTestCase implements Serializable {
private String request; private String request;
private String response;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -13,11 +13,11 @@
<result column="update_time" jdbcType="BIGINT" property="updateTime" /> <result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="num" jdbcType="INTEGER" property="num" /> <result column="num" jdbcType="INTEGER" property="num" />
<result column="tags" jdbcType="VARCHAR" property="tags" /> <result column="tags" jdbcType="VARCHAR" property="tags" />
<result column="last_result_id" jdbcType="VARCHAR" property="lastResultId" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestCaseWithBLOBs"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
<result column="description" jdbcType="LONGVARCHAR" property="description" /> <result column="description" jdbcType="LONGVARCHAR" property="description" />
<result column="request" jdbcType="LONGVARCHAR" property="request" /> <result column="request" jdbcType="LONGVARCHAR" property="request" />
<result column="response" jdbcType="LONGVARCHAR" property="response" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -79,10 +79,10 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, project_id, `name`, priority, api_definition_id, create_user_id, update_user_id, id, project_id, `name`, priority, api_definition_id, create_user_id, update_user_id,
create_time, update_time, num, tags create_time, update_time, num, tags, last_result_id
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
description, request, response description, request
</sql> </sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestCaseExample" resultMap="ResultMapWithBLOBs"> <select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestCaseExample" resultMap="ResultMapWithBLOBs">
select select
@ -136,13 +136,13 @@
insert into api_test_case (id, project_id, `name`, insert into api_test_case (id, project_id, `name`,
priority, api_definition_id, create_user_id, priority, api_definition_id, create_user_id,
update_user_id, create_time, update_time, update_user_id, create_time, update_time,
num, tags, description, num, tags, last_result_id,
request, response) description, request)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{priority,jdbcType=VARCHAR}, #{apiDefinitionId,jdbcType=VARCHAR}, #{createUserId,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, #{apiDefinitionId,jdbcType=VARCHAR}, #{createUserId,jdbcType=VARCHAR},
#{updateUserId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{updateUserId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{num,jdbcType=INTEGER}, #{tags,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, #{num,jdbcType=INTEGER}, #{tags,jdbcType=VARCHAR}, #{lastResultId,jdbcType=VARCHAR},
#{request,jdbcType=LONGVARCHAR}, #{response,jdbcType=LONGVARCHAR}) #{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestCaseWithBLOBs"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
insert into api_test_case insert into api_test_case
@ -180,15 +180,15 @@
<if test="tags != null"> <if test="tags != null">
tags, tags,
</if> </if>
<if test="lastResultId != null">
last_result_id,
</if>
<if test="description != null"> <if test="description != null">
description, description,
</if> </if>
<if test="request != null"> <if test="request != null">
request, request,
</if> </if>
<if test="response != null">
response,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -224,15 +224,15 @@
<if test="tags != null"> <if test="tags != null">
#{tags,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR},
</if> </if>
<if test="lastResultId != null">
#{lastResultId,jdbcType=VARCHAR},
</if>
<if test="description != null"> <if test="description != null">
#{description,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR},
</if> </if>
<if test="request != null"> <if test="request != null">
#{request,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR},
</if> </if>
<if test="response != null">
#{response,jdbcType=LONGVARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiTestCaseExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.base.domain.ApiTestCaseExample" resultType="java.lang.Long">
@ -277,15 +277,15 @@
<if test="record.tags != null"> <if test="record.tags != null">
tags = #{record.tags,jdbcType=VARCHAR}, tags = #{record.tags,jdbcType=VARCHAR},
</if> </if>
<if test="record.lastResultId != null">
last_result_id = #{record.lastResultId,jdbcType=VARCHAR},
</if>
<if test="record.description != null"> <if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR},
</if> </if>
<if test="record.request != null"> <if test="record.request != null">
request = #{record.request,jdbcType=LONGVARCHAR}, request = #{record.request,jdbcType=LONGVARCHAR},
</if> </if>
<if test="record.response != null">
response = #{record.response,jdbcType=LONGVARCHAR},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -304,9 +304,9 @@
update_time = #{record.updateTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT},
num = #{record.num,jdbcType=INTEGER}, num = #{record.num,jdbcType=INTEGER},
tags = #{record.tags,jdbcType=VARCHAR}, tags = #{record.tags,jdbcType=VARCHAR},
last_result_id = #{record.lastResultId,jdbcType=VARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR},
request = #{record.request,jdbcType=LONGVARCHAR}, request = #{record.request,jdbcType=LONGVARCHAR}
response = #{record.response,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -323,7 +323,8 @@
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT},
num = #{record.num,jdbcType=INTEGER}, num = #{record.num,jdbcType=INTEGER},
tags = #{record.tags,jdbcType=VARCHAR} tags = #{record.tags,jdbcType=VARCHAR},
last_result_id = #{record.lastResultId,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -361,15 +362,15 @@
<if test="tags != null"> <if test="tags != null">
tags = #{tags,jdbcType=VARCHAR}, tags = #{tags,jdbcType=VARCHAR},
</if> </if>
<if test="lastResultId != null">
last_result_id = #{lastResultId,jdbcType=VARCHAR},
</if>
<if test="description != null"> <if test="description != null">
description = #{description,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR},
</if> </if>
<if test="request != null"> <if test="request != null">
request = #{request,jdbcType=LONGVARCHAR}, request = #{request,jdbcType=LONGVARCHAR},
</if> </if>
<if test="response != null">
response = #{response,jdbcType=LONGVARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -385,9 +386,9 @@
update_time = #{updateTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT},
num = #{num,jdbcType=INTEGER}, num = #{num,jdbcType=INTEGER},
tags = #{tags,jdbcType=VARCHAR}, tags = #{tags,jdbcType=VARCHAR},
last_result_id = #{lastResultId,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR},
request = #{request,jdbcType=LONGVARCHAR}, request = #{request,jdbcType=LONGVARCHAR}
response = #{response,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiTestCase"> <update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiTestCase">
@ -401,7 +402,8 @@
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT},
num = #{num,jdbcType=INTEGER}, num = #{num,jdbcType=INTEGER},
tags = #{tags,jdbcType=VARCHAR} tags = #{tags,jdbcType=VARCHAR},
last_result_id = #{lastResultId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -15,7 +15,6 @@
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestCase"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestCase">
<result column="request" jdbcType="LONGVARCHAR" property="request"/> <result column="request" jdbcType="LONGVARCHAR" property="request"/>
<result column="response" jdbcType="LONGVARCHAR" property="response"/>
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -190,39 +189,18 @@
</sql> </sql>
<select id="list" resultType="io.metersphere.api.dto.definition.ApiTestCaseResult"> <select id="list" resultType="io.metersphere.api.dto.definition.ApiTestCaseResult">
select SELECT
atc.id, t1.*,
atc.project_id, t2.STATUS AS execResult,
atc.name, t2.create_time AS execTime,
atc.priority, u2.NAME AS createUser,
atc.api_definition_id, u1.NAME AS updateUser
u1.name as createUser , FROM
u2.name as updateUser, api_test_case t1
atc.description, LEFT JOIN api_definition_exec_result t2 ON t1.last_result_id = t2.id
atc.request, LEFT JOIN USER u1 ON t1.update_user_id = u1.id
atc.response, LEFT JOIN USER u2 ON t1.create_user_id = u2.id
atc.create_user_id, LEFT JOIN USER u3 ON t2.user_id = u3.id
atc.create_time,
atc.update_user_id,
atc.update_time,
atc.num,
atc.tags,
ader.status execResult,
ader.create_time execTime
from
api_test_case atc
left join user u1 on
atc.create_user_id = u1.id
left join user u2 on
atc.update_user_id = u2.id
left join (
select
max(create_time) create_time ,status ,id, resource_id
from
api_definition_exec_result
group by
resource_id) as ader
on atc.id = ader.resource_id
<where> <where>
<if test="request.combine != null"> <if test="request.combine != null">
<include refid="combine"> <include refid="combine">
@ -232,26 +210,26 @@
</if> </if>
<if test="request.name != null and request.name!=''"> <if test="request.name != null and request.name!=''">
and atc.name like CONCAT('%', #{request.name},'%') and t1.name like CONCAT('%', #{request.name},'%')
</if> </if>
<if test="request.id != null and request.id!=''"> <if test="request.id != null and request.id!=''">
AND atc.id = #{request.id} AND t1.id = #{request.id}
</if> </if>
<if test="request.priority != null and request.priority!=''"> <if test="request.priority != null and request.priority!=''">
AND atc.priority = #{request.priority} AND t1.priority = #{request.priority}
</if> </if>
<if test="request.projectId != null and request.projectId!=''"> <if test="request.projectId != null and request.projectId!=''">
AND atc.project_id = #{request.projectId} AND t1.project_id = #{request.projectId}
</if> </if>
<if test="request.apiDefinitionId != null and request.apiDefinitionId!=''"> <if test="request.apiDefinitionId != null and request.apiDefinitionId!=''">
AND atc.api_definition_id = #{request.apiDefinitionId} AND t1.api_definition_id = #{request.apiDefinitionId}
</if> </if>
</where> </where>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by
<foreach collection="request.orders" separator="," item="order"> <foreach collection="request.orders" separator="," item="order">
atc.${order.name} ${order.type} t1.${order.name} ${order.type}
</foreach> </foreach>
</if> </if>

View File

@ -0,0 +1,27 @@
ALTER TABLE api_test_case drop COLUMN response;
ALTER TABLE api_test_case add COLUMN last_result_id varchar(64) COMMENT 'Last ApiDefinitionExecResult ID';
UPDATE api_test_case tt
INNER JOIN (
SELECT
atc.id,
ader.id AS result_id
FROM
api_test_case atc
LEFT JOIN USER u1 ON atc.create_user_id = u1.id
LEFT JOIN USER u2 ON atc.update_user_id = u2.id
LEFT JOIN (
SELECT
max( create_time ) create_time,
STATUS,
id,
resource_id
FROM
api_definition_exec_result
GROUP BY
resource_id
) AS ader ON atc.id = ader.resource_id
) tc
SET tt.last_result_id = tc.result_id
WHERE
tt.id = tc.id;

View File

@ -1,5 +1,5 @@
<template> <template>
<input-tag v-model="data" placeholder="输入回车添加" class="ms-tag-input ms-input-div ms-input-tag-wrapper ms-input ms-input-remove"></input-tag> <input-tag v-model="data" placeholder="输入回车添加标签" class="ms-tag-input ms-input-div ms-input-tag-wrapper ms-input ms-input-remove"></input-tag>
</template> </template>
<script> <script>

View File

@ -2,9 +2,9 @@
<el-card style="margin-top: 5px" @click.native="selectTestCase(apiCase,$event)"> <el-card style="margin-top: 5px" @click.native="selectTestCase(apiCase,$event)">
<div @click="active(apiCase)"> <div @click="active(apiCase)">
<el-row> <el-row>
<el-col :span="4"> <el-col :span="5">
<el-checkbox v-model="apiCase.selected"/> <el-checkbox class="item-select" v-model="apiCase.selected"/>
<div class="el-step__icon is-text ms-api-col"> <div class="el-step__icon is-text ms-api-col">
<div class="el-step__icon-inner">{{ index + 1 }}</div> <div class="el-step__icon-inner">{{ index + 1 }}</div>
@ -39,9 +39,8 @@
</div> </div>
</el-col> </el-col>
<el-col class="tag-item" :span="4"> <el-col :span="4">
<span class="ms-api-label tag-label">{{ $t('commons.tag') }}</span> <ms-input-tag class="tag-item" :currentScenario="apiCase" ref="tag" @keyup.enter.native="saveTestCase(apiCase)"/>
<ms-input-tag :currentScenario="apiCase" ref="tag" @keyup.enter.native="saveTestCase(apiCase)"/>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
@ -74,6 +73,8 @@
<!-- 请求参数--> <!-- 请求参数-->
<el-collapse-transition> <el-collapse-transition>
<div v-if="apiCase.active"> <div v-if="apiCase.active">
<el-divider></el-divider>
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<ms-api-request-form :showScript="true" :is-read-only="isReadOnly" :headers="apiCase.request.headers " :request="apiCase.request" v-if="api.protocol==='HTTP'"/> <ms-api-request-form :showScript="true" :is-read-only="isReadOnly" :headers="apiCase.request.headers " :request="apiCase.request" v-if="api.protocol==='HTTP'"/>
@ -314,19 +315,15 @@
background: #EFF7FF; background: #EFF7FF;
} }
.ms-tag-input { .icon.is-active {
/*display: inline-block;*/ transform: rotate(90deg);
/*height: 32px;*/ }
/*box-sizing: border-box;*/
.item-select {
margin-right: 10px;
} }
.tag-item { .tag-item {
/*height: 30px;*/ margin-right: 30px;
/*line-height: 30px;*/
}
.tag-label {
/*height: 32px;*/
/*line-height: 32px;*/
} }
</style> </style>