增加创建人列

This commit is contained in:
q4speed 2020-05-22 13:25:16 +08:00
parent 601e329f0d
commit 44cfaf811a
19 changed files with 227 additions and 33 deletions

View File

@ -1,7 +1,6 @@
package io.metersphere.api.dto;
import io.metersphere.base.domain.ApiTestReport;
import io.metersphere.base.domain.ApiTestWithBLOBs;
import lombok.Getter;
import lombok.Setter;
@ -12,4 +11,6 @@ public class APIReportResult extends ApiTestReport {
private String testName;
private String projectName;
private String userName;
}

View File

@ -9,4 +9,6 @@ import lombok.Setter;
public class APITestResult extends ApiTestWithBLOBs {
private String projectName;
private String userName;
}

View File

@ -12,6 +12,7 @@ import io.metersphere.base.mapper.ApiTestReportMapper;
import io.metersphere.base.mapper.ext.ExtApiTestReportMapper;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.DashboardTestDTO;
import io.metersphere.i18n.Translator;
import org.springframework.stereotype.Service;
@ -20,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import javax.annotation.Resource;
@ -84,6 +86,7 @@ public class APIReportService {
report.setCreateTime(System.currentTimeMillis());
report.setUpdateTime(System.currentTimeMillis());
report.setStatus(APITestStatus.Running.name());
report.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
apiTestReportMapper.insert(report);
return report.getId();

View File

@ -11,6 +11,7 @@ import io.metersphere.base.mapper.ApiTestMapper;
import io.metersphere.base.mapper.ext.ExtApiTestMapper;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.i18n.Translator;
import io.metersphere.service.FileService;
import org.springframework.stereotype.Service;
@ -21,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.annotation.Resource;
@ -126,6 +128,7 @@ public class APITestService {
test.setCreateTime(System.currentTimeMillis());
test.setUpdateTime(System.currentTimeMillis());
test.setStatus(APITestStatus.Saved.name());
test.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
apiTestMapper.insert(test);
return test;
}

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class ApiTest implements Serializable {
@ -16,6 +15,8 @@ public class ApiTest implements Serializable {
private String status;
private String userId;
private Long createTime;
private Long updateTime;

View File

@ -454,6 +454,76 @@ public class ApiTestExample {
return (Criteria) this;
}
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
}
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
return (Criteria) this;
}
public Criteria andUserIdEqualTo(String value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotEqualTo(String value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThan(String value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThanOrEqualTo(String value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThan(String value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThanOrEqualTo(String value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLike(String value) {
addCriterion("user_id like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotLike(String value) {
addCriterion("user_id not like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdIn(List<String> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<String> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdBetween(String value1, String value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotBetween(String value1, String value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class ApiTestReport implements Serializable {
@ -20,6 +19,8 @@ public class ApiTestReport implements Serializable {
private String status;
private String userId;
private String content;
private static final long serialVersionUID = 1L;

View File

@ -573,6 +573,76 @@ public class ApiTestReportExample {
addCriterion("status not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
}
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
return (Criteria) this;
}
public Criteria andUserIdEqualTo(String value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotEqualTo(String value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThan(String value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThanOrEqualTo(String value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThan(String value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThanOrEqualTo(String value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLike(String value) {
addCriterion("user_id like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotLike(String value) {
addCriterion("user_id not like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdIn(List<String> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<String> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdBetween(String value1, String value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotBetween(String value1, String value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -1,11 +1,10 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)

View File

@ -7,6 +7,7 @@
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap>
@ -73,7 +74,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, project_id, name, description, status, create_time, update_time
id, project_id, name, description, status, user_id, create_time, update_time
</sql>
<sql id="Blob_Column_List">
scenario_definition, schedule
@ -128,13 +129,13 @@
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.ApiTestWithBLOBs">
insert into api_test (id, project_id, name,
description, status, create_time,
update_time, scenario_definition, schedule
)
description, status, user_id,
create_time, update_time, scenario_definition,
schedule)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{scenarioDefinition,jdbcType=LONGVARCHAR}, #{schedule,jdbcType=LONGVARCHAR}
)
#{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{scenarioDefinition,jdbcType=LONGVARCHAR},
#{schedule,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestWithBLOBs">
insert into api_test
@ -154,6 +155,9 @@
<if test="status != null">
status,
</if>
<if test="userId != null">
user_id,
</if>
<if test="createTime != null">
create_time,
</if>
@ -183,6 +187,9 @@
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
@ -221,6 +228,9 @@
<if test="record.status != null">
status = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
@ -245,6 +255,7 @@
name = #{record.name,jdbcType=VARCHAR},
description = #{record.description,jdbcType=VARCHAR},
status = #{record.status,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
@ -260,6 +271,7 @@
name = #{record.name,jdbcType=VARCHAR},
description = #{record.description,jdbcType=VARCHAR},
status = #{record.status,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}
<if test="_parameter != null">
@ -281,6 +293,9 @@
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
@ -302,6 +317,7 @@
name = #{name,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
@ -314,6 +330,7 @@
name = #{name,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}

View File

@ -9,6 +9,7 @@
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestReport">
<result column="content" jdbcType="LONGVARCHAR" property="content" />
@ -72,7 +73,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, test_id, name, description, create_time, update_time, status
id, test_id, name, description, create_time, update_time, status, user_id
</sql>
<sql id="Blob_Column_List">
content
@ -128,10 +129,12 @@
<insert id="insert" parameterType="io.metersphere.base.domain.ApiTestReport">
insert into api_test_report (id, test_id, name,
description, create_time, update_time,
status, content)
status, user_id, content
)
values (#{id,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{status,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR})
#{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestReport">
insert into api_test_report
@ -157,6 +160,9 @@
<if test="status != null">
status,
</if>
<if test="userId != null">
user_id,
</if>
<if test="content != null">
content,
</if>
@ -183,6 +189,9 @@
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
@ -218,6 +227,9 @@
<if test="record.status != null">
status = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
@ -235,6 +247,7 @@
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
status = #{record.status,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -248,7 +261,8 @@
description = #{record.description,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
status = #{record.status,jdbcType=VARCHAR}
status = #{record.status,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -274,6 +288,9 @@
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
@ -288,6 +305,7 @@
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
status = #{status,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
@ -298,7 +316,8 @@
description = #{description,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
status = #{status,jdbcType=VARCHAR}
status = #{status,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -5,12 +5,14 @@
<resultMap id="BaseResultMap" type="io.metersphere.api.dto.APITestResult"
extends="io.metersphere.base.mapper.ApiTestMapper.BaseResultMap">
<result column="project_name" property="projectName"/>
<result column="user_name" property="userName"/>
</resultMap>
<select id="list" resultMap="BaseResultMap" parameterType="io.metersphere.api.dto.APITestResult">
select api_test.*, project.name as project_name
select api_test.*, project.name as project_name, user.name as user_name
from api_test
left join project on api_test.project_id = project.id
left join user on api_test.user_id = user.id
<where>
<if test="request.name != null">
and api_test.name like CONCAT('%', #{request.name},'%')

View File

@ -6,14 +6,16 @@
extends="io.metersphere.base.mapper.ApiTestReportMapper.BaseResultMap">
<result column="test_name" property="testName"/>
<result column="project_name" property="projectName"/>
<result column="user_name" property="userName"/>
</resultMap>
<select id="list" resultMap="BaseResultMap">
SELECT t.name AS test_name,
r.name, r.description, r.id, r.test_id, r.create_time, r.update_time, r.status,
project.name AS project_name
project.name AS project_name, user.name AS user_name
FROM api_test_report r JOIN api_test t ON r.test_id = t.id
JOIN project ON project.id = t.project_id
LEFT JOIN project ON project.id = t.project_id
LEFT JOIN user ON user.id = r.user_id
<where>
<if test="request.name != null">
AND r.name like CONCAT('%', #{request.name},'%')
@ -31,9 +33,10 @@
<select id="listByTestId" resultMap="BaseResultMap">
SELECT t.name AS test_name,
r.name, r.description, r.id, r.test_id, r.create_time, r.update_time, r.status,
project.name AS project_name
project.name AS project_name, user.name AS user_name
FROM api_test_report r JOIN api_test t ON r.test_id = t.id
JOIN project ON project.id = t.project_id
LEFT JOIN project ON project.id = t.project_id
LEFT JOIN user ON user.id = r.user_id
<where>
r.test_id = #{testId}
</where>
@ -41,9 +44,10 @@
</select>
<select id="get" resultMap="BaseResultMap">
SELECT r.*, t.name AS test_name, project.name AS project_name
SELECT r.*, t.name AS test_name, project.name AS project_name, user.name AS user_name
FROM api_test_report r JOIN api_test t ON r.test_id = t.id
JOIN project ON project.id = t.project_id
LEFT JOIN user ON user.id = r.user_id
<where>
r.id = #{id}
</where>

View File

@ -216,7 +216,8 @@ CREATE TABLE IF NOT EXISTS `api_test` (
`description` varchar(255) DEFAULT NULL COMMENT 'Test description',
`scenario_definition` longtext COMMENT 'Scenario definition (JSON format)',
`schedule` longtext COMMENT 'Test schedule (cron list)',
`status` varchar(64) DEFAULT NULL,
`status` varchar(64) DEFAULT NULL COMMENT 'Status of this test',
`user_id` varchar(64) DEFAULT NULL COMMENT 'User ID',
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
PRIMARY KEY (`id`)
@ -239,6 +240,7 @@ CREATE TABLE IF NOT EXISTS `api_test_report` (
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
`status` varchar(64) NOT NULL COMMENT 'Status of this test run',
`user_id` varchar(64) DEFAULT NULL COMMENT 'User ID',
PRIMARY KEY (`id`)
)
ENGINE = InnoDB

View File

@ -13,16 +13,13 @@
</template>
</el-table-column>
<el-table-column prop="testName" :label="$t('api_report.test_name')" width="200" show-overflow-tooltip/>
<el-table-column prop="projectName" :label="$t('load_test.project_name')" width="150" show-overflow-tooltip/>
<el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/>
<el-table-column width="250" :label="$t('commons.create_time')">
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column width="250" :label="$t('commons.update_time')">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column prop="status" :label="$t('commons.status')">
<template v-slot:default="{row}">
<ms-api-report-status :row="row"/>

View File

@ -12,8 +12,8 @@
<el-link type="info" @click="handleEdit(scope.row)">{{ scope.row.name }}</el-link>
</template>
</el-table-column>
<el-table-column prop="projectName" :label="$t('load_test.project_name')" width="150" show-overflow-tooltip>
</el-table-column>
<el-table-column prop="projectName" :label="$t('load_test.project_name')" width="150" show-overflow-tooltip/>
<el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/>
<el-table-column width="250" :label="$t('commons.create_time')">
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>

View File

@ -241,6 +241,7 @@ export default {
'download_log_file': 'Download',
},
api_test: {
creator: "Creator",
title: "Test",
save_and_run: "Save and Run",
run: "Run",

View File

@ -239,6 +239,7 @@ export default {
'pressure_prediction_chart': '压力预估图',
},
api_test: {
creator: "创建人",
save_and_run: "保存并执行",
run: "执行",
running: "正在执行",

View File

@ -244,6 +244,7 @@ export default {
key: "鍵",
value: "值",
scenario: {
creator: "創建人",
config: "場景配寘",
input_name: "請輸入場景名稱",
name: "場景名稱",