Merge remote-tracking branch 'origin/master'

This commit is contained in:
q4speed 2020-10-19 13:00:30 +08:00
commit ff5a52d966
38 changed files with 2340 additions and 208 deletions

View File

@ -351,7 +351,17 @@
<artifactId>json</artifactId>
<version>20171018</version>
</dependency>
<!--钉钉sdk-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
</dependencies>

View File

@ -5,11 +5,13 @@ import io.metersphere.api.service.APITestService;
import io.metersphere.base.domain.ApiTestReport;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.notice.domain.NoticeDetail;
import io.metersphere.notice.service.MailService;
import io.metersphere.notice.service.NoticeService;
import io.metersphere.track.service.TestPlanTestCaseService;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.assertions.AssertionResult;
import org.apache.jmeter.samplers.SampleResult;
@ -117,6 +119,21 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
apiReportService.complete(testResult, report);
queue.clear();
super.teardownTest(context);
TestPlanTestCaseService testPlanTestCaseService = CommonBeanFactory.getBean(TestPlanTestCaseService.class);
List<String> ids = testPlanTestCaseService.getTestPlanTestCaseIds(testResult.getTestId());
if (ids.size() > 0) {
try {
if (StringUtils.equals(APITestStatus.Success.name(), report.getStatus())) {
testPlanTestCaseService.updateTestCaseStates(ids, TestPlanTestCaseStatus.Pass.name());
} else {
testPlanTestCaseService.updateTestCaseStates(ids, TestPlanTestCaseStatus.Failure.name());
}
} catch (Exception e) {
LogUtil.error(e);
}
}
NoticeService noticeService = CommonBeanFactory.getBean(NoticeService.class);
try {
List<NoticeDetail> noticeList = noticeService.queryNotice(testResult.getTestId());

View File

@ -0,0 +1,24 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
@Data
public class MessageTask implements Serializable {
private String id;
private String type;
private String event;
private String userid;
private String username;
private String tasktype;
private String webhook;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,690 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class MessageTaskExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public MessageTaskExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("`type` like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("`type` not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andEventIsNull() {
addCriterion("event is null");
return (Criteria) this;
}
public Criteria andEventIsNotNull() {
addCriterion("event is not null");
return (Criteria) this;
}
public Criteria andEventEqualTo(String value) {
addCriterion("event =", value, "event");
return (Criteria) this;
}
public Criteria andEventNotEqualTo(String value) {
addCriterion("event <>", value, "event");
return (Criteria) this;
}
public Criteria andEventGreaterThan(String value) {
addCriterion("event >", value, "event");
return (Criteria) this;
}
public Criteria andEventGreaterThanOrEqualTo(String value) {
addCriterion("event >=", value, "event");
return (Criteria) this;
}
public Criteria andEventLessThan(String value) {
addCriterion("event <", value, "event");
return (Criteria) this;
}
public Criteria andEventLessThanOrEqualTo(String value) {
addCriterion("event <=", value, "event");
return (Criteria) this;
}
public Criteria andEventLike(String value) {
addCriterion("event like", value, "event");
return (Criteria) this;
}
public Criteria andEventNotLike(String value) {
addCriterion("event not like", value, "event");
return (Criteria) this;
}
public Criteria andEventIn(List<String> values) {
addCriterion("event in", values, "event");
return (Criteria) this;
}
public Criteria andEventNotIn(List<String> values) {
addCriterion("event not in", values, "event");
return (Criteria) this;
}
public Criteria andEventBetween(String value1, String value2) {
addCriterion("event between", value1, value2, "event");
return (Criteria) this;
}
public Criteria andEventNotBetween(String value1, String value2) {
addCriterion("event not between", value1, value2, "event");
return (Criteria) this;
}
public Criteria andUseridIsNull() {
addCriterion("userId is null");
return (Criteria) this;
}
public Criteria andUseridIsNotNull() {
addCriterion("userId is not null");
return (Criteria) this;
}
public Criteria andUseridEqualTo(String value) {
addCriterion("userId =", value, "userid");
return (Criteria) this;
}
public Criteria andUseridNotEqualTo(String value) {
addCriterion("userId <>", value, "userid");
return (Criteria) this;
}
public Criteria andUseridGreaterThan(String value) {
addCriterion("userId >", value, "userid");
return (Criteria) this;
}
public Criteria andUseridGreaterThanOrEqualTo(String value) {
addCriterion("userId >=", value, "userid");
return (Criteria) this;
}
public Criteria andUseridLessThan(String value) {
addCriterion("userId <", value, "userid");
return (Criteria) this;
}
public Criteria andUseridLessThanOrEqualTo(String value) {
addCriterion("userId <=", value, "userid");
return (Criteria) this;
}
public Criteria andUseridLike(String value) {
addCriterion("userId like", value, "userid");
return (Criteria) this;
}
public Criteria andUseridNotLike(String value) {
addCriterion("userId not like", value, "userid");
return (Criteria) this;
}
public Criteria andUseridIn(List<String> values) {
addCriterion("userId in", values, "userid");
return (Criteria) this;
}
public Criteria andUseridNotIn(List<String> values) {
addCriterion("userId not in", values, "userid");
return (Criteria) this;
}
public Criteria andUseridBetween(String value1, String value2) {
addCriterion("userId between", value1, value2, "userid");
return (Criteria) this;
}
public Criteria andUseridNotBetween(String value1, String value2) {
addCriterion("userId not between", value1, value2, "userid");
return (Criteria) this;
}
public Criteria andUsernameIsNull() {
addCriterion("userName is null");
return (Criteria) this;
}
public Criteria andUsernameIsNotNull() {
addCriterion("userName is not null");
return (Criteria) this;
}
public Criteria andUsernameEqualTo(String value) {
addCriterion("userName =", value, "username");
return (Criteria) this;
}
public Criteria andUsernameNotEqualTo(String value) {
addCriterion("userName <>", value, "username");
return (Criteria) this;
}
public Criteria andUsernameGreaterThan(String value) {
addCriterion("userName >", value, "username");
return (Criteria) this;
}
public Criteria andUsernameGreaterThanOrEqualTo(String value) {
addCriterion("userName >=", value, "username");
return (Criteria) this;
}
public Criteria andUsernameLessThan(String value) {
addCriterion("userName <", value, "username");
return (Criteria) this;
}
public Criteria andUsernameLessThanOrEqualTo(String value) {
addCriterion("userName <=", value, "username");
return (Criteria) this;
}
public Criteria andUsernameLike(String value) {
addCriterion("userName like", value, "username");
return (Criteria) this;
}
public Criteria andUsernameNotLike(String value) {
addCriterion("userName not like", value, "username");
return (Criteria) this;
}
public Criteria andUsernameIn(List<String> values) {
addCriterion("userName in", values, "username");
return (Criteria) this;
}
public Criteria andUsernameNotIn(List<String> values) {
addCriterion("userName not in", values, "username");
return (Criteria) this;
}
public Criteria andUsernameBetween(String value1, String value2) {
addCriterion("userName between", value1, value2, "username");
return (Criteria) this;
}
public Criteria andUsernameNotBetween(String value1, String value2) {
addCriterion("userName not between", value1, value2, "username");
return (Criteria) this;
}
public Criteria andTasktypeIsNull() {
addCriterion("taskType is null");
return (Criteria) this;
}
public Criteria andTasktypeIsNotNull() {
addCriterion("taskType is not null");
return (Criteria) this;
}
public Criteria andTasktypeEqualTo(String value) {
addCriterion("taskType =", value, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeNotEqualTo(String value) {
addCriterion("taskType <>", value, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeGreaterThan(String value) {
addCriterion("taskType >", value, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeGreaterThanOrEqualTo(String value) {
addCriterion("taskType >=", value, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeLessThan(String value) {
addCriterion("taskType <", value, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeLessThanOrEqualTo(String value) {
addCriterion("taskType <=", value, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeLike(String value) {
addCriterion("taskType like", value, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeNotLike(String value) {
addCriterion("taskType not like", value, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeIn(List<String> values) {
addCriterion("taskType in", values, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeNotIn(List<String> values) {
addCriterion("taskType not in", values, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeBetween(String value1, String value2) {
addCriterion("taskType between", value1, value2, "tasktype");
return (Criteria) this;
}
public Criteria andTasktypeNotBetween(String value1, String value2) {
addCriterion("taskType not between", value1, value2, "tasktype");
return (Criteria) this;
}
public Criteria andWebhookIsNull() {
addCriterion("webhook is null");
return (Criteria) this;
}
public Criteria andWebhookIsNotNull() {
addCriterion("webhook is not null");
return (Criteria) this;
}
public Criteria andWebhookEqualTo(String value) {
addCriterion("webhook =", value, "webhook");
return (Criteria) this;
}
public Criteria andWebhookNotEqualTo(String value) {
addCriterion("webhook <>", value, "webhook");
return (Criteria) this;
}
public Criteria andWebhookGreaterThan(String value) {
addCriterion("webhook >", value, "webhook");
return (Criteria) this;
}
public Criteria andWebhookGreaterThanOrEqualTo(String value) {
addCriterion("webhook >=", value, "webhook");
return (Criteria) this;
}
public Criteria andWebhookLessThan(String value) {
addCriterion("webhook <", value, "webhook");
return (Criteria) this;
}
public Criteria andWebhookLessThanOrEqualTo(String value) {
addCriterion("webhook <=", value, "webhook");
return (Criteria) this;
}
public Criteria andWebhookLike(String value) {
addCriterion("webhook like", value, "webhook");
return (Criteria) this;
}
public Criteria andWebhookNotLike(String value) {
addCriterion("webhook not like", value, "webhook");
return (Criteria) this;
}
public Criteria andWebhookIn(List<String> values) {
addCriterion("webhook in", values, "webhook");
return (Criteria) this;
}
public Criteria andWebhookNotIn(List<String> values) {
addCriterion("webhook not in", values, "webhook");
return (Criteria) this;
}
public Criteria andWebhookBetween(String value1, String value2) {
addCriterion("webhook between", value1, value2, "webhook");
return (Criteria) this;
}
public Criteria andWebhookNotBetween(String value1, String value2) {
addCriterion("webhook not between", value1, value2, "webhook");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,31 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.MessageTask;
import io.metersphere.base.domain.MessageTaskExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface MessageTaskMapper {
long countByExample(MessageTaskExample example);
int deleteByExample(MessageTaskExample example);
int deleteByPrimaryKey(String id);
int insert(MessageTask record);
int insertSelective(MessageTask record);
List<MessageTask> selectByExample(MessageTaskExample example);
MessageTask selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") MessageTask record, @Param("example") MessageTaskExample example);
int updateByExample(@Param("record") MessageTask record, @Param("example") MessageTaskExample example);
int updateByPrimaryKeySelective(MessageTask record);
int updateByPrimaryKey(MessageTask record);
}

View File

@ -0,0 +1,247 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.MessageTaskMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.MessageTask">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="event" jdbcType="VARCHAR" property="event"/>
<result column="userId" jdbcType="VARCHAR" property="userid"/>
<result column="userName" jdbcType="VARCHAR" property="username"/>
<result column="taskType" jdbcType="VARCHAR" property="tasktype"/>
<result column="webhook" jdbcType="VARCHAR" property="webhook"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, `type`, event, userId, userName, taskType, webhook
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.MessageTaskExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from message_task
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from message_task
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from message_task
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.MessageTaskExample">
delete from message_task
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.MessageTask">
insert into message_task (id, `type`, event,
userId, userName, taskType,
webhook)
values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR},
#{userid,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{tasktype,jdbcType=VARCHAR},
#{webhook,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.MessageTask">
insert into message_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="type != null">
`type`,
</if>
<if test="event != null">
event,
</if>
<if test="userid != null">
userId,
</if>
<if test="username != null">
userName,
</if>
<if test="tasktype != null">
taskType,
</if>
<if test="webhook != null">
webhook,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="event != null">
#{event,jdbcType=VARCHAR},
</if>
<if test="userid != null">
#{userid,jdbcType=VARCHAR},
</if>
<if test="username != null">
#{username,jdbcType=VARCHAR},
</if>
<if test="tasktype != null">
#{tasktype,jdbcType=VARCHAR},
</if>
<if test="webhook != null">
#{webhook,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.MessageTaskExample"
resultType="java.lang.Long">
select count(*) from message_task
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update message_task
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.event != null">
event = #{record.event,jdbcType=VARCHAR},
</if>
<if test="record.userid != null">
userId = #{record.userid,jdbcType=VARCHAR},
</if>
<if test="record.username != null">
userName = #{record.username,jdbcType=VARCHAR},
</if>
<if test="record.tasktype != null">
taskType = #{record.tasktype,jdbcType=VARCHAR},
</if>
<if test="record.webhook != null">
webhook = #{record.webhook,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
update message_task
set id = #{record.id,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
event = #{record.event,jdbcType=VARCHAR},
userId = #{record.userid,jdbcType=VARCHAR},
userName = #{record.username,jdbcType=VARCHAR},
taskType = #{record.tasktype,jdbcType=VARCHAR},
webhook = #{record.webhook,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.MessageTask">
update message_task
<set>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="event != null">
event = #{event,jdbcType=VARCHAR},
</if>
<if test="userid != null">
userId = #{userid,jdbcType=VARCHAR},
</if>
<if test="username != null">
userName = #{username,jdbcType=VARCHAR},
</if>
<if test="tasktype != null">
taskType = #{tasktype,jdbcType=VARCHAR},
</if>
<if test="webhook != null">
webhook = #{webhook,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.MessageTask">
update message_task
set `type` = #{type,jdbcType=VARCHAR},
event = #{event,jdbcType=VARCHAR},
userId = #{userid,jdbcType=VARCHAR},
userName = #{username,jdbcType=VARCHAR},
taskType = #{tasktype,jdbcType=VARCHAR},
webhook = #{webhook,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -26,4 +26,9 @@ public interface ExtTestPlanTestCaseMapper {
List<TestPlanCaseDTO> getPendingTestCases(@Param("request") QueryTestPlanCaseRequest request);
List<String> getStatusByPlanId(String planId);
int updateTestCaseStates(@Param("ids") List<String> ids, @Param("reportStatus") String reportStatus);
List<String> getTestPlanTestCaseIds(String testId);
}

View File

@ -285,4 +285,24 @@
from test_plan_test_case
where plan_id = #{planId}
</select>
<select id="getTestPlanTestCaseIds" resultType="java.lang.String">
select c.id from test_case a left join test_plan_test_case c on a.id=c.case_id
<where>
<if test="testId!=null">
and a.test_id=#{testId}
</if>
</where>
</select>
<update id="updateTestCaseStates" parameterType="java.lang.String">
update test_plan_test_case
<set>
<if test="reportStatus!=null">
status=#{reportStatus,jdbcType=VARCHAR}
</if>
</set>
where id in
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
</mapper>

View File

@ -3,4 +3,11 @@ package io.metersphere.commons.constants;
public interface NoticeConstants {
String EXECUTE_SUCCESSFUL = "EXECUTE_SUCCESSFUL";
String EXECUTE_FAILED = "EXECUTE_FAILED";
String EMAIL = "EMAIL";
String NAIL_ROBOT = "NAIL_ROBOT";
String WECHAT_ROBOT = "WECHAT_ROBOT";
String CREATE = "CREATE";
String UPDATE = "CREATE";
String DELETE = "DELETE";
}

View File

@ -1,6 +1,8 @@
package io.metersphere.notice.controller;
import io.metersphere.notice.controller.request.MessageRequest;
import io.metersphere.notice.controller.request.NoticeRequest;
import io.metersphere.notice.domain.MessageSettingDetail;
import io.metersphere.notice.domain.NoticeDetail;
import io.metersphere.notice.service.NoticeService;
import org.springframework.web.bind.annotation.*;
@ -24,4 +26,19 @@ public class NoticeController {
return noticeService.queryNotice(testId);
}
@PostMapping("save/message/task")
public void saveMessage(@RequestBody MessageRequest messageRequest) {
noticeService.saveMessageTask(messageRequest);
}
@GetMapping("/search/message")
public List<MessageSettingDetail> searchMessage() {
return noticeService.searchMessage();
}
@GetMapping("/delete/message")
public void deleteMessage() {
}
}

View File

@ -0,0 +1,11 @@
package io.metersphere.notice.controller.request;
import io.metersphere.notice.domain.MessageDetail;
import lombok.Data;
import java.util.List;
@Data
public class MessageRequest {
private List<MessageDetail> messageDetail;
}

View File

@ -0,0 +1,17 @@
package io.metersphere.notice.domain;
import io.metersphere.base.domain.MessageTask;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class MessageDetail extends MessageTask {
private List<String> userIds = new ArrayList<>();
private List<String> userNames = new ArrayList<>();
private List<String> events = new ArrayList<>();
private String taskType;
private String webhook;
private String type;
}

View File

@ -0,0 +1,13 @@
package io.metersphere.notice.domain;
import lombok.Data;
import java.util.List;
@Data
public class MessageSettingDetail {
private List<MessageDetail> jenkinsTask;
private List<MessageDetail> testCasePlanTask;
private List<MessageDetail> reviewTask;
private List<MessageDetail> defectTask;
}

View File

@ -0,0 +1,45 @@
package io.metersphere.notice.message;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
public class LinkMessage implements Message {
private String title;
private String text;
private String picUrl;
private String messageUrl;
public String toJsonString() {
Map<String, Object> items = new HashMap<String, Object>();
items.put("msgtype", "link");
Map<String, String> linkContent = new HashMap<String, String>();
if (StringUtils.isBlank(title)) {
throw new IllegalArgumentException("title should not be blank");
}
linkContent.put("title", title);
if (StringUtils.isBlank(messageUrl)) {
throw new IllegalArgumentException("messageUrl should not be blank");
}
linkContent.put("messageUrl", messageUrl);
if (StringUtils.isBlank(text)) {
throw new IllegalArgumentException("text should not be blank");
}
linkContent.put("text", text);
if (StringUtils.isNotBlank(picUrl)) {
linkContent.put("picUrl", picUrl);
}
items.put("link", linkContent);
return JSON.toJSONString(items);
}
}

View File

@ -0,0 +1,5 @@
package io.metersphere.notice.message;
public interface Message {
String toJsonString();
}

View File

@ -0,0 +1,64 @@
package io.metersphere.notice.message;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TextMessage implements Message {
private String text;
private List<String> mentionedMobileList;
private boolean isAtAll;
public TextMessage(String text) {
this.text = text;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public boolean isAtAll() {
return isAtAll;
}
public void setIsAtAll(boolean isAtAll) {
this.isAtAll = isAtAll;
}
public List<String> getMentionedMobileList() {
return mentionedMobileList;
}
public void setMentionedMobileList(List<String> mentionedMobileList) {
this.mentionedMobileList = mentionedMobileList;
}
public String toJsonString() {
Map<String, Object> items = new HashMap<String, Object>();
items.put("msgtype", "text");
Map<String, Object> textContent = new HashMap<String, Object>();
if (StringUtils.isBlank(text)) {
throw new IllegalArgumentException("text should not be blank");
}
textContent.put("content", text);
if (isAtAll) {
if (mentionedMobileList == null) mentionedMobileList = new ArrayList<String>();
mentionedMobileList.add("@all");
}
if (mentionedMobileList != null && !mentionedMobileList.isEmpty()) {
textContent.put("mentioned_mobile_list", mentionedMobileList);
}
items.put("text", textContent);
return JSON.toJSONString(items);
}
}

View File

@ -0,0 +1,34 @@
package io.metersphere.notice.service;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.dingtalk.api.response.OapiRobotSendResponse;
import com.taobao.api.ApiException;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Service
public class DingTaskService {
public void sendDingTask(String context, List<String> userIds) {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=5129dc4c073d28f67c7452e0de6536c3ca496728d8c014d0a209b88a8814307a");
OapiRobotSendRequest request = new OapiRobotSendRequest();
request.setMsgtype("text");
OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
text.setContent(context);
request.setText(text);
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
at.setAtMobiles(Arrays.asList("15135125273"));
request.setAt(at);
OapiRobotSendResponse response = null;
try {
response = client.execute(request);
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println(response.getErrcode());
}
}

View File

@ -95,6 +95,7 @@ public class MailService {
try {
javaMailSender.send(mimeMessage);
} catch (MailException e) {
LogUtil.error(e);
LogUtil.error("Failed to send mail");
}
}
@ -249,5 +250,6 @@ public class MailService {
return recipientEmails;
}
}

View File

@ -1,9 +1,14 @@
package io.metersphere.notice.service;
import io.metersphere.base.domain.MessageTask;
import io.metersphere.base.domain.MessageTaskExample;
import io.metersphere.base.domain.Notice;
import io.metersphere.base.domain.NoticeExample;
import io.metersphere.base.mapper.MessageTaskMapper;
import io.metersphere.base.mapper.NoticeMapper;
import io.metersphere.notice.controller.request.MessageRequest;
import io.metersphere.notice.controller.request.NoticeRequest;
import io.metersphere.notice.domain.MessageSettingDetail;
import io.metersphere.notice.domain.NoticeDetail;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
@ -20,6 +25,8 @@ import static io.metersphere.commons.constants.NoticeConstants.EXECUTE_SUCCESSFU
public class NoticeService {
@Resource
private NoticeMapper noticeMapper;
@Resource
private MessageTaskMapper messageTaskMapper;
public void saveNotice(NoticeRequest noticeRequest) {
NoticeExample example = new NoticeExample();
@ -78,4 +85,32 @@ public class NoticeService {
return result;
}
}
public void saveMessageTask(MessageRequest messageRequest) {
messageRequest.getMessageDetail().forEach(list -> {
list.getEvents().forEach(n -> {
list.getUserIds().forEach(m -> {
MessageTask message = new MessageTask();
message.setId(UUID.randomUUID().toString());
message.setEvent(n);
message.setTasktype(list.getTaskType());
message.setUserid(m);
message.setType(list.getType());
message.setUsername("a");
message.setWebhook(list.getWebhook());
messageTaskMapper.insert(message);
});
});
});
}
public List<MessageSettingDetail> searchMessage() {
MessageTaskExample messageTaskExample = new MessageTaskExample();
messageTaskExample.createCriteria();
List<MessageTask> messageTasks = new ArrayList<>();
List<MessageSettingDetail> messageSettingDetail = new ArrayList<>();
messageTasks = messageTaskMapper.selectByExample(messageTaskExample);
return messageSettingDetail;
}
}

View File

@ -0,0 +1,27 @@
package io.metersphere.notice.service;
import io.metersphere.notice.message.TextMessage;
import io.metersphere.notice.util.SendResult;
import io.metersphere.notice.util.WxChatbotClient;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Service
public class WxChatTaskService {
public void enterpriseWechatTask() {
TextMessage message = new TextMessage("脸给你打歪");
List<String> mentionedMobileList = new ArrayList<String>();
mentionedMobileList.add("15135125273");//@群内成员 手机号
message.setMentionedMobileList(mentionedMobileList);
message.setIsAtAll(true);//@所有人
try {
SendResult result = WxChatbotClient.send("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a03acc34-4988-4200-a9c7-7c9b30c5601e", message);
System.out.println(result);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,47 @@
package io.metersphere.notice.util;
import com.alibaba.fastjson.JSON;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public class SendResult {
private boolean isSuccess;
private Integer errorCode;
private String errorMsg;
public boolean isSuccess() {
return isSuccess;
}
public void setIsSuccess(boolean isSuccess) {
this.isSuccess = isSuccess;
}
public Integer getErrorCode() {
return errorCode;
}
public void setErrorCode(Integer errorCode) {
this.errorCode = errorCode;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public String toString() {
Map<String, Object> items = new HashMap<String, Object>();
items.put("errorCode", errorCode);
items.put("errorMsg", errorMsg);
items.put("isSuccess", isSuccess);
return JSON.toJSONString(items);
}
}

View File

@ -0,0 +1,50 @@
package io.metersphere.notice.util;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.notice.message.Message;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
/**
*
*/
public class WxChatbotClient {
static HttpClient httpclient = HttpClients.createDefault();
public static SendResult send(String webhook, Message message) throws IOException {
if (StringUtils.isBlank(webhook)) {
return new SendResult();
}
HttpPost httppost = new HttpPost(webhook);
httppost.addHeader("Content-Type", "application/json; charset=utf-8");
StringEntity se = new StringEntity(message.toJsonString(), "utf-8");
httppost.setEntity(se);
SendResult sendResult = new SendResult();
HttpResponse response = httpclient.execute(httppost);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String result = EntityUtils.toString(response.getEntity());
JSONObject obj = JSONObject.parseObject(result);
Integer errcode = obj.getInteger("errcode");
sendResult.setErrorCode(errcode);
sendResult.setErrorMsg(obj.getString("errmsg"));
sendResult.setIsSuccess(errcode.equals(0));
}
return sendResult;
}
}

View File

@ -13,6 +13,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@ -132,7 +133,7 @@ public class FileService {
final List<TestCaseFile> testCaseFiles = testCaseFileMapper.selectByExample(testCaseFileExample);
if (CollectionUtils.isEmpty(testCaseFiles)) {
return null;
return new ArrayList<>();
}
List<String> fileIds = testCaseFiles.stream().map(TestCaseFile::getFileId).collect(Collectors.toList());

View File

@ -8,10 +8,15 @@ import io.metersphere.base.mapper.TestCaseCommentMapper;
import io.metersphere.base.mapper.TestCaseMapper;
import io.metersphere.base.mapper.TestCaseReviewMapper;
import io.metersphere.base.mapper.UserMapper;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.notice.service.DingTaskService;
import io.metersphere.notice.service.MailService;
import io.metersphere.notice.service.WxChatTaskService;
import io.metersphere.track.request.testreview.SaveCommentRequest;
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -34,6 +39,10 @@ public class TestCaseCommentService {
MailService mailService;
@Resource
TestCaseMapper testCaseMapper;
@Resource
DingTaskService dingTaskService;
@Resource
WxChatTaskService wxChatTaskService;
public void saveComment(SaveCommentRequest request) {
TestCaseComment testCaseComment = new TestCaseComment();
@ -49,7 +58,18 @@ public class TestCaseCommentService {
SaveTestCaseReviewRequest caseReviewRequest = new SaveTestCaseReviewRequest();
List<String> userIds = new ArrayList<>();
userIds.add(testCaseWithBLOBs.getMaintainer());
mailService.sendCommentNotice(userIds, request, testCaseWithBLOBs);
String context = getReviewContext(request, testCaseWithBLOBs);
try {
if (StringUtils.equals(NoticeConstants.NAIL_ROBOT, "NAIL_ROBOT")) {
dingTaskService.sendDingTask(context, userIds);
} else if (StringUtils.equals(NoticeConstants.WECHAT_ROBOT, "WECHAT_ROBOT")) {
wxChatTaskService.enterpriseWechatTask();
} else {
mailService.sendCommentNotice(userIds, request, testCaseWithBLOBs);
}
} catch (Exception e) {
LogUtil.error(e);
}
}
@ -72,4 +92,10 @@ public class TestCaseCommentService {
testCaseCommentExample.createCriteria().andCaseIdEqualTo(caseId);
testCaseCommentMapper.deleteByExample(testCaseCommentExample);
}
private String getReviewContext(SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
String context = "";
context = testCaseWithBLOBs.getMaintainer() + "发起的" + "'" + testCaseWithBLOBs.getName() + "'" + "添加评论:" + request.getDescription();
return context;
}
}

View File

@ -6,17 +6,18 @@ import io.metersphere.base.mapper.ext.ExtProjectMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseReviewMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.TestCaseReviewStatus;
import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.constants.TestReviewCaseStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.MathUtils;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.notice.service.DingTaskService;
import io.metersphere.notice.service.MailService;
import io.metersphere.notice.service.WxChatTaskService;
import io.metersphere.service.UserService;
import io.metersphere.track.dto.TestCaseReviewDTO;
import io.metersphere.track.dto.TestReviewCaseDTO;
@ -36,7 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -72,6 +73,10 @@ public class TestCaseReviewService {
MailService mailService;
@Resource
ExtTestCaseMapper extTestCaseMapper;
@Resource
DingTaskService dingTaskService;
@Resource
WxChatTaskService wxChatTaskService;
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
checkCaseReviewExist(reviewRequest);
@ -99,8 +104,15 @@ public class TestCaseReviewService {
reviewRequest.setCreator(SessionUtils.getUser().getId());
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
testCaseReviewMapper.insert(reviewRequest);
String context = getReviewContext(reviewRequest, "create");
try {
mailService.sendReviewerNotice(userIds, reviewRequest);
if (StringUtils.equals(NoticeConstants.NAIL_ROBOT, "NAIL_ROBOT")) {
dingTaskService.sendDingTask(context, userIds);
} else if (StringUtils.equals(NoticeConstants.WECHAT_ROBOT, "WECHAT_ROBOT")) {
wxChatTaskService.enterpriseWechatTask();
} else {
mailService.sendReviewerNotice(userIds, reviewRequest);
}
} catch (Exception e) {
LogUtil.error(e);
}
@ -374,7 +386,14 @@ public class TestCaseReviewService {
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
try {
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
mailService.sendEndNotice(userIds, testCaseReviewRequest);
String context = getReviewContext(testCaseReviewRequest, "create");
if (StringUtils.equals(NoticeConstants.NAIL_ROBOT, "NAIL_ROBOT")) {
dingTaskService.sendDingTask(context, userIds);
} else if (StringUtils.equals(NoticeConstants.WECHAT_ROBOT, "WECHAT_ROBOT")) {
wxChatTaskService.enterpriseWechatTask();
} else {
mailService.sendEndNotice(userIds, testCaseReviewRequest);
}
} catch (Exception e) {
LogUtil.error(e);
}
@ -465,4 +484,28 @@ public class TestCaseReviewService {
request.setProjectIds(projectIds);
return extTestReviewCaseMapper.list(request);
}
private String getReviewContext(SaveTestCaseReviewRequest reviewRequest, String type) {
Long startTime = reviewRequest.getCreateTime();
Long endTime = reviewRequest.getEndTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String start = null;
String sTime = String.valueOf(startTime);
String eTime = String.valueOf(endTime);
if (!sTime.equals("null")) {
start = sdf.format(new Date(Long.parseLong(sTime)));
}
String end = null;
if (!eTime.equals("null")) {
end = sdf.format(new Date(Long.parseLong(eTime)));
}
String context = "";
if (StringUtils.equals("create", type)) {
context = reviewRequest.getCreator() + "发起的" + "'" + reviewRequest.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进";
} else if (StringUtils.equals("end", type)) {
context = reviewRequest.getCreator() + "发起的" + "'" + reviewRequest.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成";
}
return context;
}
}

View File

@ -140,4 +140,12 @@ public class TestPlanTestCaseService {
example.createCriteria().andIdIn(request.getIds());
testPlanTestCaseMapper.deleteByExample(example);
}
public List<String> getTestPlanTestCaseIds(String testId) {
return extTestPlanTestCaseMapper.getTestPlanTestCaseIds(testId);
}
public int updateTestCaseStates(List<String> ids, String reportStatus) {
return extTestPlanTestCaseMapper.updateTestCaseStates(ids, reportStatus);
}
}

View File

@ -15,10 +15,12 @@ import io.metersphere.track.dto.TestReviewCaseDTO;
import io.metersphere.track.request.testplancase.TestReviewCaseBatchRequest;
import io.metersphere.track.request.testreview.DeleteRelevanceRequest;
import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
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.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -64,17 +66,17 @@ public class TestReviewTestCaseService {
return testCaseReviewUsers.stream().map(TestCaseReviewUsers::getUserId).collect(Collectors.toList());
}
private String getReviewName(List<String> userIds, Map userMap) {
StringBuilder stringBuilder = new StringBuilder();
String name = "";
private String getReviewName(List<String> userIds, Map<String, String> userMap) {
List<String> userNames = new ArrayList<>();
if (userIds.size() > 0) {
for (String id : userIds) {
stringBuilder.append(userMap.get(id)).append("");
String n = userMap.get(id);
if (StringUtils.isNotBlank(n)) {
userNames.add(n);
}
}
name = stringBuilder.toString().substring(0, stringBuilder.length() - 1);
}
return name;
return StringUtils.join(userNames, "");
}
public int deleteTestCase(DeleteRelevanceRequest request) {

View File

@ -95,11 +95,12 @@ public class XmindCaseParser {
}
String path = "";
for (int i = 0; i < nodes.length; i++) {
path += nodes[i].trim() + "/";
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
process.append(path + "" + Translator.get("module_not_null") + "; ");
process.append(Translator.get("module") + ":【" + path + "" + Translator.get("module_not_null") + "; ");
} else if (nodes[i].trim().length() > 30) {
process.append(nodes[i].trim() + "" + Translator.get("test_track.length_less_than") + "30 ;");
} else {
path += nodes[i].trim() + "/";
}
}
});
@ -124,7 +125,7 @@ public class XmindCaseParser {
}
for (int i = 0; i < nodes.length; i++) {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
stringBuilder.append(Translator.get("test_case") + "" + data.getName() + Translator.get("module_not_null") + "; ");
stringBuilder.append(Translator.get("test_case") + ":【" + data.getName() + "" + Translator.get("module_not_null") + "; ");
break;
} else if (nodes[i].trim().length() > 30) {
stringBuilder.append(nodes[i].trim() + "" + Translator.get("module") + Translator.get("test_track.length_less_than") + "30 ;");

View File

@ -0,0 +1,12 @@
create table message_task
(
id varchar(255) not null,
type varchar(255) not null comment '消息类型',
event varchar(255) not null comment '通知事件类型',
userId varchar(500) not null comment '接收人id',
userName varchar(500) not null comment '接收人姓名',
taskType varchar(255) not null,
webhook varchar(255) not null comment 'webhook地址',
constraint message_manage_pk
primary key (id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -0,0 +1 @@
alter table test_case modify prerequisite varchar(500) null comment 'Test case prerequisite condition';

View File

@ -139,9 +139,9 @@ export default {
{text: 'Error', value: 'Error'}
],
triggerFilters: [
{text: '手动', value: 'MANUAL'},
{text: '定时任务', value: 'SCHEDULE'},
{text: 'API', value: 'API'}
{text: this.$t('commons.trigger_mode.manual'), value: 'MANUAL'},
{text: this.$t('commons.trigger_mode.schedule'), value: 'SCHEDULE'},
{text: this.$t('commons.trigger_mode.api'), value: 'API'}
],
buttons: [
{

View File

@ -1,7 +1,7 @@
<template>
<div class="header-title" v-loading="result.loading">
<div>
<div>{{$t('organization.integration.select_defect_platform')}}</div>
<div>{{ $t('organization.integration.select_defect_platform') }}</div>
<el-radio-group v-model="platform" style="margin-top: 10px" @change="change">
<el-radio label="Tapd">
<img class="platform" src="../../../../assets/tapd.png" alt="Tapd"/>
@ -13,7 +13,7 @@
</div>
<div style="width: 500px">
<div style="margin-top: 20px;margin-bottom: 10px">{{$t('organization.integration.basic_auth_info')}}</div>
<div style="margin-top: 20px;margin-bottom: 10px">{{ $t('organization.integration.basic_auth_info') }}</div>
<el-form :model="form" ref="form" label-width="120px" size="small" :disabled="show" :rules="rules">
<el-form-item :label="$t('organization.integration.api_account')" prop="account">
<el-input v-model="form.account" :placeholder="$t('organization.integration.input_api_account')"/>
@ -25,36 +25,37 @@
<el-form-item :label="$t('organization.integration.jira_url')" prop="url" v-if="platform === 'Jira'">
<el-input v-model="form.url" :placeholder="$t('organization.integration.input_jira_url')"/>
</el-form-item>
<el-form-item :label="$t('organization.integration.jira_issuetype')" prop="issuetype" v-if="platform === 'Jira'">
<el-form-item :label="$t('organization.integration.jira_issuetype')" prop="issuetype"
v-if="platform === 'Jira'">
<el-input v-model="form.issuetype" :placeholder="$t('organization.integration.input_jira_issuetype')"/>
</el-form-item>
</el-form>
</div>
<div style="margin-left: 120px">
<el-button type="primary" size="mini" :disabled="!show" @click="testConnection">{{$t('ldap.test_connect')}}
<el-button type="primary" size="mini" :disabled="!show" @click="testConnection">{{ $t('ldap.test_connect') }}
</el-button>
<el-button v-if="showEdit" size="mini" @click="edit">{{$t('commons.edit')}}</el-button>
<el-button type="primary" v-if="showSave" size="mini" @click="save('form')">{{$t('commons.save')}}</el-button>
<el-button v-if="showCancel" size="mini" @click="cancelEdit">{{$t('organization.integration.cancel_edit')}}
<el-button v-if="showEdit" size="mini" @click="edit">{{ $t('commons.edit') }}</el-button>
<el-button type="primary" v-if="showSave" size="mini" @click="save('form')">{{ $t('commons.save') }}</el-button>
<el-button v-if="showCancel" size="mini" @click="cancelEdit">{{ $t('organization.integration.cancel_edit') }}
</el-button>
<el-button type="info" size="mini" @click="cancelIntegration('form')" :disabled="!show">
{{$t('organization.integration.cancel_integration')}}
{{ $t('organization.integration.cancel_integration') }}
</el-button>
</div>
<div class="defect-tip">
<div>{{$t('organization.integration.use_tip')}}</div>
<div>{{ $t('organization.integration.use_tip') }}</div>
<div>
1. {{$t('organization.integration.use_tip_tapd')}}
1. {{ $t('organization.integration.use_tip_tapd') }}
</div>
<div>
2. {{$t('organization.integration.use_tip_jira')}}
2. {{ $t('organization.integration.use_tip_jira') }}
</div>
<div>
3. {{$t('organization.integration.use_tip_two')}}
3. {{ $t('organization.integration.use_tip_two') }}
<router-link to="/track/project/all" style="margin-left: 5px">
{{$t('organization.integration.link_the_project_now')}}
{{ $t('organization.integration.link_the_project_now') }}
</router-link>
</div>
</div>
@ -62,197 +63,197 @@
</template>
<script>
import {getCurrentUser} from "../../../../common/js/utils";
import {getCurrentUser} from "../../../../common/js/utils";
export default {
name: "IssuesManagement",
data() {
return {
form: {},
result: {},
platform: '',
orgId: '',
show: true,
showEdit: true,
showSave: false,
showCancel: false,
rules: {
account: {
required: true,
message: this.$t('organization.integration.input_api_account'),
trigger: ['change', 'blur']
},
password: {
required: true,
message: this.$t('organization.integration.input_api_password'),
trigger: ['change', 'blur']
},
url: {
required: true,
message: this.$t('organization.integration.input_jira_url'),
trigger: ['change', 'blur']
},
issuetype: {
required: true,
message: this.$t('organization.integration.input_jira_issuetype'),
trigger: ['change', 'blur']
}
export default {
name: "IssuesManagement",
data() {
return {
form: {},
result: {},
platform: '',
orgId: '',
show: true,
showEdit: true,
showSave: false,
showCancel: false,
rules: {
account: {
required: true,
message: this.$t('organization.integration.input_api_account'),
trigger: ['change', 'blur']
},
}
password: {
required: true,
message: this.$t('organization.integration.input_api_password'),
trigger: ['change', 'blur']
},
url: {
required: true,
message: this.$t('organization.integration.input_jira_url'),
trigger: ['change', 'blur']
},
issuetype: {
required: true,
message: this.$t('organization.integration.input_jira_issuetype'),
trigger: ['change', 'blur']
}
},
}
},
created() {
this.init(this.platform);
},
methods: {
init(platform) {
let param = {};
param.platform = platform;
param.orgId = getCurrentUser().lastOrganizationId;
this.result = this.$post("service/integration/type", param, response => {
let data = response.data;
this.platform = data.platform;
if (data.configuration) {
let config = JSON.parse(data.configuration);
this.$set(this.form, 'account', config.account);
this.$set(this.form, 'password', config.password);
this.$set(this.form, 'url', config.url);
this.$set(this.form, 'issuetype', config.issuetype);
} else {
this.clear();
}
})
},
created() {
edit() {
this.show = false;
this.showEdit = false;
this.showSave = true;
this.showCancel = true;
},
cancelEdit() {
this.showEdit = true;
this.showCancel = false;
this.showSave = false;
this.show = true;
this.init(this.platform);
},
methods: {
init(platform) {
let param = {};
param.platform = platform;
param.orgId = getCurrentUser().lastOrganizationId;
this.result = this.$post("service/integration/type", param, response => {
let data = response.data;
this.platform = data.platform;
if (data.configuration) {
let config = JSON.parse(data.configuration);
this.$set(this.form, 'account', config.account);
this.$set(this.form, 'password', config.password);
this.$set(this.form, 'url', config.url);
this.$set(this.form, 'issuetype', config.issuetype);
} else {
this.clear();
}
})
},
edit() {
this.show = false;
this.showEdit = false;
this.showSave = true;
this.showCancel = true;
},
cancelEdit() {
this.showEdit = true;
this.showCancel = false;
this.showSave = false;
this.show = true;
this.init(this.platform);
},
cancelIntegration() {
if (this.form.account && this.form.password && this.platform) {
cancelIntegration() {
if (this.form.account && this.form.password && this.platform) {
this.$alert(this.$t('organization.integration.cancel_confirm') + this.platform + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let param = {};
param.orgId = getCurrentUser().lastOrganizationId;
param.platform = this.platform;
this.result = this.$post("service/integration/delete", param, () => {
this.$success(this.$t('organization.integration.successful_operation'));
this.init('');
});
}
this.$alert(this.$t('organization.integration.cancel_confirm') + this.platform + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let param = {};
param.orgId = getCurrentUser().lastOrganizationId;
param.platform = this.platform;
this.result = this.$post("service/integration/delete", param, () => {
this.$success(this.$t('organization.integration.successful_operation'));
this.init('');
});
}
});
} else {
this.$warning(this.$t('organization.integration.not_integrated'));
}
},
save(form) {
if (!this.platform) {
this.$warning(this.$t('organization.integration.choose_platform'));
return;
}
this.$refs[form].validate(valid => {
if (valid) {
let formatUrl = this.form.url.trim();
if (!formatUrl.endsWith('/')) {
formatUrl = formatUrl + '/';
}
let param = {};
let auth = {
account: this.form.account,
password: this.form.password,
url: formatUrl,
issuetype: this.form.issuetype
};
param.organizationId = getCurrentUser().lastOrganizationId;
param.platform = this.platform;
param.configuration = JSON.stringify(auth);
this.result = this.$post("service/integration/save", param, () => {
this.show = true;
this.showEdit = true;
this.showSave = false;
this.showCancel = false;
this.init(this.platform);
this.$success(this.$t('commons.save_success'));
});
} else {
return false;
}
})
},
change(platform) {
this.show = true;
this.showEdit = true;
this.showCancel = false;
this.showSave = false;
let param = {};
param.orgId = getCurrentUser().lastOrganizationId;
param.platform = platform;
this.result = this.$post("service/integration/type", param, response => {
let data = response.data;
if (data.configuration) {
let config = JSON.parse(data.configuration);
this.$set(this.form, 'account', config.account);
this.$set(this.form, 'password', config.password);
this.$set(this.form, 'url', config.url);
this.$set(this.form, 'issuetype', config.issuetype);
} else {
this.clear();
}
})
},
clear() {
this.$set(this.form, 'account', '');
this.$set(this.form, 'password', '');
this.$set(this.form, 'url', '');
this.$set(this.form, 'issuetype', '');
this.$nextTick(() => {
this.$refs.form.clearValidate();
});
},
testConnection() {
if (this.form.account && this.form.password && this.platform) {
this.result = this.$get("issues/auth/" + this.platform, () => {
this.$success(this.$t('organization.integration.verified'));
} else {
this.$warning(this.$t('organization.integration.not_integrated'));
}
},
save(form) {
if (!this.platform) {
this.$warning(this.$t('organization.integration.choose_platform'));
return;
}
this.$refs[form].validate(valid => {
if (valid) {
let formatUrl = this.form.url.trim();
if (!formatUrl.endsWith('/')) {
formatUrl = formatUrl + '/';
}
let param = {};
let auth = {
account: this.form.account,
password: this.form.password,
url: formatUrl,
issuetype: this.form.issuetype
};
param.organizationId = getCurrentUser().lastOrganizationId;
param.platform = this.platform;
param.configuration = JSON.stringify(auth);
this.result = this.$post("service/integration/save", param, () => {
this.show = true;
this.showEdit = true;
this.showSave = false;
this.showCancel = false;
this.init(this.platform);
this.$success(this.$t('commons.save_success'));
});
} else {
this.$warning(this.$t('organization.integration.not_integrated'));
return false;
}
})
},
change(platform) {
this.show = true;
this.showEdit = true;
this.showCancel = false;
this.showSave = false;
let param = {};
param.orgId = getCurrentUser().lastOrganizationId;
param.platform = platform;
this.result = this.$post("service/integration/type", param, response => {
let data = response.data;
if (data.configuration) {
let config = JSON.parse(data.configuration);
this.$set(this.form, 'account', config.account);
this.$set(this.form, 'password', config.password);
this.$set(this.form, 'url', config.url);
this.$set(this.form, 'issuetype', config.issuetype);
} else {
this.clear();
}
})
},
clear() {
this.$set(this.form, 'account', '');
this.$set(this.form, 'password', '');
this.$set(this.form, 'url', '');
this.$set(this.form, 'issuetype', '');
this.$nextTick(() => {
this.$refs.form.clearValidate();
});
},
testConnection() {
if (this.form.account && this.form.password && this.platform) {
this.result = this.$get("issues/auth/" + this.platform, () => {
this.$success(this.$t('organization.integration.verified'));
});
} else {
this.$warning(this.$t('organization.integration.not_integrated'));
return false;
}
}
}
}
</script>
<style scoped>
.header-title {
padding: 10px 30px;
}
.header-title {
padding: 10px 30px;
}
.defect-tip {
background: #EDEDED;
border: solid #E1E1E1 1px;
margin: 10px 0;
padding: 10px;
border-radius: 3px;
}
.defect-tip {
background: #EDEDED;
border: solid #E1E1E1 1px;
margin: 10px 0;
padding: 10px;
border-radius: 3px;
}
.platform {
height: 90px;
vertical-align: middle
}
.platform {
height: 90px;
vertical-align: middle
}
</style>

View File

@ -0,0 +1,31 @@
<template>
<div>
<el-card>
<el-tabs class="system-setting" v-model="activeName">
<el-tab-pane :label="$t('organization.message_settings')" name="message">
<message-notification/>
</el-tab-pane>
</el-tabs>
</el-card>
</div>
</template>
<script>
import MessageNotification from "./TaskNotification"
export default {
name: "MessageSettings",
components: {
MessageNotification
},
data(){
return{
activeName: 'message'
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,537 @@
<template>
<div style="margin-left: 40px">
<el-form :model="form" ref="from">
<el-row class="row">
<el-col :span="20">
<div class="grid-content bg-purple-dark">
<el-row>
<el-col :span="6">
<span style="font-weight:bold;">{{ $t('organization.message.jenkins_task_notification') }}</span>
</el-col>
<el-col :span="14">
<el-button type="text" icon="el-icon-plus" size="mini"
@click="handleAddTaskModel('jenkinsTask')">
{{ $t('organization.message.create_new_notification') }}
</el-button>
</el-col>
</el-row>
</div>
<el-table
:data="form.jenkinsTask"
class="tb-edit"
border
size="mini"
:header-cell-style="{background:'#EDEDED'}"
>
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
<template slot-scope="scope">
<el-select v-model="scope.row.events" multiple :placeholder="$t('organization.message.select_events')"
prop="events">
<el-option
v-for="item in jenkinsEventOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column :label="$t('schedule.receiver')" prop="userIds" min-width="20%">
<template v-slot:default="{row}">
<el-select v-model="row.userIds" filterable multiple
:placeholder="$t('commons.please_select')"
@click.native="userList()" style="width: 100%;">
<el-option
v-for="item in jenkinsReceiverOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
<template slot-scope="scope">
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')">
<el-option
v-for="item in receiveTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="webhook" min-width="20%" prop="webhook">
<template v-slot:default="scope">
<el-input v-model="scope.row.webhook" placeholder="webhook地址"></el-input>
</template>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
<template v-slot:default="scope">
<el-button
type="primary"
size="mini"
v-show="scope.row.result.showSave"
@click="handleAddTask(scope.$index,scope.row)"
>{{ $t('commons.add') }}
</el-button>
<el-button
size="mini"
v-show="scope.row.result.showCancel"
@click.native.prevent="removeRowTask(scope.$index,form.jenkinsTask)"
>{{ $t('commons.cancel') }}
</el-button>
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
v-show="scope.row.result.showDelete"
@click.native.prevent="deleteRowTask(scope.$index,form.jenkinsTask)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<el-row class="row">
<el-col :span="20">
<div class="grid-content bg-purple-dark">
<el-row>
<el-col :span="6">
<span style="font-weight:bold;">{{ $t('organization.message.test_plan_task_notification') }}</span>
</el-col>
<el-col :span="14">
<el-button type="text" icon="el-icon-plus" size="mini" @click="handleAddTaskModel('testPlanTask')">
{{ $t('organization.message.create_new_notification') }}
</el-button>
</el-col>
</el-row>
</div>
<el-table
:data="form.testPlanTask"
class="tb-edit"
border
size="mini"
:header-cell-style="{background:'#EDEDED'}"
>
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
<template slot-scope="scope">
<el-select v-model="scope.row.events" multiple :placeholder="$t('organization.message.select_events')"
prop="events">
<el-option
v-for="item in otherEventOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column :label="$t('schedule.receiver')" prop="userIds" min-width="20%">
<template v-slot:default="{row}">
<el-select v-model="row.userIds" filterable multiple
:placeholder="$t('commons.please_select')"
@click.native="defectAndTestPlanUserList()" style="width: 100%;">
<el-option
v-for="item in testPlanReceiverOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
<template slot-scope="scope">
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')">
<el-option
v-for="item in receiveTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="webhook" min-width="20%" prop="webhook">
<template v-slot:default="scope">
<el-input v-model="scope.row.webhook" placeholder="webhook地址"></el-input>
</template>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
<template v-slot:default="scope">
<el-button
type="primary"
size="mini"
v-show="scope.row.result.showSave"
@click="handleAddTask(scope.$index,scope.row)"
>{{ $t('commons.add') }}
</el-button>
<el-button
size="mini"
v-show="scope.row.result.showCancel"
@click.native.prevent="removeRowTask(scope.$index,form.testPlanTask)"
>{{ $t('commons.cancel') }}
</el-button>
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
v-show="scope.row.result.showDelete"
@click.native.prevent="deleteRowTask(scope.$index,form.testPlanTask)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<el-row class="row">
<el-col :span="20">
<div class="grid-content bg-purple-dark">
<el-row>
<el-col :span="6">
<span style="font-weight:bold;">{{ $t('organization.message.test_review_task_notice') }}</span>
</el-col>
<el-col :span="14">
<el-button type="text" icon="el-icon-plus" size="mini" @click="handleAddTaskModel('reviewTask')">
{{ $t('organization.message.create_new_notification') }}
</el-button>
</el-col>
</el-row>
</div>
<el-table
:data="form.reviewTask"
class="tb-edit"
border
size="mini"
:header-cell-style="{background:'#EDEDED'}"
>
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
<template slot-scope="scope">
<el-select v-model="scope.row.events" multiple :placeholder="$t('organization.message.select_events')"
prop="event">
<el-option
v-for="item in otherEventOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column :label="$t('schedule.receiver')" prop="receiver" min-width="20%">
<template v-slot:default="{row}">
<el-select v-model="row.userIds" filterable multiple
:placeholder="$t('commons.please_select')"
@click.native="reviewUerList()" style="width: 100%;">
<el-option
v-for="item in reviewReceiverOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
<template slot-scope="scope">
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')">
<el-option
v-for="item in receiveTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="webhook" min-width="20%" prop="webhook">
<template v-slot:default="scope">
<el-input v-model="scope.row.webhook" placeholder="webhook地址"></el-input>
</template>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
<template v-slot:default="scope">
<el-button
type="primary"
size="mini"
v-show="scope.row.result.showSave"
@click="handleAddTask(scope.$index,scope.row)"
>{{ $t('commons.add') }}
</el-button>
<el-button
size="mini"
v-show="scope.row.result.showCancel"
@click.native.prevent="removeRowTask(scope.$index,form.reviewTask)"
>{{ $t('commons.cancel') }}
</el-button>
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
v-show="scope.row.result.showDelete"
@click.native.prevent="deleteRowTask(scope.$index,form.reviewTask)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<el-row class="row">
<el-col :span="20">
<div class="grid-content bg-purple-dark">
<el-row>
<el-col :span="6">
<span style="font-weight:bold;">{{ $t('organization.message.defect_task_notification') }}</span>
</el-col>
<el-col :span="14">
<el-button type="text" icon="el-icon-plus" size="mini" @click="handleAddTaskModel('defectTask')">
{{ $t('organization.message.create_new_notification') }}
</el-button>
</el-col>
</el-row>
</div>
<el-table
:data="form.defectTask"
class="tb-edit"
border
size="mini"
:header-cell-style="{background:'#EDEDED'}"
>
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
<template slot-scope="scope">
<el-select v-model="scope.row.events" multiple :placeholder="$t('organization.message.select_events')"
prop="event">
<el-option
v-for="item in otherEventOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column :label="$t('schedule.receiver')" prop="receiver" min-width="20%">
<template v-slot:default="{row}">
<el-select v-model="row.userIds" filterable multiple
:placeholder="$t('commons.please_select')"
@click.native="defectAndTestPlanUserList()" style="width: 100%;">
<el-option
v-for="item in defectReceiverOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
<template slot-scope="scope">
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')">
<el-option
v-for="item in receiveTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="webhook" min-width="20%" prop="webhook">
<template v-slot:default="scope">
<el-input v-model="scope.row.webhook" placeholder="webhook地址"></el-input>
</template>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
<template v-slot:default="scope">
<el-button
type="primary"
size="mini"
v-show="scope.row.result.showSave"
@click="handleAddTask(scope.$index,scope.row)"
>{{ $t('commons.add') }}
</el-button>
<el-button
size="mini"
v-show="scope.row.result.showCancel"
@click.native.prevent="removeRowTask(scope.$index,form.defectTask)"
>{{ $t('commons.cancel') }}
</el-button>
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
v-show="scope.row.result.showDelete"
@click.native.prevent="deleteRowTask(scope.$index,form.defectTask)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
</el-form>
</div>
</template>
<script>
export default {
name: "TaskNotification",
data() {
return {
form: {
jenkinsTask: [{
taskType: 'jenkins',
events: [],
userIds: [],
type: [],
webhook: "",
result: {
showSave: true,
showCancel: true,
showDelete: false
}
}],
testPlanTask: [{
taskType: 'testPlan',
events: [],
userIds: [],
type: [],
webhook: "",
result: {
showSave: true,
showCancel: true,
showDelete: false
}
}],
reviewTask: [{
taskType: 'review',
events: [],
userIds: [],
type: [],
webhook: "",
result: {
showSave: true,
showCancel: true,
showDelete: false
}
}],
defectTask: [{
taskType: 'defect',
events: [],
userIds: [],
type: [],
webhook: "",
result: {
showSave: true,
showCancel: true,
showDelete: false
}
}],
},
jenkinsEventOptions: [
{value: 'EXECUTE_SUCCESSFUL', label: this.$t('schedule.event_success')},
{value: 'EXECUTE_FAILED', label: this.$t('schedule.event_failed')}
],
jenkinsReceiverOptions: [],
receiveTypeOptions: [
{value: 'EMAIL', label: this.$t('organization.message.mail')},
{value: 'NAIL_ROBOT', label: this.$t('organization.message.nail_robot')},
{value: 'WECHAT_ROBOT', label: this.$t('organization.message.enterprise_wechat_robot')}
],
otherEventOptions: [
{value: 'CREATE', label: this.$t('commons.create')},
{value: 'UPDATE', label: this.$t('commons.update')},
{value: 'DELETE', label: this.$t('commons.delete')}
],
//
testPlanReceiverOptions: [],
//
reviewReceiverOptions: [],
//
defectReceiverOptions: [],
}
},
methods: {
userList() {
this.result = this.$get('user/list', response => {
this.jenkinsReceiverOptions = response.data
})
},
reviewUerList() {
this.result = this.$get('user/list', response => {
this.reviewReceiverOptions = response.data
this.reviewReceiverOptions.unshift({id: 'Founder', name: this.$t('api_test.creator')},
{id: 'Executor', name: this.$t('test_track.plan_view.executor')},
{id: 'Maintainer', name: this.$t('test_track.case.maintainer')})
})
},
defectAndTestPlanUserList() {
this.result = this.$get('user/list', response => {
this.testPlanReceiverOptions = response.data
this.defectReceiverOptions = response.data
this.testPlanReceiverOptions.unshift({id: 'Founder', name: this.$t('api_test.creator')}, {
id: 'Executor',
name: this.$t('test_track.plan_view.executor')
})
})
},
handleAddTaskModel(type) {
let Task = {};
Task.result = {
showSave: true,
showCancel: true,
showDelete: false,
}
if (type === 'jenkinsTask') {
this.form.jenkinsTask.unshift(Task)
} else if (type === 'testPlanTask') {
this.form.testPlanTask.unshift(Task)
} else if (type === 'reviewTask') {
this.form.reviewTask.unshift(Task)
} else {
this.form.defectTask.unshift(Task)
}
},
handleAddTask(index, data) {
let list = []
list.push(data)
let param = {};
param.messageDetail = list
this.result = this.$post("/notice/save/message/task", param, () => {
data.result.showSave = false;
data.result.showCancel = false;
data.result.showDelete = true;
})
},
removeRowTask(index, data) { //
data.splice(index, 1)
},
deleteRowTask(index, data) { //
this.result = this.$get("/delete/message" + index, response => {
})
data.splice(index, 1)
},
}
}
</script>
<style scoped>
/deep/ .el-select__tags {
flex-wrap: unset;
overflow: auto;
}
.row {
margin-bottom: 30px;
}
</style>

View File

@ -48,6 +48,11 @@ export default {
component: () => import('@/business/components/settings/organization/ServiceIntegration'),
meta: {organization: true, title: 'organization.service_integration'}
},
{
path: 'messagesettings',
component: () => import('@/business/components/settings/organization/MessageSettings'),
meta: {organization: true, title: 'organization.message_settings'}
},
{
path: 'member',
component: () => import('@/business/components/settings/workspace/WorkspaceMember'),

View File

@ -213,6 +213,20 @@ export default {
select: 'Select Organization',
service_integration: 'Service integration',
defect_manage: 'Defect management platform',
message_settings:'Message settings',
message:{
jenkins_task_notification:'Jenkins task notification',
test_plan_task_notification:'Test plan task notification',
test_review_task_notice:'Test review task notice',
defect_task_notification:'Defect task notification',
create_new_notification:'Create a new notification',
select_events:'Select event',
select_receiving_method:'Select receiving method',
mail:'mail',
nail_robot:'Nail robot',
enterprise_wechat_robot:'Enterprise wechat robot',
},
integration: {
select_defect_platform: 'Please select the defect management platform to be integrated:',
basic_auth_info: 'Basic Auth account information:',

View File

@ -214,6 +214,22 @@ export default {
delete_warning: '删除该组织将同步删除该组织下所有相关工作空间和相关工作空间下的所有项目,以及项目中的所有用例、接口测试、性能测试等,确定要删除吗?',
service_integration: '服务集成',
defect_manage: '缺陷管理平台',
message_settings:'消息设置',
message:{
jenkins_task_notification:'Jenkins任务通知',
test_plan_task_notification:'测试计划任务通知',
test_review_task_notice:'测试评审任务通知',
create_new_notification:'创建新通知',
select_events:'选择事件',
defect_task_notification:'缺陷任务通知',
select_receiving_method:'选择接收方式',
mail:'邮件',
nail_robot:'钉钉机器人',
enterprise_wechat_robot:'企业微信机器人',
},
integration: {
select_defect_platform: '请选择要集成的缺陷管理平台:',
basic_auth_info: 'Basic Auth 账号信息:',

View File

@ -214,6 +214,19 @@ export default {
delete_warning: '刪除該組織將同步刪除該組織下所有相關工作空間和相關工作空間下的所有項目,以及項目中的所有用例、接口測試、性能測試等,確定要刪除嗎?',
service_integration: '服務集成',
defect_manage: '缺陷管理平臺',
message_settings:'消息設定',
message:{
jenkins_task_notification:'Jenkins任務通知',
test_plan_task_notification:'測試計畫任務通知',
test_review_task_notice:'測試評審任務通知',
defect_task_notification:'缺陷任務通知',
create_new_notification:'創建新通知',
select_events:'選擇事件',
select_receiving_method:'選擇接收管道',
mail:'郵件',
nail_robot:'釘釘機器人',
enterprise_wechat_robot:'企業微信機器人',
},
integration: {
select_defect_platform: '請選擇要集成的缺陷管理平臺:',
basic_auth_info: 'Basic Auth 賬號信息:',
@ -236,7 +249,10 @@ export default {
successful_operation: '操作成功',
not_integrated: '未集成該平臺',
choose_platform: '請選擇集成的平臺',
verified: '驗證通過'
verified: '驗證通過',
mail:'郵件',
nail_robot:'釘釘機器人',
enterprise_wechat_robot:'企業微信機器人',
}
},
project: {