提交 c4d6ec1f 编写于 作者: C chenjianxing

Merge branch 'dev' of https://github.com/fit2cloudrd/metersphere-server into dev

......@@ -63,7 +63,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
......
......@@ -12,10 +12,7 @@ import org.apache.jmeter.visualizers.backend.AbstractBackendListenerClient;
import org.apache.jmeter.visualizers.backend.BackendListenerContext;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
......@@ -72,6 +69,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
sampleResults.forEach(result -> {
String thread = StringUtils.substringBeforeLast(result.getThreadName(), " ");
String order = StringUtils.substringAfterLast(result.getThreadName(), " ");
String scenarioName = StringUtils.substringBefore(thread, SPLIT);
String scenarioId = StringUtils.substringAfter(thread, SPLIT);
ScenarioResult scenarioResult;
......@@ -79,6 +77,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
scenarioResult = new ScenarioResult();
scenarioResult.setId(scenarioId);
scenarioResult.setName(scenarioName);
scenarioResult.setOrder(StringUtils.substringBefore(order, "-"));
scenarios.put(scenarioId, scenarioResult);
} else {
scenarioResult = scenarios.get(scenarioId);
......@@ -88,8 +87,8 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
scenarioResult.addSuccess();
testResult.addSuccess();
} else {
scenarioResult.addError();
testResult.addError();
scenarioResult.addError(result.getErrorCount());
testResult.addError(result.getErrorCount());
}
RequestResult requestResult = getRequestResult(result);
......@@ -103,6 +102,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
scenarioResult.addTotalAssertions(requestResult.getTotalAssertions());
});
testResult.getScenarios().addAll(scenarios.values());
testResult.getScenarios().sort(Comparator.comparing(ScenarioResult::getOrder));
apiTestService.changeStatus(id, APITestStatus.Completed);
apiReportService.save(testResult);
});
......@@ -123,6 +123,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
requestResult.setRequestSize(result.getSentBytes());
requestResult.setTotalAssertions(result.getAssertionResults().length);
requestResult.setSuccess(result.isSuccessful());
requestResult.setError(result.getErrorCount());
ResponseResult responseResult = requestResult.getResponseResult();
responseResult.setBody(result.getResponseDataAsString());
......
......@@ -13,6 +13,8 @@ public class RequestResult {
private long requestSize;
private int error;
private boolean success;
private String headers;
......
......@@ -12,6 +12,8 @@ public class ScenarioResult {
private String name;
private String order;
private long responseTime;
private int error = 0;
......@@ -28,8 +30,8 @@ public class ScenarioResult {
this.responseTime += time;
}
public void addError() {
this.error++;
public void addError(int count) {
this.error += count;
}
public void addSuccess() {
......
......@@ -22,8 +22,8 @@ public class TestResult {
private final List<ScenarioResult> scenarios = new ArrayList<>();
public void addError() {
this.error++;
public void addError(int count) {
this.error += count;
}
public void addSuccess() {
......
......@@ -18,5 +18,7 @@ public class LoadTestReport implements Serializable {
private String status;
private String description;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package io.metersphere.base.domain;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.io.Serializable;
@Data
public class LoadTestReportDetail implements Serializable {
private String reportId;
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class LoadTestReportDetail extends LoadTestReportDetailKey implements Serializable {
private String content;
private static final long serialVersionUID = 1L;
......
......@@ -173,6 +173,66 @@ public class LoadTestReportDetailExample {
addCriterion("report_id not between", value1, value2, "reportId");
return (Criteria) this;
}
public Criteria andPartIsNull() {
addCriterion("part is null");
return (Criteria) this;
}
public Criteria andPartIsNotNull() {
addCriterion("part is not null");
return (Criteria) this;
}
public Criteria andPartEqualTo(Long value) {
addCriterion("part =", value, "part");
return (Criteria) this;
}
public Criteria andPartNotEqualTo(Long value) {
addCriterion("part <>", value, "part");
return (Criteria) this;
}
public Criteria andPartGreaterThan(Long value) {
addCriterion("part >", value, "part");
return (Criteria) this;
}
public Criteria andPartGreaterThanOrEqualTo(Long value) {
addCriterion("part >=", value, "part");
return (Criteria) this;
}
public Criteria andPartLessThan(Long value) {
addCriterion("part <", value, "part");
return (Criteria) this;
}
public Criteria andPartLessThanOrEqualTo(Long value) {
addCriterion("part <=", value, "part");
return (Criteria) this;
}
public Criteria andPartIn(List<Long> values) {
addCriterion("part in", values, "part");
return (Criteria) this;
}
public Criteria andPartNotIn(List<Long> values) {
addCriterion("part not in", values, "part");
return (Criteria) this;
}
public Criteria andPartBetween(Long value1, Long value2) {
addCriterion("part between", value1, value2, "part");
return (Criteria) this;
}
public Criteria andPartNotBetween(Long value1, Long value2) {
addCriterion("part not between", value1, value2, "part");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
......
package io.metersphere.base.domain;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class LoadTestReportWithBLOBs extends LoadTestReport implements Serializable {
private String description;
public class LoadTestReportDetailKey implements Serializable {
private String reportId;
private String content;
private Long part;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ public class LoadTestReportLog implements Serializable {
private String resourceId;
private Long part;
private String content;
private static final long serialVersionUID = 1L;
......
......@@ -313,6 +313,66 @@ public class LoadTestReportLogExample {
addCriterion("resource_id not between", value1, value2, "resourceId");
return (Criteria) this;
}
public Criteria andPartIsNull() {
addCriterion("part is null");
return (Criteria) this;
}
public Criteria andPartIsNotNull() {
addCriterion("part is not null");
return (Criteria) this;
}
public Criteria andPartEqualTo(Long value) {
addCriterion("part =", value, "part");
return (Criteria) this;
}
public Criteria andPartNotEqualTo(Long value) {
addCriterion("part <>", value, "part");
return (Criteria) this;
}
public Criteria andPartGreaterThan(Long value) {
addCriterion("part >", value, "part");
return (Criteria) this;
}
public Criteria andPartGreaterThanOrEqualTo(Long value) {
addCriterion("part >=", value, "part");
return (Criteria) this;
}
public Criteria andPartLessThan(Long value) {
addCriterion("part <", value, "part");
return (Criteria) this;
}
public Criteria andPartLessThanOrEqualTo(Long value) {
addCriterion("part <=", value, "part");
return (Criteria) this;
}
public Criteria andPartIn(List<Long> values) {
addCriterion("part in", values, "part");
return (Criteria) this;
}
public Criteria andPartNotIn(List<Long> values) {
addCriterion("part not in", values, "part");
return (Criteria) this;
}
public Criteria andPartBetween(Long value1, Long value2) {
addCriterion("part between", value1, value2, "part");
return (Criteria) this;
}
public Criteria andPartNotBetween(Long value1, Long value2) {
addCriterion("part not between", value1, value2, "part");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
......
......@@ -2,6 +2,7 @@ package io.metersphere.base.mapper;
import io.metersphere.base.domain.LoadTestReportDetail;
import io.metersphere.base.domain.LoadTestReportDetailExample;
import io.metersphere.base.domain.LoadTestReportDetailKey;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -11,7 +12,7 @@ public interface LoadTestReportDetailMapper {
int deleteByExample(LoadTestReportDetailExample example);
int deleteByPrimaryKey(String reportId);
int deleteByPrimaryKey(LoadTestReportDetailKey key);
int insert(LoadTestReportDetail record);
......@@ -21,7 +22,7 @@ public interface LoadTestReportDetailMapper {
List<LoadTestReportDetail> selectByExample(LoadTestReportDetailExample example);
LoadTestReportDetail selectByPrimaryKey(String reportId);
LoadTestReportDetail selectByPrimaryKey(LoadTestReportDetailKey key);
int updateByExampleSelective(@Param("record") LoadTestReportDetail record, @Param("example") LoadTestReportDetailExample example);
......
......@@ -3,6 +3,7 @@
<mapper namespace="io.metersphere.base.mapper.LoadTestReportDetailMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.LoadTestReportDetail">
<id column="report_id" jdbcType="VARCHAR" property="reportId" />
<id column="part" jdbcType="BIGINT" property="part"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestReportDetail">
<result column="content" jdbcType="LONGVARCHAR" property="content" />
......@@ -66,7 +67,8 @@
</where>
</sql>
<sql id="Base_Column_List">
report_id
report_id,
part
</sql>
<sql id="Blob_Column_List">
content
......@@ -101,18 +103,20 @@
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from load_test_report_detail
where report_id = #{reportId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from load_test_report_detail
where report_id = #{reportId,jdbcType=VARCHAR}
</delete>
<select id="selectByPrimaryKey" parameterType="io.metersphere.base.domain.LoadTestReportDetailKey" resultMap="ResultMapWithBLOBs">
SELECT
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List"/>
FROM load_test_report_detail
WHERE report_id = #{reportId,jdbcType=VARCHAR}
AND part = #{part,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="io.metersphere.base.domain.LoadTestReportDetailKey">
DELETE FROM load_test_report_detail
WHERE report_id = #{reportId,jdbcType=VARCHAR}
AND part = #{part,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.LoadTestReportDetailExample">
delete from load_test_report_detail
<if test="_parameter != null">
......@@ -120,27 +124,35 @@
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.LoadTestReportDetail">
insert into load_test_report_detail (report_id, content)
values (#{reportId,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR})
insert into load_test_report_detail (report_id, part, content
)
values (#{reportId,jdbcType=VARCHAR}, #{part,jdbcType=BIGINT}, #{content,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestReportDetail">
insert into load_test_report_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="reportId != null">
report_id,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="reportId != null">
report_id,
</if>
<if test="part != null">
part,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
</if>
<if test="part != null">
#{part,jdbcType=BIGINT},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.LoadTestReportDetailExample" resultType="java.lang.Long">
select count(*) from load_test_report_detail
......@@ -150,30 +162,35 @@
</select>
<update id="updateByExampleSelective" parameterType="map">
update load_test_report_detail
<set>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<set>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
</if>
<if test="record.part != null">
part = #{record.part,jdbcType=BIGINT},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update load_test_report_detail
set report_id = #{record.reportId,jdbcType=VARCHAR},
update load_test_report_detail
set report_id = #{record.reportId,jdbcType=VARCHAR},
part = #{record.part,jdbcType=BIGINT},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update load_test_report_detail
set report_id = #{record.reportId,jdbcType=VARCHAR}
<if test="_parameter != null">
update load_test_report_detail
set report_id = #{record.reportId,jdbcType=VARCHAR},
part = #{record.part,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
......@@ -184,11 +201,13 @@
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where report_id = #{reportId,jdbcType=VARCHAR}
where report_id = #{reportId,jdbcType=VARCHAR}
and part = #{part,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.LoadTestReportDetail">
update load_test_report_detail
set content = #{content,jdbcType=LONGVARCHAR}
where report_id = #{reportId,jdbcType=VARCHAR}
update load_test_report_detail
set content = #{content,jdbcType=LONGVARCHAR}
where report_id = #{reportId,jdbcType=VARCHAR}
and part = #{part,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
......@@ -5,6 +5,7 @@
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="report_id" jdbcType="VARCHAR" property="reportId" />
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="part" jdbcType="BIGINT" property="part"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestReportLog">
<result column="content" jdbcType="LONGVARCHAR" property="content" />
......@@ -68,7 +69,10 @@
</where>
</sql>
<sql id="Base_Column_List">
id, report_id, resource_id
id,
report_id,
resource_id,
part
</sql>
<sql id="Blob_Column_List">
content
......@@ -122,41 +126,47 @@
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.LoadTestReportLog">
insert into load_test_report_log (id, report_id, resource_id,
content)
values (#{id,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
#{content,jdbcType=LONGVARCHAR})
insert into load_test_report_log (id, report_id, resource_id,
part, content)
values (#{id,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
#{part,jdbcType=BIGINT}, #{content,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestReportLog">
insert into load_test_report_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="reportId != null">
report_id,
</if>
<if test="resourceId != null">
resource_id,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
</if>
<if test="resourceId != null">
#{resourceId,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="reportId != null">
report_id,
</if>
<if test="resourceId != null">
resource_id,
</if>
<if test="part != null">
part,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
</if>
<if test="resourceId != null">
#{resourceId,jdbcType=VARCHAR},
</if>
<if test="part != null">
#{part,jdbcType=BIGINT},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.LoadTestReportLogExample" resultType="java.lang.Long">
select count(*) from load_test_report_log
......@@ -166,69 +176,79 @@
</select>
<update id="updateByExampleSelective" parameterType="map">
update load_test_report_log
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
</if>
<if test="record.resourceId != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
</if>
<if test="record.resourceId != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
</if>
<if test="record.part != null">
part = #{record.part,jdbcType=BIGINT},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update load_test_report_log
set id = #{record.id,jdbcType=VARCHAR},
update load_test_report_log
set id = #{record.id,jdbcType=VARCHAR},
report_id = #{record.reportId,jdbcType=VARCHAR},
resource_id = #{record.resourceId,jdbcType=VARCHAR},
part = #{record.part,jdbcType=BIGINT},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update load_test_report_log
set id = #{record.id,jdbcType=VARCHAR},
update load_test_report_log
set id = #{record.id,jdbcType=VARCHAR},
report_id = #{record.reportId,jdbcType=VARCHAR},
resource_id = #{record.resourceId,jdbcType=VARCHAR}
<if test="_parameter != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
part = #{record.part,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.LoadTestReportLog">
update load_test_report_log
<set>
<if test="reportId != null">
report_id = #{reportId,jdbcType=VARCHAR},
</if>
<if test="resourceId != null">
resource_id = #{resourceId,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
<set>
<if test="reportId != null">
report_id = #{reportId,jdbcType=VARCHAR},
</if>
<if test="resourceId != null">
resource_id = #{resourceId,jdbcType=VARCHAR},
</if>
<if test="part != null">
part = #{part,jdbcType=BIGINT},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.LoadTestReportLog">
update load_test_report_log
set report_id = #{reportId,jdbcType=VARCHAR},
update load_test_report_log
set report_id = #{reportId,jdbcType=VARCHAR},
resource_id = #{resourceId,jdbcType=VARCHAR},
part = #{part,jdbcType=BIGINT},
content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.LoadTestReportLog">
update load_test_report_log
set report_id = #{reportId,jdbcType=VARCHAR},
resource_id = #{resourceId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
update load_test_report_log
set report_id = #{reportId,jdbcType=VARCHAR},
resource_id = #{resourceId,jdbcType=VARCHAR},
part = #{part,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
......@@ -2,7 +2,6 @@ package io.metersphere.base.mapper;
import io.metersphere.base.domain.LoadTestReport;
import io.metersphere.base.domain.LoadTestReportExample;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -14,25 +13,25 @@ public interface LoadTestReportMapper {
int deleteByPrimaryKey(String id);
int insert(LoadTestReportWithBLOBs record);
int insert(LoadTestReport record);
int insertSelective(LoadTestReportWithBLOBs record);
int insertSelective(LoadTestReport record);
List<LoadTestReportWithBLOBs> selectByExampleWithBLOBs(LoadTestReportExample example);
List<LoadTestReport> selectByExampleWithBLOBs(LoadTestReportExample example);
List<LoadTestReport> selectByExample(LoadTestReportExample example);
LoadTestReportWithBLOBs selectByPrimaryKey(String id);
LoadTestReport selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") LoadTestReportWithBLOBs record, @Param("example") LoadTestReportExample example);
int updateByExampleSelective(@Param("record") LoadTestReport record, @Param("example") LoadTestReportExample example);
int updateByExampleWithBLOBs(@Param("record") LoadTestReportWithBLOBs record, @Param("example") LoadTestReportExample example);
int updateByExampleWithBLOBs(@Param("record") LoadTestReport record, @Param("example") LoadTestReportExample example);
int updateByExample(@Param("record") LoadTestReport record, @Param("example") LoadTestReportExample example);
int updateByPrimaryKeySelective(LoadTestReportWithBLOBs record);
int updateByPrimaryKeySelective(LoadTestReport record);
int updateByPrimaryKeyWithBLOBs(LoadTestReportWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(LoadTestReport record);
int updateByPrimaryKey(LoadTestReport record);
}
\ No newline at end of file
......@@ -9,9 +9,8 @@
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="status" jdbcType="VARCHAR" property="status" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestReportWithBLOBs">
<result column="description" jdbcType="LONGVARCHAR" property="description" />
<result column="content" jdbcType="LONGVARCHAR" property="content" />
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestReport">
<result column="description" jdbcType="LONGVARCHAR" property="description"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
......@@ -75,7 +74,7 @@
id, test_id, name, create_time, update_time, status
</sql>
<sql id="Blob_Column_List">
description, content
description
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.LoadTestReportExample" resultMap="ResultMapWithBLOBs">
select
......@@ -125,25 +124,25 @@
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.LoadTestReportWithBLOBs">
insert into load_test_report (id, test_id, name,
create_time, update_time, status,
description, content)
values (#{id,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR},
#{description,jdbcType=LONGVARCHAR}, #{content,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestReportWithBLOBs">
insert into load_test_report
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="testId != null">
test_id,
</if>
<if test="name != null">
name,
<insert id="insert" parameterType="io.metersphere.base.domain.LoadTestReport">
INSERT INTO load_test_report (id, test_id, name,
create_time, update_time, status,
description)
VALUES (#{id,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR},
#{description,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestReport">
insert into load_test_report
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="testId != null">
test_id,
</if>
<if test="name != null">
name,
</if>
<if test="createTime != null">
create_time,
......@@ -157,9 +156,6 @@
<if test="description != null">
description,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
......@@ -183,9 +179,6 @@
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.LoadTestReportExample" resultType="java.lang.Long">
......@@ -218,25 +211,21 @@
<if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update load_test_report
set id = #{record.id,jdbcType=VARCHAR},
update load_test_report
set id = #{record.id,jdbcType=VARCHAR},
test_id = #{record.testId,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
status = #{record.status,jdbcType=VARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
description = #{record.description,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
......@@ -252,17 +241,17 @@
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.LoadTestReportWithBLOBs">
update load_test_report
<set>
<if test="testId != null">
test_id = #{testId,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.LoadTestReport">
update load_test_report
<set>
<if test="testId != null">
test_id = #{testId,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
......@@ -273,23 +262,19 @@
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.LoadTestReportWithBLOBs">
update load_test_report
set test_id = #{testId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
status = #{status,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR},
content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.LoadTestReport">
UPDATE load_test_report
SET test_id = #{testId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
status = #{status,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR}
WHERE id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.LoadTestReport">
update load_test_report
set test_id = #{testId,jdbcType=VARCHAR},
......
......@@ -14,8 +14,6 @@ public interface ExtLoadTestReportMapper {
ReportDTO getReportTestAndProInfo(@Param("id") String id);
int appendLine(@Param("testId") String id, @Param("line") String line);
LoadTestReport selectByPrimaryKey(String id);
List<DashboardTestDTO> selectDashboardTests(@Param("workspaceId") String workspaceId, @Param("startTimestamp") long startTimestamp);
......
......@@ -41,12 +41,6 @@
where ltr.id = #{id}
</select>
<update id="appendLine">
UPDATE load_test_report
SET content = concat(content, #{line})
WHERE id = #{testId}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
......
......@@ -28,7 +28,7 @@ public interface ParamConstants {
}
enum Classify implements ParamConstants {
MAIL("meter"),
REGISTRY("registry");
private String value;
......@@ -85,4 +85,29 @@ public interface ParamConstants {
this.value = value;
}
}
public static enum MAIL {
HOST("meter.host", 1),
PORT("meter.port", 2),
ACCOUNT("meter.account", 3),
PASSWORD("meter.password", 4),
SSL("meter.ssl", 5),
TLS("meter.tls", 6),
ANON("meter.anon", 7);
private String key;
private Integer value;
private MAIL(String key, Integer value) {
this.key = key;
this.value = value;
}
public String getKey() {
return this.key;
}
public Integer getValue() {
return this.value;
}
}
}
......@@ -22,4 +22,9 @@ public class RoleController {
return roleService.getRoleList(sign);
}
@GetMapping("/all")
public List<Role> getAllRole() {
return roleService.getAllRole();
}
}
package io.metersphere.controller;
import io.metersphere.base.domain.SystemParameter;
import io.metersphere.service.SystemParameterService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
@RestController
@RequestMapping(value = "/system")
public class SystemParameterController {
@Resource
private SystemParameterService SystemParameterService;
@PostMapping("/edit/email")
public void editMail(@RequestBody List<SystemParameter> SystemParameter){
SystemParameterService.editMail(SystemParameter);
}
@PostMapping("/testConnection")
public void testConnection(@RequestBody HashMap<String, String> hashMap){
SystemParameterService.testConnection(hashMap);
}
}
......@@ -9,11 +9,10 @@ import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.UserRequest;
import io.metersphere.controller.request.member.AddMemberRequest;
import io.metersphere.controller.request.member.UserRequest;
import io.metersphere.controller.request.member.EditPassWordRequest;
import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.member.SetAdminRequest;
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.UserDTO;
......@@ -39,16 +38,15 @@ public class UserController {
@Resource
private WorkspaceService workspaceService;
// admin api
@PostMapping("/special/add")
@RequiresRoles(RoleConstants.ADMIN)
public UserDTO insertUser(@RequestBody User user) {
public UserDTO insertUser(@RequestBody UserRequest user) {
return userService.insert(user);
}
@PostMapping("/special/list/{goPage}/{pageSize}")
@RequiresRoles(RoleConstants.ADMIN)
public Pager<List<User>> getUserList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody UserRequest request) {
public Pager<List<User>> getUserList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody io.metersphere.controller.request.UserRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, userService.getUserListWithRequest(request));
}
......@@ -67,8 +65,8 @@ public class UserController {
@PostMapping("/special/update")
@RequiresRoles(RoleConstants.ADMIN)
public void updateUser(@RequestBody User user) {
userService.updateUser(user);
public void updateUser(@RequestBody UserRequest user) {
userService.updateUserRole(user);
}
@PostMapping("/special/ws/member/list/{goPage}/{pageSize}")
......@@ -120,7 +118,6 @@ public class UserController {
public List<User> getOrgMemberListByAdmin(@RequestBody QueryOrgMemberRequest request) {
return userService.getOrgMemberList(request);
}
// admin api
@GetMapping("/list")
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
......@@ -270,10 +267,4 @@ public class UserController {
return userService.updateUserPassword(request);
}
@PostMapping("/set/admin")
@RequiresRoles(RoleConstants.ADMIN)
public void setAdmin(@RequestBody SetAdminRequest request) {
userService.setAdmin(request);
}
}
......@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@RequestMapping("userrole")
@RestController
......@@ -20,14 +21,20 @@ public class UserRoleController {
private UserRoleService userRoleService;
@GetMapping("/list/org/{orgId}/{userId}")
@RequiresRoles(value = {RoleConstants.ADMIN,RoleConstants.ORG_ADMIN}, logical = Logical.OR)
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
public List<Role> getOrganizationMemberRoles(@PathVariable String orgId, @PathVariable String userId) {
return userRoleService.getOrganizationMemberRoles(orgId, userId);
}
@GetMapping("/list/ws/{workspaceId}/{userId}")
@RequiresRoles(value = {RoleConstants.ADMIN,RoleConstants.ORG_ADMIN}, logical = Logical.OR)
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
public List<Role> getWorkspaceMemberRoles(@PathVariable String workspaceId, @PathVariable String userId) {
return userRoleService.getWorkspaceMemberRoles(workspaceId, userId);
}
@GetMapping("/all/{userId}")
@RequiresRoles(RoleConstants.ADMIN)
public List<Map<String,Object>> getUserRole(@PathVariable("userId") String userId) {
return userRoleService.getUserRole(userId);
}
}
......@@ -38,6 +38,11 @@ public class WorkspaceController {
return workspaceService.saveWorkspace(workspace);
}
@GetMapping("/list")
public List<Workspace> getWorkspaceList() {
return workspaceService.getWorkspaceList(new WorkspaceRequest());
}
@PostMapping("special/add")
@RequiresRoles(RoleConstants.ADMIN)
public void addWorkspaceByAdmin(@RequestBody Workspace workspace) {
......
package io.metersphere.controller.request.member;
import lombok.Data;
@Data
public class SetAdminRequest {
private String id;
private String adminId;
private String password;
}
package io.metersphere.controller.request.member;
import io.metersphere.base.domain.User;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Getter
@Setter
public class UserRequest extends User {
private List<Map<String,Object>> roles = new ArrayList<>();
}
......@@ -6,7 +6,7 @@ import lombok.Setter;
@Getter
@Setter
public class LogDetailDTO {
private String id;
private String resourceId;
private String resourceName;
private String content;
}
......@@ -104,9 +104,9 @@ public class PerformanceReportController {
return reportService.logs(reportId);
}
@GetMapping("log/download/{logId}")
public ResponseEntity<byte[]> downloadLog(@PathVariable String logId) {
byte[] bytes = reportService.downloadLog(logId);
@GetMapping("log/download/{reportId}/{resourceId}")
public ResponseEntity<byte[]> downloadLog(@PathVariable String reportId, @PathVariable String resourceId) {
byte[] bytes = reportService.downloadLog(reportId, resourceId);
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("application/octet-stream"))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"jmeter.log\"")
......
......@@ -79,7 +79,9 @@ public class PerformanceTestService {
// delete load_test_report, delete load_test_report_detail
reportIdList.forEach(reportId -> {
loadTestReportDetailMapper.deleteByPrimaryKey(reportId);
LoadTestReportDetailExample example = new LoadTestReportDetailExample();
example.createCriteria().andReportIdEqualTo(reportId);
loadTestReportDetailMapper.deleteByExample(example);
reportService.deleteReport(reportId);
});
......@@ -202,7 +204,7 @@ public class PerformanceTestService {
}
private void startEngine(LoadTestWithBLOBs loadTest, Engine engine) {
LoadTestReportWithBLOBs testReport = new LoadTestReportWithBLOBs();
LoadTestReport testReport = new LoadTestReport();
testReport.setId(engine.getReportId());
testReport.setCreateTime(engine.getStartTime());
testReport.setUpdateTime(engine.getStartTime());
......@@ -216,29 +218,16 @@ public class PerformanceTestService {
loadTest.setStatus(PerformanceTestStatus.Starting.name());
loadTestMapper.updateByPrimaryKeySelective(loadTest);
// 启动正常插入 report
testReport.setContent(HEADERS);
testReport.setStatus(PerformanceTestStatus.Starting.name());
loadTestReportMapper.insertSelective(testReport);
LoadTestReportDetail reportDetail = new LoadTestReportDetail();
reportDetail.setContent(HEADERS);
reportDetail.setReportId(testReport.getId());
reportDetail.setPart(1L);
loadTestReportDetailMapper.insertSelective(reportDetail);
// append \n
extLoadTestReportMapper.appendLine(testReport.getId(), "\n");
// append \n
extLoadTestReportDetailMapper.appendLine(testReport.getId(), "\n");
// 保存 load_test_report_log
String resourcePoolId = loadTest.getTestResourcePoolId();
List<TestResource> testResourceList = testResourceService.getResourcesByPoolId(resourcePoolId);
testResourceList.forEach(r -> {
LoadTestReportLog record = new LoadTestReportLog();
record.setId(UUID.randomUUID().toString());
record.setReportId(testReport.getId());
record.setResourceId(r.getId());
record.setContent(StringUtils.EMPTY);
loadTestReportLogMapper.insert(record);
});
} catch (MSException e) {
LogUtil.error(e);
loadTest.setStatus(PerformanceTestStatus.Error.name());
......
......@@ -24,7 +24,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
......@@ -57,7 +59,7 @@ public class ReportService {
MSException.throwException("report id cannot be null");
}
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(loadTestReport.getTestId());
LogUtil.info("Delete report started, report ID: %s" + reportId);
......@@ -142,7 +144,7 @@ public class ReportService {
}
public void checkReportStatus(String reportId) {
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
String reportStatus = loadTestReport.getStatus();
if (StringUtils.equals(PerformanceTestStatus.Running.name(), reportStatus)) {
MSException.throwException("Reporting in progress...");
......@@ -160,42 +162,50 @@ public class ReportService {
public List<LogDetailDTO> logs(String reportId) {
LoadTestReportLogExample example = new LoadTestReportLogExample();
example.createCriteria().andReportIdEqualTo(reportId);
example.setOrderByClause("part");
List<LoadTestReportLog> loadTestReportLogs = loadTestReportLogMapper.selectByExampleWithBLOBs(example);
return loadTestReportLogs.stream().map(log -> {
Map<String, List<LoadTestReportLog>> reportLogs = loadTestReportLogs.stream().collect(Collectors.groupingBy(LoadTestReportLog::getResourceId));
List<LogDetailDTO> result = new ArrayList<>();
reportLogs.forEach((resourceId, resourceLogs) -> {
LogDetailDTO detailDTO = new LogDetailDTO();
detailDTO.setId(log.getId());
TestResource testResource = testResourceService.getTestResource(log.getResourceId());
String content = log.getContent();
TestResource testResource = testResourceService.getTestResource(resourceId);
String content = resourceLogs.stream().map(LoadTestReportLog::getContent).reduce("", (a, b) -> a + b);
// 显示前 2048
content = StringUtils.substring(content, 0, 2048);
detailDTO.setResourceId(resourceId);
detailDTO.setContent(content);
if (testResource == null) {
detailDTO.setResourceName(log.getResourceId());
return detailDTO;
detailDTO.setResourceName(resourceId);
result.add(detailDTO);
return;
}
String configuration = testResource.getConfiguration();
if (StringUtils.isBlank(configuration)) {
detailDTO.setResourceName(log.getResourceId());
return detailDTO;
detailDTO.setResourceName(resourceId);
result.add(detailDTO);
return;
}
JSONObject object = JSON.parseObject(configuration);
if (StringUtils.isNotBlank(object.getString("masterUrl"))) {
detailDTO.setResourceName(object.getString("masterUrl"));
return detailDTO;
result.add(detailDTO);
return;
}
if (StringUtils.isNotBlank(object.getString("ip"))) {
detailDTO.setResourceName(object.getString("ip"));
return detailDTO;
result.add(detailDTO);
}
return detailDTO;
}).collect(Collectors.toList());
});
return result;
}
public byte[] downloadLog(String logId) {
LoadTestReportLog loadTestReportLog = loadTestReportLogMapper.selectByPrimaryKey(logId);
if (loadTestReportLog != null) {
return loadTestReportLog.getContent().getBytes();
}
return new byte[0];
public byte[] downloadLog(String reportId, String resourceId) {
LoadTestReportLogExample example = new LoadTestReportLogExample();
example.createCriteria().andReportIdEqualTo(reportId).andResourceIdEqualTo(resourceId);
List<LoadTestReportLog> loadTestReportLogs = loadTestReportLogMapper.selectByExampleWithBLOBs(example);
String content = loadTestReportLogs.stream().map(LoadTestReportLog::getContent).reduce("", (a, b) -> a + b);
return content.getBytes();
}
}
package io.metersphere.service;
import io.metersphere.base.domain.Role;
import io.metersphere.base.mapper.RoleMapper;
import io.metersphere.base.mapper.ext.ExtRoleMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -13,8 +14,14 @@ public class RoleService {
@Resource
private ExtRoleMapper extRoleMapper;
@Resource
private RoleMapper roleMapper;
public List<Role> getRoleList(String sign) {
return extRoleMapper.getRoleList(sign);
}
public List<Role> getAllRole() {
return roleMapper.selectByExample(null);
}
}
......@@ -4,14 +4,22 @@ import io.metersphere.base.domain.SystemParameter;
import io.metersphere.base.domain.SystemParameterExample;
import io.metersphere.base.mapper.SystemParameterMapper;
import io.metersphere.commons.constants.ParamConstants;
import io.metersphere.commons.utils.EncryptUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import javax.annotation.Resource;
@Service
public class SystemParameterService {
......@@ -31,4 +39,43 @@ public class SystemParameterService {
}
return result;
}
public void editMail(List<SystemParameter> parameters){
List<SystemParameter> paramList = this.getParamList(ParamConstants.Classify.MAIL.getValue());
boolean empty = paramList.size() < 2;
parameters.forEach(parameter -> {
if (parameter.getParamKey().equals(ParamConstants.MAIL.PASSWORD.getKey())) {
String string = EncryptUtils.aesEncrypt(parameter.getParamValue()).toString();
parameter.setParamValue(string);
}
if (empty) {
systemParameterMapper.insert(parameter);
} else {
systemParameterMapper.updateByPrimaryKey(parameter);
}
});
}
public List<SystemParameter> getParamList(String type) {
SystemParameterExample example = new SystemParameterExample();
example.createCriteria().andParamKeyLike(type + "%");
return systemParameterMapper.selectByExample(example);
}
public void testConnection(HashMap<String, String> hashMap){
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
javaMailSender.setDefaultEncoding("UTF-8");
javaMailSender.setHost(hashMap.get(ParamConstants.MAIL.PORT.getKey()));
javaMailSender.setPort(Integer.valueOf(hashMap.get(ParamConstants.MAIL.PORT.getKey())));
javaMailSender.setUsername(hashMap.get(ParamConstants.MAIL.ACCOUNT.getKey()));
javaMailSender.setPassword(hashMap.get(ParamConstants.MAIL.PASSWORD.getKey()));
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
if (BooleanUtils.toBoolean(hashMap.get(ParamConstants.MAIL.SSL.getKey()))) {
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
}
if (BooleanUtils.toBoolean(hashMap.get(ParamConstants.MAIL.TLS.getKey()))) {
props.put("mail.smtp.starttls.enable", "true");
}
javaMailSender.setJavaMailProperties(props);
}
}
package io.metersphere.service;
import io.metersphere.base.domain.Role;
import io.metersphere.base.domain.UserRole;
import io.metersphere.base.domain.UserRoleExample;
import io.metersphere.base.mapper.UserRoleMapper;
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
......@@ -14,6 +22,8 @@ public class UserRoleService {
@Resource
private ExtUserRoleMapper extUserRoleMapper;
@Resource
private UserRoleMapper userRoleMapper;
public List<Role> getOrganizationMemberRoles(String orgId, String userId) {
return extUserRoleMapper.getOrganizationMemberRoles(orgId, userId);
......@@ -23,4 +33,28 @@ public class UserRoleService {
return extUserRoleMapper.getWorkspaceMemberRoles(workspaceId, userId);
}
public List<Map<String,Object>> getUserRole(String userId) {
List<Map<String,Object>> list = new ArrayList<>();
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andUserIdEqualTo(userId);
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
List<String> collect = userRoles.stream()
.map(userRole -> userRole.getRoleId())
.distinct()
.collect(Collectors.toList());
for (int i = 0; i < collect.size(); i++) {
Map<String, Object> map = new HashMap<>(2);
map.put("id", collect.get(i));
map.put("Ids", new ArrayList<>());
for (int j = 0; j < userRoles.size(); j++) {
String role = userRoles.get(j).getRoleId();
if (StringUtils.equals(role, collect.get(i))) {
List ids = (List) map.get("Ids");
ids.add(userRoles.get(j).getSourceId());
}
}
list.add(map);
}
return list;
}
}
......@@ -9,11 +9,10 @@ import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.CodingUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.UserRequest;
import io.metersphere.controller.request.member.AddMemberRequest;
import io.metersphere.controller.request.member.UserRequest;
import io.metersphere.controller.request.member.EditPassWordRequest;
import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.member.SetAdminRequest;
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.UserDTO;
......@@ -25,8 +24,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
@Service
......@@ -48,7 +46,7 @@ public class UserService {
@Resource
private ExtUserMapper extUserMapper;
public UserDTO insert(User user) {
public UserDTO insert(UserRequest user) {
checkUserParam(user);
//
String id = user.getId();
......@@ -58,9 +56,44 @@ public class UserService {
} else {
createUser(user);
}
List<Map<String, Object>> roles = user.getRoles();
if (!roles.isEmpty()) {
insertUserRole(roles, user.getId());
}
return getUserDTO(user.getId());
}
private void insertUserRole(List<Map<String, Object>> roles, String userId) {
for (int i = 0; i < roles.size(); i++) {
Map<String, Object> map = roles.get(i);
String role = (String) map.get("id");
if (StringUtils.equals(role, RoleConstants.ADMIN)) {
UserRole userRole = new UserRole();
userRole.setId(UUID.randomUUID().toString());
userRole.setUserId(userId);
userRole.setUpdateTime(System.currentTimeMillis());
userRole.setCreateTime(System.currentTimeMillis());
userRole.setRoleId(role);
// TODO 修改
userRole.setSourceId("adminSourceId");
userRoleMapper.insertSelective(userRole);
} else {
List<String> list = (List<String>) map.get("Ids");
for (int j = 0; j < list.size(); j++) {
UserRole userRole1 = new UserRole();
userRole1.setId(UUID.randomUUID().toString());
userRole1.setUserId(userId);
userRole1.setRoleId(role);
userRole1.setUpdateTime(System.currentTimeMillis());
userRole1.setCreateTime(System.currentTimeMillis());
userRole1.setSourceId(list.get(j));
// TODO 防止重复插入
userRoleMapper.insertSelective(userRole1);
}
}
}
}
private void checkUserParam(User user) {
if (StringUtils.isBlank(user.getName())) {
......@@ -134,7 +167,7 @@ public class UserService {
return userMapper.selectByExample(null);
}
public List<User> getUserListWithRequest(UserRequest request) {
public List<User> getUserListWithRequest(io.metersphere.controller.request.UserRequest request) {
return extUserMapper.getUserList(request);
}
......@@ -146,6 +179,19 @@ public class UserService {
userMapper.deleteByPrimaryKey(userId);
}
public void updateUserRole(UserRequest user) {
String userId = user.getId();
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andUserIdEqualTo(userId);
userRoleMapper.deleteByExample(userRoleExample);
List<Map<String, Object>> roles = user.getRoles();
if (!roles.isEmpty()) {
insertUserRole(roles, user.getId());
}
user.setUpdateTime(System.currentTimeMillis());
userMapper.updateByPrimaryKeySelective(user);
}
public void updateUser(User user) {
user.setUpdateTime(System.currentTimeMillis());
userMapper.updateByPrimaryKeySelective(user);
......@@ -270,7 +316,7 @@ public class UserService {
public void setLanguage(String lang) {
if (SessionUtils.getUser() != null) {
User user = new User();
UserRequest user = new UserRequest();
user.setId(SessionUtils.getUser().getId());
user.setLanguage(lang);
updateUser(user);
......@@ -336,23 +382,6 @@ public class UserService {
return extUserMapper.updatePassword(user);
}
public void setAdmin(SetAdminRequest request) {
String adminId = request.getAdminId();
String password = request.getPassword();
if (!checkUserPassword(adminId, password)) {
MSException.throwException("verification failed!");
}
UserRole userRole = new UserRole();
userRole.setId(UUID.randomUUID().toString());
userRole.setUserId(request.getId());
// TODO 修改admin sourceId
userRole.setSourceId("adminSourceId");
userRole.setRoleId(RoleConstants.ADMIN);
userRole.setCreateTime(System.currentTimeMillis());
userRole.setUpdateTime(System.currentTimeMillis());
userRoleMapper.insertSelective(userRole);
}
public String getDefaultLanguage() {
final String key = "default.language";
return extUserMapper.getDefaultLanguage(key);
......
......@@ -51,7 +51,6 @@ CREATE TABLE IF NOT EXISTS `load_test_report` (
`test_id` varchar(50) NOT NULL COMMENT 'Test ID this test report belongs to',
`name` varchar(64) NOT NULL COMMENT 'Test report name',
`description` varchar(255) DEFAULT NULL COMMENT 'Test report name',
`content` longtext,
`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',
......@@ -64,20 +63,19 @@ CREATE TABLE IF NOT EXISTS `load_test_report` (
CREATE TABLE IF NOT EXISTS `load_test_report_detail` (
`report_id` varchar(50) NOT NULL,
`content` longtext,
PRIMARY KEY (`report_id`)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_bin;
`part` bigint(11) NOT NULL,
PRIMARY KEY (`report_id`,`part`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `load_test_report_log` (
`id` varchar(50) NOT NULL,
`id` varchar(50) NOT NULL,
`report_id` varchar(50) NOT NULL,
`resource_id` varchar(50) DEFAULT NULL,
`content` longtext ,
`part` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `load_test_report_log_report_id_resource_name_index` (`report_id`,`resource_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ;
CREATE TABLE IF NOT EXISTS `load_test_report_result` (
`id` varchar(50) NOT NULL,
......
......@@ -59,7 +59,7 @@
<!--要生成的数据库表 -->
<table tableName="test_plan_test_case"/>
<table tableName="load_test_report"/>
</context>
</generatorConfiguration>
\ No newline at end of file
......@@ -88,6 +88,7 @@
},
reportRecent: {
title: this.$t('report.recent'),
showTime: true,
url: "/api/report/recent/5",
index: function (item) {
return '/api/report/view/' + item.id;
......
......@@ -2,7 +2,7 @@
<el-table :data="assertions" :row-style="getRowStyle" :header-cell-style="getRowStyle">
<el-table-column prop="name" :label="$t('api_report.assertions_name')" width="300">
</el-table-column>
<el-table-column prop="message" :label="$t('api_report.assertions_message')">
<el-table-column prop="message" :label="$t('api_report.assertions_error_message')">
</el-table-column>
<el-table-column prop="pass" :label="$t('api_report.assertions_is_success')" width="180">
<template v-slot:default="{row}">
......
......@@ -105,7 +105,7 @@
},
fail() {
return (this.content.error / this.content.total).toFixed(0) + "%";
return (this.content.error / this.content.total * 100).toFixed(0) + "%";
},
assertions() {
return this.content.passAssertions + " / " + this.content.totalAssertions;
......
......@@ -17,10 +17,10 @@
</div>
</el-col>
<el-col :span="2">
{{error}}
{{request.error}}
</el-col>
<el-col :span="2">
{{request.passAssertions}} / {{request.totalAssertions}}
{{assertion}}
</el-col>
<el-col :span="2">
<el-tag size="mini" type="success" v-if="request.success">
......@@ -72,9 +72,9 @@
},
computed: {
error() {
return this.request.totalAssertions - this.request.passAssertions;
}
assertion() {
return this.request.passAssertions + " / " + this.request.totalAssertions;
},
}
}
</script>
......
......@@ -59,7 +59,7 @@
computed: {
assertion() {
return this.scenario.passAssertions - this.scenario.totalAssertions;
return this.scenario.passAssertions + " / " + this.scenario.totalAssertions;
},
success() {
return this.scenario.error === 0;
......
......@@ -5,7 +5,8 @@
<el-container class="test-container" v-loading="result.loading">
<el-header>
<el-row type="flex" align="middle">
<el-input class="test-name" v-model="test.name" maxlength="64" :placeholder="$t('api_test.input_name')">
<el-input class="test-name" v-model="test.name" maxlength="60" :placeholder="$t('api_test.input_name')"
show-word-limit>
<el-select class="test-project" v-model="test.projectId" slot="prepend"
:placeholder="$t('api_test.select_project')">
<el-option v-for="project in projects" :key="project.id" :label="project.name" :value="project.id"/>
......@@ -113,6 +114,9 @@
saveTest: function () {
this.save(() => {
this.$success(this.$t('commons.save_success'));
this.$router.push({
path: '/api/test/edit?id=' + this.test.id
})
})
},
runTest: function () {
......
......@@ -13,8 +13,12 @@
<el-dropdown trigger="click" @command="handleCommand">
<span class="el-dropdown-link el-icon-more"/>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="{type: 'copy', index: index}">复制请求</el-dropdown-item>
<el-dropdown-item :command="{type: 'delete', index: index}">删除请求</el-dropdown-item>
<el-dropdown-item :command="{type: 'copy', index: index}">
{{$t('api_test.request.copy')}}
</el-dropdown-item>
<el-dropdown-item :command="{type: 'delete', index: index}">
{{$t('api_test.request.delete')}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
......@@ -50,12 +54,12 @@
methods: {
createRequest: function () {
let request = new Request({method: "GET"});
let request = new Request();
this.requests.push(request);
},
copyRequest: function (index) {
let request = this.requests[index];
this.requests.push(JSON.parse(JSON.stringify(request)));
this.requests.push(request.clone());
},
deleteRequest: function (index) {
this.requests.splice(index, 1);
......
<template>
<el-form :model="request" :rules="rules" ref="request" label-width="100px">
<el-form-item :label="$t('api_test.request.name')" prop="name">
<el-input v-model="request.name" maxlength="100"/>
<el-input v-model="request.name" maxlength="100" @input="valid"/>
</el-form-item>
<el-form-item :label="$t('api_test.request.url')" prop="url">
......@@ -108,6 +108,10 @@
}
}
return url;
},
valid(value) {
value = value.replace(/[`~!@#$%^&*()_\-+=<>?:"{}|,./;'\\[\]·!¥…()—\-《》?:“”【】、;‘’,。]/g, '').replace(/\s/g, "");
this.request.name = value;
}
},
......
......@@ -12,13 +12,17 @@
{{$t('api_test.scenario.config')}}
</span>
</div>
<!-- 暂时去掉,将来再加-->
<!-- <el-dropdown trigger="click" @command="handleCommand">-->
<!-- <span class="el-dropdown-link el-icon-more scenario-btn"/>-->
<!-- <el-dropdown-menu slot="dropdown">-->
<!-- <el-dropdown-item :command="{type:'delete', index:index}">删除场景</el-dropdown-item>-->
<!-- </el-dropdown-menu>-->
<!-- </el-dropdown>-->
<el-dropdown trigger="click" @command="handleCommand">
<span class="el-dropdown-link el-icon-more scenario-btn"/>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="{type: 'copy', index: index}">
{{$t('api_test.scenario.copy')}}
</el-dropdown-item>
<el-dropdown-item :command="{type:'delete', index:index}">
{{$t('api_test.scenario.delete')}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<ms-api-request-config :requests="scenario.requests" :open="select"/>
</ms-api-collapse-item>
......@@ -71,6 +75,10 @@
createScenario: function () {
this.scenarios.push(new Scenario());
},
copyScenario: function (index) {
let scenario = this.scenarios[index];
this.scenarios.push(scenario.clone());
},
deleteScenario: function (index) {
this.scenarios.splice(index, 1);
if (this.scenarios.length === 0) {
......@@ -83,6 +91,9 @@
},
handleCommand: function (command) {
switch (command.type) {
case "copy":
this.copyScenario(command.index);
break;
case "delete":
this.deleteScenario(command.index);
break;
......
<template>
<el-form :model="scenario" :rules="rules" ref="scenario" label-width="100px">
<el-form-item :label="$t('api_test.scenario.name')" prop="name">
<el-input v-model="scenario.name" maxlength="100"/>
<el-input v-model="scenario.name" maxlength="100" @input="valid"/>
</el-form-item>
<!-- <el-form-item :label="$t('api_test.scenario.base_url')" prop="url">-->
<!-- <el-input :placeholder="$t('api_test.scenario.base_url_description')" v-model="scenario.url" maxlength="100"/>-->
<!-- </el-form-item>-->
<!-- <el-form-item :label="$t('api_test.scenario.base_url')" prop="url">-->
<!-- <el-input :placeholder="$t('api_test.scenario.base_url_description')" v-model="scenario.url" maxlength="100"/>-->
<!-- </el-form-item>-->
<el-tabs v-model="activeName">
<el-tab-pane :label="$t('api_test.scenario.variables')" name="parameters">
......@@ -43,6 +43,13 @@
]
}
}
},
methods: {
valid(value) {
value = value.replace(/[`~!@#$%^&*()\-+=<>?:"{}|,./;'\\[\]·!¥…()—\-《》?:“”【】、;‘’,。]/g, '').replace(/\s/g, "");
this.scenario.name = value;
}
}
}
</script>
......
......@@ -32,13 +32,12 @@
methods: {
add: function () {
this.remove();
setTimeout(() => {
this.duration.value = this.time;
})
},
remove: function () {
this.duration.value = null;
this.duration.value = undefined;
}
}
}
......
......@@ -20,7 +20,7 @@
</el-select>
</el-col>
<el-col>
<el-input v-model="value" maxlength="255" size="small" show-word-limit
<el-input v-model="value" maxlength="200" size="small" show-word-limit
:placeholder="$t('api_test.request.assertions.value')"/>
</el-col>
<el-col class="assertion-btn">
......
......@@ -13,7 +13,7 @@
<div>
{{$t("api_test.request.assertions.response_time")}}
</div>
<ms-api-assertion-response-time :response-time="assertions.responseTime" :edit="true"/>
<ms-api-assertion-response-time :duration="assertions.duration" :edit="true"/>
</div>
</div>
......
......@@ -137,6 +137,16 @@ export class Scenario extends BaseConfig {
options.requests = options.requests || [new Request()];
return options;
}
clone() {
let scenario = new Scenario(this);
scenario.id = uuid();
scenario.requests.forEach(function (request) {
request.id = uuid();
});
return scenario;
}
}
export class Request extends BaseConfig {
......@@ -168,6 +178,12 @@ export class Request extends BaseConfig {
isValid() {
return !!this.url && !!this.method
}
clone() {
let request = new Request(this);
request.id = uuid();
return request;
}
}
export class Body extends BaseConfig {
......
......@@ -6,7 +6,10 @@
<i class="el-icon-refresh" @click="recent"/>
</div>
<el-menu-item :key="i.id" v-for="i in items" :index="getIndex(i)" :route="getRouter(i)">
<span class="title">{{ i.name }}</span>
<template slot="title">
<div class="title">{{ i.name }}</div>
<div class="time" v-if="options.showTime && i.updateTime">{{ i.updateTime | timestampFormatDate}}</div>
</template>
</el-menu-item>
</div>
</template>
......@@ -81,6 +84,18 @@
}
.title {
display: inline-block;
padding-left: 20px;
max-width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.time {
color: #C0C4CC;
display: inline-block;
padding-left: 20px;
float: right;
}
</style>
......@@ -10,6 +10,7 @@ import OrganizationMember from "../../settings/organization/OrganizationMember";
import Member from "../../settings/workspace/WorkspaceMember";
import TestCaseReportTemplate from "../../settings/workspace/TestCaseReportTemplate";
import TestResourcePool from "../../settings/system/TestResourcePool";
import SystemParameterSetting from "../../settings/system/SystemParameterSetting";
import MsProject from "../../project/MsProject";
import OrganizationWorkspace from "../../settings/organization/OrganizationWorkspace";
import PersonSetting from "../../settings/personal/PersonSetting";
......@@ -80,11 +81,16 @@ const router = new VueRouter({
path: 'testresourcepool',
component: TestResourcePool
},
{
path: 'systemparametersetting',
component: SystemParameterSetting
},
{
path: 'testcase/report/template',
name: 'testCaseReportTemplate',
component: TestCaseReportTemplate
}
},
]
},
{
......
<template>
<div v-loading="result.loading">
<el-tabs type="border-card" :stretch="true">
<el-tab-pane v-for="item in logContent" :key="item.id" :label="item.resourceName" class="logging-content">
<el-tab-pane v-for="item in logContent" :key="item.resourceId" :label="item.resourceName" class="logging-content">
{{item.content}}...
<el-link type="primary" @click="downloadLogFile(item)">{{$t('load_test.download_log_file')}}</el-link>
</el-tab-pane>
......@@ -27,7 +27,7 @@
},
downloadLogFile(item) {
let config = {
url: '/performance/report/log/download/' + item.id,
url: '/performance/report/log/download/' + this.id + '/' + item.resourceId,
method: 'get',
responseType: 'blob'
};
......
<template>
<div>
<!--Domain name binding-->
<el-row type="flex" justify="start">
<el-col :span="8">
<h3>{{$t('load_test.domain_bind')}}</h3>
......@@ -7,7 +8,7 @@
</el-button>
</el-col>
</el-row>
<!-- -->
<!--Domain name binding form -->
<el-row>
<el-col :span="24">
<el-table :data="domains" size="mini" class="tb-edit" align="center" border highlight-current-row>
......@@ -40,6 +41,7 @@
v-model="row.enable"
active-color="#13ce66"
inactive-color="#ff4949"
active-value="readOnly"
@click="confirmEdit(row)"
>
</el-switch>
......
......@@ -9,6 +9,7 @@
<el-menu-item index="/setting/organization">{{$t('commons.organization')}}</el-menu-item>
<el-menu-item index="/setting/systemworkspace">{{$t('commons.workspace')}}</el-menu-item>
<el-menu-item index="/setting/testresourcepool">{{$t('commons.test_resource_pool')}}</el-menu-item>
<el-menu-item index="/setting/systemparametersetting">{{$t('commons.system_parameter_setting')}}</el-menu-item>
</el-submenu>
<el-submenu index="2" v-permission="['org_admin']" v-if="isCurrentOrganizationAdmin">
......
<template>
<div>
<el-card class="box-card" v-loading="result.loading">
<template v-slot:header>
<h2>{{$t('system_parameter_setting.mailbox_service_settings')}}</h2>
</template>
<!--邮件表单-->
<el-form :inline="true" :model="formInline" :rules="rules" ref="formInline" class="demo-form-inline"
:disabled="show" v-loading="loading">
<el-row>
<el-col>
<el-form-item :label="$t('system_parameter_setting.SMTP_host')" prop="host">
</el-form-item>
<el-input v-model="formInline.host" :placeholder="$t('system_parameter_setting.SMTP_host')"
v-on:input="host"></el-input>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('system_parameter_setting.SMTP_port')" prop="port">
</el-form-item>
<el-input v-model="formInline.port" :placeholder="$t('system_parameter_setting.SMTP_port')"
v-on:input="port"></el-input>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('system_parameter_setting.SMTP_account')" prop="account">
</el-form-item>
<el-input v-model="formInline.account" :placeholder="$t('system_parameter_setting.SMTP_account')"
v-on:input="account"></el-input>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('system_parameter_setting.SMTP_password')" prop="password">
</el-form-item>
<el-input v-model="formInline.password" :placeholder="$t('system_parameter_setting.SMTP_password')"
show-password></el-input>
</el-col>
</el-row>
<!---->
<div style="border: 0px;margin-bottom: 20px;margin-top: 20px">
<el-checkbox v-model="SSL" label="开启SSL(如果SMTP端口是465,通常需要启用SSL)"></el-checkbox>
</div>
<div style="border: 0px;margin-bottom: 20px">
<el-checkbox v-model="TLS" label="开启TLS(如果SMTP端口是587,通常需要启用TLS)"></el-checkbox>
</div>
<div style="border: 0px;margin-bottom: 20px">
<el-checkbox v-model="SMTP" label="是否匿名 SMTP"></el-checkbox>
</div>
<template v-slot:footer>
</template>
</el-form>
<div style="margin-left: 640px">
<el-button type="primary" @click="testConnection('formInline')" :disabled="disabledConnection">
{{$t('system_parameter_setting.test_connection')}}
</el-button>
<el-button @click="edit" v-if="showEdit">{{$t('commons.edit')}}</el-button>
<el-button type="success" @click="save('formInline')" v-if="showSave" :disabled="disabledSave">
{{$t('commons.save')}}
</el-button>
<el-button @click="cancel" type="info" v-if="showCancel">{{$t('commons.cancel')}}</el-button>
</div>
</el-card>
</div>
</template>
<script>
export default {
name: "SystemParameterSetting",
data() {
return {
formInline: {
host: 'smtp.163.com',
port: '465',
account: 'xjj0608@153.com',
password: '2345678',
},
result: {},
SSL: false,
TLS: false,
SMTP: true,
showEdit: true,
showSave: false,
showCancel: false,
show: true,
disabledConnection: false,
disabledSave: false,
loading: false,
rules: {
host: [
{
required: true,
message: this.$t('commons.host_cannot_be_empty')
},
],
port: [
{
required: true,
message: ' '
}
],
account: [
{
required: true,
message: ' '
}]
}
}
},
methods: {
host() {
let host = this.formInline.host;
if (!host) {
this.disabledConnection = true;
this.disabledSave = true;
} else {
this.disabledConnection = false;
this.disabledSave = false;
}
},
port() {
let port = this.formInline.port;
if (!port) {
this.disabledConnection = true;
this.disabledSave = true;
} else {
this.disabledConnection = false;
this.disabledSave = false;
}
},
account() {
let account = this.formInline.account;
if (!account) {
this.disabledConnection = true;
this.disabledSave = true;
} else {
this.disabledConnection = false;
this.disabledSave = false;
}
},
testConnection(formInline) {
let param = {
"meter.host": this.formInline.host,
"meter.port": this.formInline.port,
"meter.account": this.formInline.account,
"meter.password": this.formInline.password,
"meter.ssl": this.SSL,
"meter.tls": this.TLS,
"meter.smtp": this.SMTP,
};
this.$refs[formInline].validate((valid) => {
if (valid) {
this.result = this.$post("/system/testConnection", param, response => {
let flag = response.success;
if (flag) {
this.$success(this.$t('commons.connection_successful'));
} else {
this.$message.error(this.$t('commons.connection_failed'));
}
});
} else {
return false;
}
})
},
edit() {
this.showEdit = false;
this.showSave = true;
this.showCancel = true;
this.show = false;
},
save(formInline) {
this.showEdit = true;
this.showCancel = false;
this.showSave = false;
this.show = true;
let param = [
{paramKey: "meter.host", paramValue: this.formInline.host, type: "text", sort: 1},
{paramKey: "meter.port", paramValue: this.formInline.port, type: "text", sort: 2},
{paramKey: "meter.account", paramValue: this.formInline.account, type: "text", sort: 3},
{paramKey: "meter.password", paramValue: this.formInline.password, type: "password", sort: 4},
{paramKey: "meter.ssl", paramValue: this.SSL, type: "text", sort: 5},
{paramKey: "meter.tls", paramValue: this.TLS, type: "text", sort: 6},
{paramKey: "meter.smtp", paramValue: this.SMTP, type: "text", sort: 7}
]
this.$refs[formInline].validate(valid => {
if (valid) {
this.result = this.$post("/system/edit/email", param, response => {
let flag = response.success;
if (flag) {
this.$success(this.$t('commons.save_success'));
} else {
this.$message.error(this.$t('commons.save_failed'));
}
});
} else {
return false;
}
})
},
cancel() {
this.showEdit = true;
this.showCancel = false;
this.showSave = false;
this.show = true;
}
}
}
</script>
<style scoped>
.text {
font-size: 18px;
}
.item {
margin-bottom: 30px;
}
.box-card {
padding-left: 5px;
}
/deep/ .el-input__inner {
border-width: 0px;
border-bottom-width: 1px;
}
</style>
......@@ -16,7 +16,7 @@
</template>
</el-table-column>
<el-table-column prop="email" :label="$t('commons.email')"/>
<el-table-column prop="status" :label="$t('commons.status')">
<el-table-column prop="status" :label="$t('commons.status')" width="120">
<template v-slot:default="scope">
<el-switch v-model="scope.row.status"
active-color="#13ce66"
......@@ -49,9 +49,9 @@
</el-card>
<!--Create user-->
<el-dialog :title="$t('user.create')" :visible.sync="createVisible" width="30%" @closed="handleClose"
<el-dialog :title="$t('user.create')" :visible.sync="createVisible" width="35%" @closed="handleClose"
:destroy-on-close="true">
<el-form :model="form" label-position="right" label-width="100px" size="small" :rules="rule" ref="createUserForm">
<el-form :model="form" label-position="right" label-width="120px" size="small" :rules="rule" ref="createUserForm">
<el-form-item label="ID" prop="id">
<el-input v-model="form.id" autocomplete="off"/>
</el-form-item>
......@@ -67,6 +67,74 @@
<el-form-item :label="$t('commons.password')" prop="password">
<el-input v-model="form.password" autocomplete="off" show-password/>
</el-form-item>
<div v-for="(role, index) in form.roles" :key="index">
<el-form-item :label="'角色'+index" :required="true">
<el-select v-model="role.id" placeholder="选择角色类型">
<el-option
v-for="item in userRole"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-button @click.prevent="removeRole(role)" style="margin-left: 20px;" v-if="form.roles.length > 1">删除
</el-button>
</el-form-item>
<div v-if="role.id === 'org_admin'">
<el-form-item label="选择组织" :required="true">
<el-select v-model="role.Ids" placeholder="选择组织" multiple>
<el-option
v-for="item in form.orgList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
<div v-if="role.id === 'test_manager'">
<el-form-item label="选择工作空间" :required="true">
<el-select v-model="role.Ids" placeholder="选择工作空间" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
<div v-if="role.id ==='test_user'">
<el-form-item label="选择工作空间" :required="true">
<el-select v-model="role.Ids" placeholder="选择工作空间" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
<div v-if="role.id ==='test_viewer'">
<el-form-item label="选择工作空间" :required="true">
<el-select v-model="role.Ids" placeholder="选择工作空间" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
</div>
<el-form-item>
<template>
<el-button type="success" style="width: 100%;" @click="addRole()">添加角色</el-button>
</template>
</el-form-item>
</el-form>
<template v-slot:footer>
<ms-dialog-footer
......@@ -78,7 +146,7 @@
<!--Modify user information in system settings-->
<el-dialog :title="$t('user.modify')" :visible.sync="updateVisible" width="30%" :destroy-on-close="true"
@close="handleClose">
<el-form :model="form" label-position="right" label-width="100px" size="small" :rules="rule" ref="updateUserForm">
<el-form :model="form" label-position="right" label-width="120px" size="small" :rules="rule" ref="updateUserForm">
<el-form-item label="ID" prop="id">
<el-input v-model="form.id" autocomplete="off" :disabled="true"/>
</el-form-item>
......@@ -91,6 +159,73 @@
<el-form-item :label="$t('commons.phone')" prop="phone">
<el-input v-model="form.phone" autocomplete="off"/>
</el-form-item>
<div v-for="(role, index) in form.roles" :key="index">
<el-form-item :label="'角色'+index" :required="true">
<el-select v-model="role.id" placeholder="选择角色类型">
<el-option
v-for="item in userRole"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-button @click.prevent="removeRole(role)" style="margin-left: 20px;" v-if="form.roles.length > 1">删除
</el-button>
</el-form-item>
<div v-if="role.id === 'org_admin'">
<el-form-item label="选择组织" :required="true">
<el-select v-model="role.Ids" placeholder="选择组织" multiple>
<el-option
v-for="item in form.orgList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
<div v-if="role.id === 'test_manager'">
<el-form-item label="选择工作空间" :required="true">
<el-select v-model="role.Ids" placeholder="选择工作空间" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
<div v-if="role.id ==='test_user'">
<el-form-item label="选择工作空间" :required="true">
<el-select v-model="role.Ids" placeholder="选择工作空间" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
<div v-if="role.id ==='test_viewer'">
<el-form-item label="选择工作空间" :required="true">
<el-select v-model="role.Ids" placeholder="选择工作空间" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
</div>
<el-form-item>
<template>
<el-button type="success" style="width: 100%;" @click="addRole()">添加角色</el-button>
</template>
</el-form-item>
</el-form>
<template v-slot:footer>
<ms-dialog-footer
......@@ -152,12 +287,15 @@
updateVisible: false,
editPasswordVisible: false,
multipleSelection: [],
userRole: [],
currentPage: 1,
pageSize: 5,
total: 0,
condition: {},
tableData: [],
form: {},
form: {
roles: [{}]
},
checkPasswordForm: {},
ruleForm: {},
setAdminParam: {},
......@@ -216,14 +354,27 @@
},
created() {
this.search();
this.getAllRole();
},
methods: {
create() {
this.createVisible = true;
this.getOrgList();
this.getWsList();
},
edit(row) {
this.updateVisible = true;
this.form = Object.assign({}, row);
this.$get("/organization/list", response => {
this.$set(this.form, "orgList", response.data);
});
this.$get("/workspace/list", response => {
this.$set(this.form, "wsList", response.data);
});
this.$get('/userrole/all/' + row.id, response => {
let data = response.data;
this.$set(this.form, "roles", data);
});
},
editPassword(row) {
this.editPasswordVisible = true;
......@@ -295,12 +446,12 @@
let roles = data.roles;
// let userRoles = result.userRoles;
this.$set(this.tableData[i], "roles", roles);
})
});
}
})
},
handleClose() {
this.form = {};
this.form = {roles: [{value: ''}]};
},
changeSwitch(row) {
this.$post(this.updatePath, row, () => {
......@@ -312,7 +463,32 @@
},
handleSelectionChange(val) {
this.multipleSelection = val;
}
},
getOrgList() {
this.$get("/organization/list", response => {
this.$set(this.form, "orgList", response.data);
})
},
getWsList() {
this.$get("/workspace/list", response => {
this.$set(this.form, "wsList", response.data);
})
},
getAllRole() {
this.$get("/role/all", response => {
this.userRole = response.data;
})
},
addRole() {
let roles = this.form.roles;
roles.push({});
},
removeRole(item) {
let index = this.form.roles.indexOf(item)
if (index !== -1) {
this.form.roles.splice(index, 1)
}
},
}
}
</script>
......
......@@ -56,6 +56,15 @@ export default {
'personal_information': 'Personal Information',
'exit_system': 'Exit System',
'verification': 'Verification',
'set_admin': 'Set Admin',
'system_parameter_setting': 'System Parameter Setting',
'connection_successful': 'Connection successful',
'connection_failed': 'Connection failed',
'save_failed': 'Saved failed',
'host_cannot_be_empty': 'Host cannot be empty',
'port_cannot_be_empty': 'Port cannot be empty',
'account_cannot_be_empty': 'Account cannot be empty',
'title': 'Title',
'custom': 'Custom',
'select_date': 'Select date',
......@@ -150,9 +159,9 @@ export default {
'please_choose_role': 'Please Choose Role',
'admin': 'Admin',
'org_admin': 'Org_Admin',
'test_manager': 'Test_Manager',
'test_user': 'Test_User',
'test_viewer': 'Test_Viewer',
'test_manager': 'Test Manager',
'test_user': 'Test User',
'test_viewer': 'Test Viewer',
},
report: {
'recent': 'Recent Report',
......@@ -252,8 +261,12 @@ export default {
variables: "Variables",
headers: "Headers",
kv_description: "Variables are available for all requests",
copy: "Copy scenario",
delete: "Delete scenario"
},
request: {
copy: "Copy request",
delete: "Delete request",
input_name: "Please enter the request name",
name: "Name",
method: "Method",
......@@ -312,7 +325,7 @@ export default {
assertions: "Assertions",
assertions_pass: "Passed Assertions",
assertions_name: "Assertion Name",
assertions_message: "Assertion Message",
assertions_error_message: "Error Message",
assertions_is_success: "Fail/Success",
result: "Result",
success: "Success",
......@@ -480,6 +493,14 @@ export default {
'status_change_success': 'Successfully changed the status!',
'status_change_failed': 'Failed to change the status, resource pool is invalid!',
},
system_parameter_setting: {
'mailbox_service_settings': 'Mailbox Service Settings',
'test_connection': 'Test connection',
'SMTP_host': 'SMTP host',
'SMTP_port': 'SMTP port',
'SMTP_account': 'SMTP account',
'SMTP_password': 'SMTP password',
},
i18n: {
'home': 'Home'
}
......
......@@ -80,6 +80,14 @@ export default {
'weeks_5': '周五',
'weeks_6': '周六',
'test_unit': '测试',
'set_admin': '设置为管理员',
'system_parameter_setting': '系统参数设置',
'connection_successful': '连接成功',
'connection_failed': '连接失败',
'save_failed': '保存失败',
'host_cannot_be_empty': '主机不能为空',
'port_cannot_be_empty': '端口号不能为空',
'account_cannot_be_empty': '帐户不能为空',
},
workspace: {
'create': '创建工作空间',
......@@ -106,7 +114,6 @@ export default {
'select': '选择组织',
},
project: {
'name': '项目名称',
'recent': '最近的项目',
'create': '创建项目',
'edit': '编辑项目',
......@@ -232,7 +239,6 @@ export default {
'pressure_prediction_chart': '压力预估图',
},
api_test: {
title: "测试",
save_and_run: "保存并执行",
run: "执行",
running: "正在执行",
......@@ -252,8 +258,12 @@ export default {
variables: "自定义变量",
headers: "请求头",
kv_description: "所有请求可以使用自定义变量",
copy: "复制场景",
delete: "删除场景"
},
request: {
copy: "复制请求",
delete: "删除请求",
input_name: "请输入请求名称",
name: "请求名称",
method: "请求方法",
......@@ -312,7 +322,7 @@ export default {
assertions: "断言",
assertions_pass: "成功断言",
assertions_name: "断言名称",
assertions_message: "断言信息",
assertions_error_message: "错误信息",
assertions_is_success: "是否成功",
result: "结果",
success: "成功",
......@@ -480,6 +490,14 @@ export default {
'status_change_success': '状态修改成功!',
'status_change_failed': '状态修改失败, 校验不通过!',
},
system_parameter_setting: {
'mailbox_service_settings': '邮件服务设置',
'test_connection': '测试连接',
'SMTP_host': 'SMTP主机',
'SMTP_port': 'SMTP端口',
'SMTP_account': 'SMTP账户',
'SMTP_password': 'SMTP密码',
},
i18n: {
'home': '首页'
}
......
......@@ -252,8 +252,12 @@ export default {
variables: "自定義變數",
headers: "請求頭",
kv_description: "所有請求可以使用自定義變數",
copy: "複製場景",
delete: "删除場景"
},
request: {
copy: "複製請求",
delete: "删除請求",
input_name: "請輸入請求名稱",
name: "請求名稱",
method: "請求方法",
......@@ -312,7 +316,7 @@ export default {
assertions: "斷言",
assertions_pass: "成功斷言",
assertions_name: "斷言名稱",
assertions_message: "斷言資訊",
assertions_error_message: "錯誤資訊",
assertions_is_success: "是否成功",
result: "結果",
success: "成功",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册