This commit is contained in:
fit2-zhao 2020-12-09 12:26:20 +08:00
commit 9f4adbbbf9
8 changed files with 116 additions and 25 deletions

View File

@ -229,7 +229,11 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
if (StringUtils.equals("Error", report.getStatus())) { if (StringUtils.equals("Error", report.getStatus())) {
event = NoticeConstants.Event.EXECUTE_FAILED; event = NoticeConstants.Event.EXECUTE_FAILED;
} }
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("testName", report.getName());
paramMap.put("id", report.getId());
paramMap.put("type", "performance");
paramMap.put("url", baseSystemConfigDTO.getUrl());
NoticeModel noticeModel = NoticeModel.builder() NoticeModel noticeModel = NoticeModel.builder()
.successContext(successContext) .successContext(successContext)
.successMailTemplate("ApiSuccessfulNotification") .successMailTemplate("ApiSuccessfulNotification")
@ -239,6 +243,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
.status(report.getStatus()) .status(report.getStatus())
.event(event) .event(event)
.subject(subject) .subject(subject)
.paramMap(paramMap)
.build(); .build();
noticeSendService.send(report.getTriggerMode(), noticeModel); noticeSendService.send(report.getTriggerMode(), noticeModel);
} }

View File

@ -29,5 +29,7 @@ public class User implements Serializable {
private String source; private String source;
private String lastProjectId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -923,6 +923,76 @@ public class UserExample {
addCriterion("`source` not between", value1, value2, "source"); addCriterion("`source` not between", value1, value2, "source");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andLastProjectIdIsNull() {
addCriterion("last_project_id is null");
return (Criteria) this;
}
public Criteria andLastProjectIdIsNotNull() {
addCriterion("last_project_id is not null");
return (Criteria) this;
}
public Criteria andLastProjectIdEqualTo(String value) {
addCriterion("last_project_id =", value, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdNotEqualTo(String value) {
addCriterion("last_project_id <>", value, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdGreaterThan(String value) {
addCriterion("last_project_id >", value, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdGreaterThanOrEqualTo(String value) {
addCriterion("last_project_id >=", value, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdLessThan(String value) {
addCriterion("last_project_id <", value, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdLessThanOrEqualTo(String value) {
addCriterion("last_project_id <=", value, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdLike(String value) {
addCriterion("last_project_id like", value, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdNotLike(String value) {
addCriterion("last_project_id not like", value, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdIn(List<String> values) {
addCriterion("last_project_id in", values, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdNotIn(List<String> values) {
addCriterion("last_project_id not in", values, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdBetween(String value1, String value2) {
addCriterion("last_project_id between", value1, value2, "lastProjectId");
return (Criteria) this;
}
public Criteria andLastProjectIdNotBetween(String value1, String value2) {
addCriterion("last_project_id not between", value1, value2, "lastProjectId");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -14,6 +14,7 @@
<result column="last_organization_id" jdbcType="VARCHAR" property="lastOrganizationId" /> <result column="last_organization_id" jdbcType="VARCHAR" property="lastOrganizationId" />
<result column="phone" jdbcType="VARCHAR" property="phone" /> <result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="source" jdbcType="VARCHAR" property="source" /> <result column="source" jdbcType="VARCHAR" property="source" />
<result column="last_project_id" jdbcType="VARCHAR" property="lastProjectId" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -75,7 +76,7 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, `name`, email, `password`, `status`, create_time, update_time, `language`, last_workspace_id, id, `name`, email, `password`, `status`, create_time, update_time, `language`, last_workspace_id,
last_organization_id, phone, `source` last_organization_id, phone, `source`, last_project_id
</sql> </sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.UserExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.metersphere.base.domain.UserExample" resultMap="BaseResultMap">
select select
@ -111,13 +112,13 @@
insert into user (id, `name`, email, insert into user (id, `name`, email,
`password`, `status`, create_time, `password`, `status`, create_time,
update_time, `language`, last_workspace_id, update_time, `language`, last_workspace_id,
last_organization_id, phone, `source` last_organization_id, phone, `source`,
) last_project_id)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{password,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{language,jdbcType=VARCHAR}, #{lastWorkspaceId,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT}, #{language,jdbcType=VARCHAR}, #{lastWorkspaceId,jdbcType=VARCHAR},
#{lastOrganizationId,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR} #{lastOrganizationId,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR},
) #{lastProjectId,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.User"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.User">
insert into user insert into user
@ -158,6 +159,9 @@
<if test="source != null"> <if test="source != null">
`source`, `source`,
</if> </if>
<if test="lastProjectId != null">
last_project_id,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -196,6 +200,9 @@
<if test="source != null"> <if test="source != null">
#{source,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR},
</if> </if>
<if test="lastProjectId != null">
#{lastProjectId,jdbcType=VARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.UserExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.base.domain.UserExample" resultType="java.lang.Long">
@ -243,6 +250,9 @@
<if test="record.source != null"> <if test="record.source != null">
`source` = #{record.source,jdbcType=VARCHAR}, `source` = #{record.source,jdbcType=VARCHAR},
</if> </if>
<if test="record.lastProjectId != null">
last_project_id = #{record.lastProjectId,jdbcType=VARCHAR},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -261,7 +271,8 @@
last_workspace_id = #{record.lastWorkspaceId,jdbcType=VARCHAR}, last_workspace_id = #{record.lastWorkspaceId,jdbcType=VARCHAR},
last_organization_id = #{record.lastOrganizationId,jdbcType=VARCHAR}, last_organization_id = #{record.lastOrganizationId,jdbcType=VARCHAR},
phone = #{record.phone,jdbcType=VARCHAR}, phone = #{record.phone,jdbcType=VARCHAR},
`source` = #{record.source,jdbcType=VARCHAR} `source` = #{record.source,jdbcType=VARCHAR},
last_project_id = #{record.lastProjectId,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -302,6 +313,9 @@
<if test="source != null"> <if test="source != null">
`source` = #{source,jdbcType=VARCHAR}, `source` = #{source,jdbcType=VARCHAR},
</if> </if>
<if test="lastProjectId != null">
last_project_id = #{lastProjectId,jdbcType=VARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -317,7 +331,8 @@
last_workspace_id = #{lastWorkspaceId,jdbcType=VARCHAR}, last_workspace_id = #{lastWorkspaceId,jdbcType=VARCHAR},
last_organization_id = #{lastOrganizationId,jdbcType=VARCHAR}, last_organization_id = #{lastOrganizationId,jdbcType=VARCHAR},
phone = #{phone,jdbcType=VARCHAR}, phone = #{phone,jdbcType=VARCHAR},
`source` = #{source,jdbcType=VARCHAR} `source` = #{source,jdbcType=VARCHAR},
last_project_id = #{lastProjectId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -15,6 +15,8 @@ import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -49,7 +51,7 @@ public class PerformanceNoticeTask {
} }
try { try {
//查询定时任务是否关闭 //查询定时任务是否关闭
Thread.sleep(1000 * 30);// 每分钟检查 loadtest 的状态 Thread.sleep(1000 * 10);// 检查 loadtest 的状态
} catch (InterruptedException e) { } catch (InterruptedException e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
} }
@ -81,7 +83,11 @@ public class PerformanceNoticeTask {
if (PerformanceTestStatus.Error.name().equals(loadTestReport.getStatus())) { if (PerformanceTestStatus.Error.name().equals(loadTestReport.getStatus())) {
event = NoticeConstants.Event.EXECUTE_FAILED; event = NoticeConstants.Event.EXECUTE_FAILED;
} }
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("testName", loadTestReport.getName());
paramMap.put("id", loadTestReport.getId());
paramMap.put("type", "performance");
paramMap.put("url", baseSystemConfigDTO.getUrl());
NoticeModel noticeModel = NoticeModel.builder() NoticeModel noticeModel = NoticeModel.builder()
.successContext(successContext) .successContext(successContext)
.successMailTemplate("PerformanceApiSuccessNotification") .successMailTemplate("PerformanceApiSuccessNotification")
@ -91,6 +97,7 @@ public class PerformanceNoticeTask {
.status(loadTestReport.getStatus()) .status(loadTestReport.getStatus())
.subject(subject) .subject(subject)
.event(event) .event(event)
.paramMap(paramMap)
.build(); .build();
noticeSendService.send(loadTestReport.getTriggerMode(), noticeModel); noticeSendService.send(loadTestReport.getTriggerMode(), noticeModel);
} }

View File

@ -0,0 +1 @@
alter table user add last_project_id varchar(50) null;

View File

@ -142,25 +142,13 @@ export default {
if (this.$route.path.split('/')[2] === 'project' && if (this.$route.path.split('/')[2] === 'project' &&
this.$route.path.split('/')[3] === 'create') { this.$route.path.split('/')[3] === 'create') {
this.create(); this.create();
// this.$router.push('/setting/project'); this.$router.replace('/setting/project/all');
} }
this.list(); this.list();
}, },
activated() { activated() {
this.list(); this.list();
}, },
watch: {
'$route'(to) {
if (this.$route.path.split('/')[2] === 'project' &&
to.path.split('/')[3] === 'create') {
this.create();
// this.$router.push('/setting/project');
} else if (this.$route.path.split('/')[2] === 'project' &&
to.path.split('/')[3] === 'all') {
this.list();
}
}
},
computed: { computed: {
currentUser: () => { currentUser: () => {
return getCurrentUser(); return getCurrentUser();
@ -177,7 +165,7 @@ export default {
return false; return false;
} }
this.title = this.$t('project.create'); this.title = this.$t('project.create');
listenGoBack(this.handleClose); // listenGoBack(this.handleClose);
this.createVisible = true; this.createVisible = true;
this.form = {}; this.form = {};
}, },
@ -245,6 +233,9 @@ export default {
handleClose() { handleClose() {
removeGoBackListener(this.handleClose); removeGoBackListener(this.handleClose);
this.createVisible = false; this.createVisible = false;
this.tapd = false;
this.jira = false;
this.zentao = false;
}, },
search() { search() {
this.list(); this.list();

@ -1 +1 @@
Subproject commit 8a972a198775b3783ed6e4cef27197e53d1ebdc8 Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a