Merge remote-tracking branch 'origin/master'

This commit is contained in:
Captain.B 2021-03-22 18:24:01 +08:00
commit a1fd1af3f5
12 changed files with 328 additions and 294 deletions

View File

@ -1,18 +1,19 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class TestCaseTest implements Serializable {
private String id;
private String testCaseId;
private String testId;
private String testType;
private Long createTime;
private Long updateTime;
private static final long serialVersionUID = 1L;
}

View File

@ -104,76 +104,6 @@ public class TestCaseTestExample {
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTestCaseIdIsNull() {
addCriterion("test_case_id is null");
return (Criteria) this;
@ -383,6 +313,126 @@ public class TestCaseTestExample {
addCriterion("test_type not between", value1, value2, "testType");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Long value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Long value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Long value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Long value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -2,30 +2,21 @@ package io.metersphere.base.mapper;
import io.metersphere.base.domain.TestCaseTest;
import io.metersphere.base.domain.TestCaseTestExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TestCaseTestMapper {
long countByExample(TestCaseTestExample example);
int deleteByExample(TestCaseTestExample example);
int deleteByPrimaryKey(String id);
int insert(TestCaseTest record);
int insertSelective(TestCaseTest record);
List<TestCaseTest> selectByExample(TestCaseTestExample example);
TestCaseTest selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") TestCaseTest record, @Param("example") TestCaseTestExample example);
int updateByExample(@Param("record") TestCaseTest record, @Param("example") TestCaseTestExample example);
int updateByPrimaryKeySelective(TestCaseTest record);
int updateByPrimaryKey(TestCaseTest record);
}

View File

@ -2,10 +2,11 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.TestCaseTestMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestCaseTest">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="test_case_id" jdbcType="VARCHAR" property="testCaseId" />
<result column="test_id" jdbcType="VARCHAR" property="testId" />
<result column="test_type" jdbcType="VARCHAR" property="testType" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -25,8 +26,7 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
@ -55,8 +55,7 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
@ -68,10 +67,9 @@
</where>
</sql>
<sql id="Base_Column_List">
id, test_case_id, test_id, test_type
test_case_id, test_id, test_type, create_time, update_time
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample"
resultMap="BaseResultMap">
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
@ -85,17 +83,6 @@
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from test_case_test
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete
from test_case_test
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample">
delete from test_case_test
<if test="_parameter != null">
@ -103,17 +90,14 @@
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestCaseTest">
insert into test_case_test (id, test_case_id, test_id,
test_type)
values (#{id,jdbcType=VARCHAR}, #{testCaseId,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR},
#{testType,jdbcType=VARCHAR})
insert into test_case_test (test_case_id, test_id, test_type,
create_time, update_time)
values (#{testCaseId,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{testType,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseTest">
insert into test_case_test
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="testCaseId != null">
test_case_id,
</if>
@ -123,11 +107,14 @@
<if test="testType != null">
test_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="testCaseId != null">
#{testCaseId,jdbcType=VARCHAR},
</if>
@ -137,10 +124,15 @@
<if test="testType != null">
#{testType,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample"
resultType="java.lang.Long">
<select id="countByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample" resultType="java.lang.Long">
select count(*) from test_case_test
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
@ -149,9 +141,6 @@
<update id="updateByExampleSelective" parameterType="map">
update test_case_test
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.testCaseId != null">
test_case_id = #{record.testCaseId,jdbcType=VARCHAR},
</if>
@ -161,6 +150,12 @@
<if test="record.testType != null">
test_type = #{record.testType,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -168,34 +163,13 @@
</update>
<update id="updateByExample" parameterType="map">
update test_case_test
set id = #{record.id,jdbcType=VARCHAR},
test_case_id = #{record.testCaseId,jdbcType=VARCHAR},
set test_case_id = #{record.testCaseId,jdbcType=VARCHAR},
test_id = #{record.testId,jdbcType=VARCHAR},
test_type = #{record.testType,jdbcType=VARCHAR}
test_type = #{record.testType,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestCaseTest">
update test_case_test
<set>
<if test="testCaseId != null">
test_case_id = #{testCaseId,jdbcType=VARCHAR},
</if>
<if test="testId != null">
test_id = #{testId,jdbcType=VARCHAR},
</if>
<if test="testType != null">
test_type = #{testType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestCaseTest">
update test_case_test
set test_case_id = #{testCaseId,jdbcType=VARCHAR},
test_id = #{testId,jdbcType=VARCHAR},
test_type = #{testType,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -65,7 +65,7 @@ public interface ExtTestCaseMapper {
long countRelevanceCreatedThisWeek(@Param("projectId") String projectId,@Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
List<TrackCountResult> countCoverage(@Param("projectId") String projectId);
int countCoverage(@Param("projectId") String projectId);
List<TrackCountResult> countFuncMaintainer(@Param("projectId") String projectId);

View File

@ -343,17 +343,19 @@
</select>
<select id="countRelevance" resultType="io.metersphere.track.response.TrackCountResult">
SELECT type AS groupField, count(id) AS countNumber FROM test_case WHERE test_case.project_id = #{projectId} GROUP BY test_case.type
SELECT test_case_test.test_type AS groupField, count(test_case_test.test_case_id) AS countNumber
FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id
WHERE test_case.project_id = #{projectId} GROUP BY test_case_test.test_type
</select>
<select id="countRelevanceCreatedThisWeek" resultType="java.lang.Long">
SELECT count(id) AS countNumber FROM test_case WHERE test_case.project_id = #{projectId}
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
SELECT count(distinct test_case_test.test_case_id) AS countNumber FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id
WHERE test_case.project_id = #{projectId}
AND test_case_test.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select>
<select id="countCoverage" resultType="io.metersphere.track.response.TrackCountResult">
SELECT count(test_case.id) AS countNumber,
if(test_case.test_id is null,"uncoverage","coverage") AS groupField
FROM test_case WHERE test_case.project_id=#{projectId} and test_case.type != 'functional' GROUP BY groupField
<select id="countCoverage" resultType="int">
select count(test_case.id) from test_case where test_case.project_id = #{projectId}
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
</select>
<select id="countFuncMaintainer" resultType="io.metersphere.track.response.TrackCountResult">
select count(tc.id) as countNumber, user.name as groupField from test_case tc right join user on tc.maintainer = user.id
@ -362,7 +364,7 @@
</select>
<select id="countRelevanceMaintainer" resultType="io.metersphere.track.response.TrackCountResult">
select count(tc.id) as countNumber, user.name as groupField from test_case tc right join user on tc.maintainer = user.id
where tc.project_id = #{projectId} and tc.test_id is not null
where tc.project_id = #{projectId} and tc.id in (select distinct test_case_test.test_case_id from test_case_test)
group by tc.maintainer
</select>
<select id="getTestPlanBug" resultType="int">

View File

@ -1,11 +1,13 @@
package io.metersphere.track.controller;
import io.metersphere.base.domain.TestCase;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.performance.base.ChartsData;
import io.metersphere.track.response.BugStatustics;
import io.metersphere.track.response.TrackCountResult;
import io.metersphere.track.response.TrackStatisticsDTO;
import io.metersphere.track.service.TestCaseService;
import io.metersphere.track.service.TrackService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
@ -25,6 +27,8 @@ public class TrackController {
@Resource
private TrackService trackService;
@Resource
private TestCaseService testCaseService;
@GetMapping("/count/{projectId}")
public TrackStatisticsDTO getTrackCount(@PathVariable String projectId) {
@ -63,10 +67,11 @@ public class TrackController {
long size = trackService.countRelevanceCreatedThisWeek(projectId);
statistics.setThisWeekAddedCount(size);
List<TrackCountResult> coverageResults = trackService.countCoverage(projectId);
statistics.countCoverage(coverageResults);
long total = statistics.getUncoverageCount() + statistics.getCoverageCount();
List<TestCase> list = testCaseService.getTestCaseByProjectId(projectId);
long total = list.size();
int coverage = trackService.countCoverage(projectId);
statistics.setCoverageCount(coverage);
statistics.setUncoverageCount(total - coverage);
if (total != 0) {
float coverageRageNumber = (float) statistics.getCoverageCount() * 100 / total;

View File

@ -664,8 +664,9 @@ public class TestCaseService {
selecteds.forEach(id -> {
test.setTestType(id.get(0));
test.setTestId(id.get(1));
test.setId(UUID.randomUUID().toString());
test.setTestCaseId(request.getId());
test.setCreateTime(System.currentTimeMillis());
test.setUpdateTime(System.currentTimeMillis());
testCaseTestMapper.insert(test);
});
}
@ -707,7 +708,8 @@ public class TestCaseService {
selecteds.forEach(id -> {
test.setTestType(id.get(0));
test.setTestId(id.get(1));
test.setId(UUID.randomUUID().toString());
test.setCreateTime(System.currentTimeMillis());
test.setUpdateTime(System.currentTimeMillis());
test.setTestCaseId(request.getId());
testCaseTestMapper.insert(test);
});
@ -779,4 +781,10 @@ public class TestCaseService {
}
});
}
public List<TestCase> getTestCaseByProjectId(String projectId) {
TestCaseExample example = new TestCaseExample();
example.createCriteria().andProjectIdEqualTo(projectId);
return testCaseMapper.selectByExample(example);
}
}

View File

@ -80,7 +80,7 @@ public class TrackService {
}
}
public List<TrackCountResult> countCoverage(String projectId) {
public int countCoverage(String projectId) {
return extTestCaseMapper.countCoverage(projectId);
}

View File

@ -185,6 +185,8 @@ create table test_case_test
test_case_id varchar(70) null,
test_id varchar(70) null,
test_type varchar(70) null,
create_time bigint(13) null,
update_time bigint(13) null,
constraint test_case_test_pk
primary key (id)
) ENGINE = InnoDB

View File

@ -8,7 +8,8 @@
<env-select :project-ids="projectIds" :env-map="envMap" @close="visible = false"
ref="envSelect" @setProjectEnvMap="setProjectEnvMap" :project-list="projectList"/>
<el-button type="primary" slot="reference" size="mini" style="margin-top: 2px;">
环境配置<i class="el-icon-caret-bottom el-icon--right"></i>
{{ $t('api_test.definition.request.run_env') }}
<i class="el-icon-caret-bottom el-icon--right"></i>
</el-button>
</el-popover>
</template>

@ -1 +1 @@
Subproject commit 3dbd5a3d7ec96a10e11d817cdec25832986af1d2
Subproject commit f63ebb68ebad78de42fd711f17e2671e34577a86