This commit is contained in:
chenjianxing 2020-10-23 12:47:24 +08:00
commit 4b7a42d2e8
24 changed files with 564 additions and 512 deletions

View File

@ -178,55 +178,45 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
List<NoticeDetail> noticeList = noticeService.queryNotice(testResult.getTestId()); List<NoticeDetail> noticeList = noticeService.queryNotice(testResult.getTestId());
mailService.sendApiNotification(report, noticeList); mailService.sendApiNotification(report, noticeList);
} }
if (StringUtils.equals(NoticeConstants.API, report.getTriggerMode())) { if (StringUtils.equals(NoticeConstants.API, "API")) {
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList = messageSettingDetail.getJenkinsTask(); List<MessageDetail> taskList = messageSettingDetail.getJenkinsTask();
if (StringUtils.equals(report.getStatus(), "Success")) { String contextSuccess = "jenkins任务通知" + report.getName() + "执行成功";
String contextFailed = "jenkins任务通知" + report.getName() + "执行失败";
}
String contextSuccess = report.getName() + "执行成功";
;
String contextFailed = report.getName() + "执行失败";
taskList.forEach(r -> { taskList.forEach(r -> {
switch (r.getType()) { switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT: case NoticeConstants.NAIL_ROBOT:
r.getEvents().forEach(e -> { if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, r.getEvent()) && StringUtils.equals(report.getStatus(), "Success")) {
if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, e) && StringUtils.equals(report.getStatus(), "Success")) {
dingTaskService.sendNailRobot(r, userIds, contextSuccess, NoticeConstants.EXECUTE_SUCCESSFUL); dingTaskService.sendNailRobot(r, userIds, contextSuccess, NoticeConstants.EXECUTE_SUCCESSFUL);
} }
if (StringUtils.equals(NoticeConstants.EXECUTE_FAILED, e) && StringUtils.equals(report.getStatus(), "Error")) { if (StringUtils.equals(NoticeConstants.EXECUTE_FAILED, r.getEvent()) && StringUtils.equals(report.getStatus(), "Error")) {
dingTaskService.sendNailRobot(r, userIds, contextFailed, NoticeConstants.EXECUTE_FAILED); dingTaskService.sendNailRobot(r, userIds, contextFailed, NoticeConstants.EXECUTE_FAILED);
} }
});
break; break;
case NoticeConstants.WECHAT_ROBOT: case NoticeConstants.WECHAT_ROBOT:
r.getEvents().forEach(e -> { if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, r.getEvent()) && StringUtils.equals(report.getStatus(), "Success")) {
if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, e) && StringUtils.equals(report.getStatus(), "Success")) {
wxChatTaskService.sendWechatRobot(r, userIds, contextSuccess, NoticeConstants.EXECUTE_SUCCESSFUL); wxChatTaskService.sendWechatRobot(r, userIds, contextSuccess, NoticeConstants.EXECUTE_SUCCESSFUL);
} }
if (StringUtils.equals(NoticeConstants.EXECUTE_FAILED, e) && StringUtils.equals(report.getStatus(), "Error")) { if (StringUtils.equals(NoticeConstants.EXECUTE_FAILED, r.getEvent()) && StringUtils.equals(report.getStatus(), "Error")) {
wxChatTaskService.sendWechatRobot(r, userIds, contextFailed, NoticeConstants.EXECUTE_FAILED); wxChatTaskService.sendWechatRobot(r, userIds, contextFailed, NoticeConstants.EXECUTE_FAILED);
} }
});
break; break;
case NoticeConstants.EMAIL: case NoticeConstants.EMAIL:
r.getEvents().forEach(e -> { if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, r.getEvent()) && StringUtils.equals(report.getStatus(), "Success")) {
if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, e) && StringUtils.equals(report.getStatus(), "Success")) {
try { try {
mailService.sendApiJenkinsNotification(contextSuccess, r); mailService.sendApiJenkinsNotification(contextSuccess, r);
} catch (MessagingException messagingException) { } catch (MessagingException messagingException) {
messagingException.printStackTrace(); messagingException.printStackTrace();
} }
} }
if (StringUtils.equals(NoticeConstants.EXECUTE_FAILED, e) && StringUtils.equals(report.getStatus(), "Error")) { if (StringUtils.equals(NoticeConstants.EXECUTE_FAILED, r.getEvent()) && StringUtils.equals(report.getStatus(), "Error")) {
try { try {
mailService.sendApiJenkinsNotification(contextFailed, r); mailService.sendApiJenkinsNotification(contextFailed, r);
} catch (MessagingException messagingException) { } catch (MessagingException messagingException) {
messagingException.printStackTrace(); messagingException.printStackTrace();
} }
} }
});
break; break;
} }
}); });

View File

@ -21,5 +21,7 @@ public class MessageTask implements Serializable {
private Boolean isSet; private Boolean isSet;
private String organizationId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -653,6 +653,76 @@ public class MessageTaskExample {
addCriterion("is_set not between", value1, value2, "isSet"); addCriterion("is_set not between", value1, value2, "isSet");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andOrganizationIdIsNull() {
addCriterion("organization_id is null");
return (Criteria) this;
}
public Criteria andOrganizationIdIsNotNull() {
addCriterion("organization_id is not null");
return (Criteria) this;
}
public Criteria andOrganizationIdEqualTo(String value) {
addCriterion("organization_id =", value, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdNotEqualTo(String value) {
addCriterion("organization_id <>", value, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdGreaterThan(String value) {
addCriterion("organization_id >", value, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdGreaterThanOrEqualTo(String value) {
addCriterion("organization_id >=", value, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdLessThan(String value) {
addCriterion("organization_id <", value, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdLessThanOrEqualTo(String value) {
addCriterion("organization_id <=", value, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdLike(String value) {
addCriterion("organization_id like", value, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdNotLike(String value) {
addCriterion("organization_id not like", value, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdIn(List<String> values) {
addCriterion("organization_id in", values, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdNotIn(List<String> values) {
addCriterion("organization_id not in", values, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdBetween(String value1, String value2) {
addCriterion("organization_id between", value1, value2, "organizationId");
return (Criteria) this;
}
public Criteria andOrganizationIdNotBetween(String value1, String value2) {
addCriterion("organization_id not between", value1, value2, "organizationId");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain; package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import lombok.Data;
@Data @Data
public class TestPlan implements Serializable { public class TestPlan implements Serializable {

View File

@ -10,6 +10,7 @@
<result column="webhook" jdbcType="VARCHAR" property="webhook" /> <result column="webhook" jdbcType="VARCHAR" property="webhook" />
<result column="identification" jdbcType="VARCHAR" property="identification" /> <result column="identification" jdbcType="VARCHAR" property="identification" />
<result column="is_set" jdbcType="BIT" property="isSet" /> <result column="is_set" jdbcType="BIT" property="isSet" />
<result column="organization_id" jdbcType="VARCHAR" property="organizationId" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -70,7 +71,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, `type`, event, user_id, task_type, webhook, identification, is_set id, `type`, event, user_id, task_type, webhook, identification, is_set, organization_id
</sql> </sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultMap="BaseResultMap">
select select
@ -105,10 +106,12 @@
<insert id="insert" parameterType="io.metersphere.base.domain.MessageTask"> <insert id="insert" parameterType="io.metersphere.base.domain.MessageTask">
insert into message_task (id, `type`, event, insert into message_task (id, `type`, event,
user_id, task_type, webhook, user_id, task_type, webhook,
identification, is_set) identification, is_set, organization_id
)
values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{webhook,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{webhook,jdbcType=VARCHAR},
#{identification,jdbcType=VARCHAR}, #{isSet,jdbcType=BIT}) #{identification,jdbcType=VARCHAR}, #{isSet,jdbcType=BIT}, #{organizationId,jdbcType=VARCHAR}
)
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.MessageTask"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.MessageTask">
insert into message_task insert into message_task
@ -137,6 +140,9 @@
<if test="isSet != null"> <if test="isSet != null">
is_set, is_set,
</if> </if>
<if test="organizationId != null">
organization_id,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -163,6 +169,9 @@
<if test="isSet != null"> <if test="isSet != null">
#{isSet,jdbcType=BIT}, #{isSet,jdbcType=BIT},
</if> </if>
<if test="organizationId != null">
#{organizationId,jdbcType=VARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultType="java.lang.Long">
@ -198,6 +207,9 @@
<if test="record.isSet != null"> <if test="record.isSet != null">
is_set = #{record.isSet,jdbcType=BIT}, is_set = #{record.isSet,jdbcType=BIT},
</if> </if>
<if test="record.organizationId != null">
organization_id = #{record.organizationId,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" />
@ -212,7 +224,8 @@
task_type = #{record.taskType,jdbcType=VARCHAR}, task_type = #{record.taskType,jdbcType=VARCHAR},
webhook = #{record.webhook,jdbcType=VARCHAR}, webhook = #{record.webhook,jdbcType=VARCHAR},
identification = #{record.identification,jdbcType=VARCHAR}, identification = #{record.identification,jdbcType=VARCHAR},
is_set = #{record.isSet,jdbcType=BIT} is_set = #{record.isSet,jdbcType=BIT},
organization_id = #{record.organizationId,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>
@ -241,6 +254,9 @@
<if test="isSet != null"> <if test="isSet != null">
is_set = #{isSet,jdbcType=BIT}, is_set = #{isSet,jdbcType=BIT},
</if> </if>
<if test="organizationId != null">
organization_id = #{organizationId,jdbcType=VARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -252,7 +268,8 @@
task_type = #{taskType,jdbcType=VARCHAR}, task_type = #{taskType,jdbcType=VARCHAR},
webhook = #{webhook,jdbcType=VARCHAR}, webhook = #{webhook,jdbcType=VARCHAR},
identification = #{identification,jdbcType=VARCHAR}, identification = #{identification,jdbcType=VARCHAR},
is_set = #{isSet,jdbcType=BIT} is_set = #{isSet,jdbcType=BIT},
organization_id = #{organizationId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -143,13 +143,15 @@
stage, principal, test_case_match_rule, stage, principal, test_case_match_rule,
executor_match_rule, create_time, update_time, executor_match_rule, create_time, update_time,
actual_end_time, planned_start_time, planned_end_time, actual_end_time, planned_start_time, planned_end_time,
actual_start_time, creator, tags) actual_start_time, creator, tags
)
values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{stage,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, #{testCaseMatchRule,jdbcType=VARCHAR}, #{stage,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, #{testCaseMatchRule,jdbcType=VARCHAR},
#{executorMatchRule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{executorMatchRule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{actualEndTime,jdbcType=BIGINT}, #{plannedStartTime,jdbcType=BIGINT}, #{plannedEndTime,jdbcType=BIGINT}, #{actualEndTime,jdbcType=BIGINT}, #{plannedStartTime,jdbcType=BIGINT}, #{plannedEndTime,jdbcType=BIGINT},
#{actualStartTime,jdbcType=BIGINT}, #{creator,jdbcType=VARCHAR}, #{tags,jdbcType=LONGVARCHAR}) #{actualStartTime,jdbcType=BIGINT}, #{creator,jdbcType=VARCHAR}, #{tags,jdbcType=LONGVARCHAR}
)
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlan"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlan">
insert into test_plan insert into test_plan

View File

@ -9,14 +9,14 @@ public interface NoticeConstants {
String CREATE = "CREATE"; String CREATE = "CREATE";
String UPDATE = "UPDATE"; String UPDATE = "UPDATE";
String DELETE = "DELETE"; String DELETE = "DELETE";
String COMMENT = "COMMENT";
String JENKINS_TASK = "JENKINS_TASK"; String JENKINS_TASK = "JENKINS_TASK";
String TEST_PLAN_TASK = "TEST_PLAN_TASK"; String TEST_PLAN_TASK = "TEST_PLAN_TASK";
String REVIEW_TASK = "REVIEW_TASK"; String REVIEW_TASK = "REVIEW_TASK";
String DEFECT_TASK = "DEFECT_TASK"; String DEFECT_TASK = "DEFECT_TASK";
String FOUNDER = "FOUNDER"; String FOUNDER = "FOUNDER";//创建人
String EXECUTOR = "EXECUTOR"; String EXECUTOR = "EXECUTOR";//负责人(评审人
String MAINTAINER = "MAINTAINER"; String MAINTAINER = "MAINTAINER";//维护人
String COMMENT = "COMMENT";
String API = "API"; String API = "API";
String SCHEDULE = "SCHEDULE"; String SCHEDULE = "SCHEDULE";

View File

@ -133,7 +133,10 @@ public class UserController {
public List<User> getUserList() { public List<User> getUserList() {
return userService.getUserList(); return userService.getUserList();
} }
@GetMapping("/list/orgId")
public List<User> getUserListByOrgId() {
return userService.getUserListByOrgId();
}
@PostMapping("/update/current") @PostMapping("/update/current")
public UserDTO updateCurrentUser(@RequestBody User user) { public UserDTO updateCurrentUser(@RequestBody User user) {
userService.updateUser(user); userService.updateUser(user);

View File

@ -9,10 +9,11 @@ import java.util.List;
@Data @Data
public class MessageDetail { public class MessageDetail {
private List<String> userIds = new ArrayList<>(); private List<String> userIds = new ArrayList<>();
private List<String> events = new ArrayList<>(); private String event;
private String taskType; private String taskType;
private String webhook; private String webhook;
private String type; private String type;
private String identification; private String identification;
private String organizationId;
private Boolean isSet; private Boolean isSet;
} }

View File

@ -27,30 +27,17 @@ public class DingTaskService {
public void sendNailRobot(MessageDetail messageDetail, List<String> userIds, String context, String eventType) { public void sendNailRobot(MessageDetail messageDetail, List<String> userIds, String context, String eventType) {
List<String> addresseeIdList = new ArrayList<>(); List<String> addresseeIdList = new ArrayList<>();
messageDetail.getEvents().forEach(e -> { if (StringUtils.equals(eventType, messageDetail.getEvent())) {
if (StringUtils.equals(eventType, e)) {
messageDetail.getUserIds().forEach(u -> { messageDetail.getUserIds().forEach(u -> {
if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) { if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.FOUNDER, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) {
addresseeIdList.add(u); addresseeIdList.add(u);
} }else{
if (StringUtils.equals(NoticeConstants.CREATE, eventType) && StringUtils.equals(NoticeConstants.EXECUTOR, u)) {
addresseeIdList.addAll(userIds); addresseeIdList.addAll(userIds);
} }
if (StringUtils.equals(NoticeConstants.UPDATE, eventType) && StringUtils.equals(NoticeConstants.FOUNDER, u)) {
addresseeIdList.addAll(userIds);
}
if (StringUtils.equals(NoticeConstants.DELETE, eventType) && StringUtils.equals(NoticeConstants.FOUNDER, u)) {
addresseeIdList.addAll(userIds);
}
if (StringUtils.equals(NoticeConstants.COMMENT, eventType) && StringUtils.equals(NoticeConstants.MAINTAINER, u)) {
addresseeIdList.addAll(userIds);
}
}); });
sendDingTask(context, addresseeIdList, messageDetail.getWebhook()); sendDingTask(context, addresseeIdList, messageDetail.getWebhook());
} }
});
} }
public void sendDingTask(String context, List<String> userIds, String Webhook) { public void sendDingTask(String context, List<String> userIds, String Webhook) {

View File

@ -172,7 +172,7 @@ public class MailService {
public void sendReviewerNotice(MessageDetail messageDetail, List<String> userIds, SaveTestCaseReviewRequest reviewRequest, String eventType) { public void sendReviewerNotice(MessageDetail messageDetail, List<String> userIds, SaveTestCaseReviewRequest reviewRequest, String eventType) {
Map<String, String> context = getReviewContext(reviewRequest); Map<String, String> context = getReviewContext(reviewRequest);
try { try {
String reviewerTemplate = IOUtils.toString(this.getClass().getResource("/mail/reviewer.html"), StandardCharsets.UTF_8); String reviewerTemplate = IOUtils.toString(this.getClass().getResource("/mail/end.html"), StandardCharsets.UTF_8);
sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, reviewerTemplate); sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, reviewerTemplate);
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e); LogUtil.error(e);
@ -183,7 +183,7 @@ public class MailService {
public void sendTestPlanStartNotice(MessageDetail messageDetail, List<String> userIds, AddTestPlanRequest testPlan, String eventType) { public void sendTestPlanStartNotice(MessageDetail messageDetail, List<String> userIds, AddTestPlanRequest testPlan, String eventType) {
Map<String, String> context = getTestPlanContext(testPlan); Map<String, String> context = getTestPlanContext(testPlan);
context.put("creator", userIds.toString()); context.put("creator", testPlan.getCreator());
try { try {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/testPlanStart.html"), StandardCharsets.UTF_8); String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/testPlanStart.html"), StandardCharsets.UTF_8);
sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
@ -424,8 +424,7 @@ public class MailService {
private List<String> addresseeIdList(MessageDetail messageDetail, List<String> userIds, String eventType) { private List<String> addresseeIdList(MessageDetail messageDetail, List<String> userIds, String eventType) {
List<String> addresseeIdList = new ArrayList<>(); List<String> addresseeIdList = new ArrayList<>();
messageDetail.getEvents().forEach(e -> { if (StringUtils.equals(eventType, messageDetail.getEvent())) {
if (StringUtils.equals(eventType, e)) {
messageDetail.getUserIds().forEach(u -> { messageDetail.getUserIds().forEach(u -> {
if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) { if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) {
addresseeIdList.add(u); addresseeIdList.add(u);
@ -446,7 +445,6 @@ public class MailService {
}); });
} }
});
return addresseeIdList; return addresseeIdList;
} }
} }

View File

@ -7,6 +7,8 @@ import io.metersphere.base.domain.NoticeExample;
import io.metersphere.base.mapper.MessageTaskMapper; import io.metersphere.base.mapper.MessageTaskMapper;
import io.metersphere.base.mapper.NoticeMapper; import io.metersphere.base.mapper.NoticeMapper;
import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.notice.controller.request.MessageRequest; import io.metersphere.notice.controller.request.MessageRequest;
import io.metersphere.notice.controller.request.NoticeRequest; import io.metersphere.notice.controller.request.NoticeRequest;
import io.metersphere.notice.domain.MessageDetail; import io.metersphere.notice.domain.MessageDetail;
@ -31,9 +33,6 @@ public class NoticeService {
@Resource @Resource
private MessageTaskMapper messageTaskMapper; private MessageTaskMapper messageTaskMapper;
@Resource
MailService mailService;
public void saveNotice(NoticeRequest noticeRequest) { public void saveNotice(NoticeRequest noticeRequest) {
NoticeExample example = new NoticeExample(); NoticeExample example = new NoticeExample();
example.createCriteria().andTestIdEqualTo(noticeRequest.getTestId()); example.createCriteria().andTestIdEqualTo(noticeRequest.getTestId());
@ -93,29 +92,30 @@ public class NoticeService {
public void saveMessageTask(MessageRequest messageRequest) { public void saveMessageTask(MessageRequest messageRequest) {
String identification = UUID.randomUUID().toString(); String identification = UUID.randomUUID().toString();
SessionUser user = SessionUtils.getUser();
String orgId = user.getLastOrganizationId();
messageRequest.getMessageDetail().forEach(list -> { messageRequest.getMessageDetail().forEach(list -> {
list.getEvents().forEach(n -> {
list.getUserIds().forEach(m -> { list.getUserIds().forEach(m -> {
MessageTask message = new MessageTask(); MessageTask message = new MessageTask();
message.setId(UUID.randomUUID().toString()); message.setId(UUID.randomUUID().toString());
message.setEvent(n); message.setEvent(list.getEvent());
message.setTaskType(list.getTaskType()); message.setTaskType(list.getTaskType());
message.setUserId(m); message.setUserId(m);
message.setType(list.getType()); message.setType(list.getType());
message.setWebhook(list.getWebhook()); message.setWebhook(list.getWebhook());
message.setIdentification(identification); message.setIdentification(identification);
message.setIsSet(list.getIsSet()); message.setIsSet(list.getIsSet());
message.setOrganizationId(orgId);
messageTaskMapper.insert(message); messageTaskMapper.insert(message);
}); });
}); });
});
} }
public MessageSettingDetail searchMessage() { public MessageSettingDetail searchMessage() {
SessionUser user = SessionUtils.getUser();
String orgId = user.getLastOrganizationId();
MessageTaskExample messageTaskExample = new MessageTaskExample(); MessageTaskExample messageTaskExample = new MessageTaskExample();
messageTaskExample.createCriteria(); messageTaskExample.createCriteria().andOrganizationIdEqualTo(orgId);
List<MessageTask> messageTaskLists = new ArrayList<>(); List<MessageTask> messageTaskLists = new ArrayList<>();
MessageSettingDetail messageSettingDetail = new MessageSettingDetail(); MessageSettingDetail messageSettingDetail = new MessageSettingDetail();
List<MessageDetail> MessageDetailList = new ArrayList<>(); List<MessageDetail> MessageDetailList = new ArrayList<>();
@ -123,18 +123,16 @@ public class NoticeService {
Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(e -> fetchGroupKey(e))); Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(e -> fetchGroupKey(e)));
MessageTaskMap.forEach((k, v) -> { MessageTaskMap.forEach((k, v) -> {
Set userIds = new HashSet(); Set userIds = new HashSet();
Set events = new HashSet();
MessageDetail messageDetail = new MessageDetail(); MessageDetail messageDetail = new MessageDetail();
for (MessageTask m : v) { for (MessageTask m : v) {
userIds.add(m.getUserId()); userIds.add(m.getUserId());
events.add(m.getEvent()); messageDetail.setEvent(m.getEvent());
messageDetail.setTaskType(m.getTaskType()); messageDetail.setTaskType(m.getTaskType());
messageDetail.setWebhook(m.getWebhook()); messageDetail.setWebhook(m.getWebhook());
messageDetail.setIdentification(m.getIdentification()); messageDetail.setIdentification(m.getIdentification());
messageDetail.setType(m.getType()); messageDetail.setType(m.getType());
messageDetail.setIsSet(m.getIsSet()); messageDetail.setIsSet(m.getIsSet());
} }
messageDetail.setEvents(new ArrayList(events));
messageDetail.setUserIds(new ArrayList(userIds)); messageDetail.setUserIds(new ArrayList(userIds));
MessageDetailList.add(messageDetail); MessageDetailList.add(messageDetail);
}); });
@ -158,86 +156,4 @@ public class NoticeService {
example.createCriteria().andIdentificationEqualTo(identification); example.createCriteria().andIdentificationEqualTo(identification);
return messageTaskMapper.deleteByExample(example); return messageTaskMapper.deleteByExample(example);
} }
/*
public void sendTask(List<String> userIds,String context,String taskType,String eventType){
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList=new ArrayList<>();
switch (taskType) {
case NoticeConstants.REVIEW_TASK:
taskList=messageSettingDetail.getReviewTask();
break;
case NoticeConstants.JENKINS_TASK:
taskList=messageSettingDetail.getJenkinsTask();
break;
case NoticeConstants.DEFECT_TASK:
taskList=messageSettingDetail.getDefectTask();
break;
case NoticeConstants.TEST_PLAN_TASK:
taskList=messageSettingDetail.getTestCasePlanTask();
break;
}
taskList.forEach(r->{
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
sendNailRobot(r,userIds,context,eventType);
break;
case NoticeConstants.WECHAT_ROBOT:
sendWechatRobot(r,userIds,context,eventType);
break;
case NoticeConstants.EMAIL:
sendEmail(r,userIds,context,eventType);
break;
}
});
}
*/
/*private void sendNailRobot(MessageDetail messageDetail,List<String> userIds,String context,String eventType){
List<String> addresseeIdList=new ArrayList<>();
messageDetail.getEvents().forEach(e->{
if(StringUtils.equals(eventType,e)){
messageDetail.getUserIds().forEach(u->{
if(StringUtils.equals(NoticeConstants.FOUNDER,u)){
addresseeIdList.addAll(userIds);
}else{
addresseeIdList.add(u);
}
});
dingTaskService.sendDingTask(context, addresseeIdList,messageDetail.getWebhook());
}
});
}
private void sendWechatRobot(MessageDetail messageDetail,List<String> userIds,String context,String eventType){
List<String> addresseeIdList=new ArrayList<>();
messageDetail.getEvents().forEach(e->{
if(StringUtils.equals(eventType,e)){
messageDetail.getUserIds().forEach(u->{
if(StringUtils.equals(NoticeConstants.FOUNDER,u)){
addresseeIdList.addAll(userIds);
}else{
addresseeIdList.add(u);
}
});
wxChatTaskService.enterpriseWechatTask(context, addresseeIdList,messageDetail.getWebhook());
}
});
}
private void sendEmail(MessageDetail messageDetail,List<String> userIds,String context,String eventType){
List<String> addresseeIdList=new ArrayList<>();
if(StringUtils.equals(NoticeConstants.EMAIL,messageDetail.getType())){
messageDetail.getEvents().forEach(e->{
if(StringUtils.equals(eventType,e)){
messageDetail.getUserIds().forEach(u->{
if(StringUtils.equals(NoticeConstants.FOUNDER,u)){
addresseeIdList.addAll(userIds);
}else{
addresseeIdList.add(u);
}
});
mailService.sendReviewerNotice(addresseeIdList, context);
}
});
}
}*/
} }

View File

@ -26,30 +26,16 @@ public class WxChatTaskService {
public void sendWechatRobot(MessageDetail messageDetail, List<String> userIds, String context, String eventType) { public void sendWechatRobot(MessageDetail messageDetail, List<String> userIds, String context, String eventType) {
List<String> addresseeIdList = new ArrayList<>(); List<String> addresseeIdList = new ArrayList<>();
messageDetail.getEvents().forEach(e -> { if (StringUtils.equals(eventType, messageDetail.getEvent())) {
if (StringUtils.equals(eventType, e)) {
messageDetail.getUserIds().forEach(u -> { messageDetail.getUserIds().forEach(u -> {
if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) { if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.FOUNDER, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) {
addresseeIdList.add(u); addresseeIdList.add(u);
} }else{
if (StringUtils.equals(NoticeConstants.CREATE, eventType) && StringUtils.equals(NoticeConstants.EXECUTOR, u)) {
addresseeIdList.addAll(userIds); addresseeIdList.addAll(userIds);
} }
if (StringUtils.equals(NoticeConstants.UPDATE, eventType) && StringUtils.equals(NoticeConstants.FOUNDER, u)) {
addresseeIdList.addAll(userIds);
}
if (StringUtils.equals(NoticeConstants.DELETE, eventType) && StringUtils.equals(NoticeConstants.FOUNDER, u)) {
addresseeIdList.addAll(userIds);
}
if (StringUtils.equals(NoticeConstants.COMMENT, eventType) && StringUtils.equals(NoticeConstants.MAINTAINER, u)) {
addresseeIdList.addAll(userIds);
}
}); });
enterpriseWechatTask(context, addresseeIdList, messageDetail.getWebhook()); enterpriseWechatTask(context, addresseeIdList, messageDetail.getWebhook());
} }
});
} }
public void enterpriseWechatTask(String context, List<String> userIds, String Webhook) { public void enterpriseWechatTask(String context, List<String> userIds, String Webhook) {

View File

@ -266,6 +266,13 @@ public class UserService {
example.setOrderByClause("update_time desc"); example.setOrderByClause("update_time desc");
return userMapper.selectByExample(example); return userMapper.selectByExample(example);
} }
public List<User> getUserListByOrgId() {
SessionUser user = SessionUtils.getUser();
String orgId = user.getLastOrganizationId();
UserExample example = new UserExample();
example.createCriteria().andLastOrganizationIdEqualTo(orgId);
return userMapper.selectByExample(example);
}
public List<User> getUserListWithRequest(io.metersphere.controller.request.UserRequest request) { public List<User> getUserListWithRequest(io.metersphere.controller.request.UserRequest request) {
return extUserMapper.getUserList(request); return extUserMapper.getUserList(request);

View File

@ -184,6 +184,8 @@ public class TestCaseReviewService {
testCaseReview.setUpdateTime(System.currentTimeMillis()); testCaseReview.setUpdateTime(System.currentTimeMillis());
checkCaseReviewExist(testCaseReview); checkCaseReviewExist(testCaseReview);
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview); testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
List<String> userIds=new ArrayList<>();
userIds.addAll(testCaseReview.getUserIds());
try { try {
String context = getReviewContext(testCaseReview, NoticeConstants.CREATE); String context = getReviewContext(testCaseReview, NoticeConstants.CREATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
@ -191,13 +193,13 @@ public class TestCaseReviewService {
taskList.forEach(r -> { taskList.forEach(r -> {
switch (r.getType()) { switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT: case NoticeConstants.NAIL_ROBOT:
dingTaskService.sendNailRobot(r, testCaseReview.getUserIds(), context, NoticeConstants.CREATE); dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.CREATE);
break; break;
case NoticeConstants.WECHAT_ROBOT: case NoticeConstants.WECHAT_ROBOT:
wxChatTaskService.sendWechatRobot(r, testCaseReview.getUserIds(), context, NoticeConstants.CREATE); wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.CREATE);
break; break;
case NoticeConstants.EMAIL: case NoticeConstants.EMAIL:
mailService.sendReviewerNotice(r, testCaseReview.getUserIds(), testCaseReview, NoticeConstants.CREATE); mailService.sendReviewerNotice(r, userIds, testCaseReview, NoticeConstants.CREATE);
break; break;
} }
}); });

View File

@ -115,7 +115,6 @@ public class TestPlanService {
testPlan.setUpdateTime(System.currentTimeMillis()); testPlan.setUpdateTime(System.currentTimeMillis());
testPlan.setCreator(SessionUtils.getUser().getId()); testPlan.setCreator(SessionUtils.getUser().getId());
testPlanMapper.insert(testPlan); testPlanMapper.insert(testPlan);
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal()); userIds.add(testPlan.getPrincipal());
try { try {
@ -160,13 +159,12 @@ public class TestPlanService {
testPlan.setActualStartTime(System.currentTimeMillis()); testPlan.setActualStartTime(System.currentTimeMillis());
} else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus())) { } else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus())) {
//已完成写入实际完成时间
testPlan.setActualEndTime(System.currentTimeMillis());
}
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal()); userIds.add(testPlan.getPrincipal());
AddTestPlanRequest testPlans = new AddTestPlanRequest(); AddTestPlanRequest testPlans = new AddTestPlanRequest();
/* try { //已完成写入实际完成时间
testPlan.setActualEndTime(System.currentTimeMillis());
try {
BeanUtils.copyBean(testPlans, testPlan); BeanUtils.copyBean(testPlans, testPlan);
String context = getTestPlanContext(testPlans, NoticeConstants.CREATE); String context = getTestPlanContext(testPlans, NoticeConstants.CREATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
@ -186,7 +184,9 @@ public class TestPlanService {
}); });
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e); LogUtil.error(e);
}*/ }
}
return testPlanMapper.updateByPrimaryKeySelective(testPlan); return testPlanMapper.updateByPrimaryKeySelective(testPlan);
} }
@ -253,7 +253,7 @@ public class TestPlanService {
BeanUtils.copyBean(testPlans, testPlan); BeanUtils.copyBean(testPlans, testPlan);
String context = getTestPlanContext(testPlans, NoticeConstants.DELETE); String context = getTestPlanContext(testPlans, NoticeConstants.DELETE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList = messageSettingDetail.getReviewTask(); List<MessageDetail> taskList = messageSettingDetail.getTestCasePlanTask();
taskList.forEach(r -> { taskList.forEach(r -> {
switch (r.getType()) { switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT: case NoticeConstants.NAIL_ROBOT:
@ -493,7 +493,7 @@ public class TestPlanService {
BeanUtils.copyBean(_testPlans, testPlans); BeanUtils.copyBean(_testPlans, testPlans);
String context = getTestPlanContext(_testPlans, NoticeConstants.UPDATE); String context = getTestPlanContext(_testPlans, NoticeConstants.UPDATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList = messageSettingDetail.getReviewTask(); List<MessageDetail> taskList = messageSettingDetail.getTestCasePlanTask();
taskList.forEach(r -> { taskList.forEach(r -> {
switch (r.getType()) { switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT: case NoticeConstants.NAIL_ROBOT:

View File

@ -0,0 +1,2 @@
alter table message_task
add organization_id varchar(255) null;

View File

@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<div> <div>
<p style="text-align: left"> ${maintainer} 发起<br/> <p style="text-align: left"> ${maintainer} 维护<br/>
${testCaseName}<br/> ${testCaseName}<br/>
添加评论:${description}<br/> 添加评论:${description}<br/>
点击下面链接进入用例评审页面</p> 点击下面链接进入用例评审页面</p>

View File

@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<div> <div>
<p style="text-align: left">${creator} 发起的:<br> <p style="text-align: left">${creator} 发起的用例评审:<br>
${reviewName}<br> ${reviewName}<br>
计划开始时间是:${start}<br> 计划开始时间是:${start}<br>
计划结束时间为:${end}<br> 计划结束时间为:${end}<br>

View File

@ -12,7 +12,7 @@
计划结束时间为:${end}<br> 计划结束时间为:${end}<br>
请跟进!<br> 请跟进!<br>
点击下面链接进入测试计划页面</p> 点击下面链接进入测试计划页面</p>
<a href="${url}/#/track/plan/view/${id}">${url}/#/track/plan/view</a> <a href="${url}/#/track/plan/all">${url}/#/track/plan/all</a>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,8 +1,12 @@
<template> <template>
<div style="margin-left: 40px"> <div style="margin-left: 40px">
<el-alert
:title="$t('organization.message.notes')"
type="info">
</el-alert>
<el-form :model="form" ref="from"> <el-form :model="form" ref="from">
<el-row class="row"> <el-row class="row">
<el-col :span="20"> <el-col :span="24">
<div class="grid-content bg-purple-dark"> <div class="grid-content bg-purple-dark">
<el-row> <el-row>
<el-col :span="10"> <el-col :span="10">
@ -23,12 +27,10 @@
border border
size="mini" size="mini"
:cell-style="rowClass" :cell-style="rowClass"
:header-cell-style="headClass" :header-cell-style="headClass">
>
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events"> <el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.events" multiple <el-select v-model="scope.row.event"
:placeholder="$t('organization.message.select_events')" :placeholder="$t('organization.message.select_events')"
prop="events" :disabled="!scope.row.isSet"> prop="events" :disabled="!scope.row.isSet">
<el-option <el-option
@ -56,7 +58,8 @@
</el-table-column> </el-table-column>
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type"> <el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')" :disabled="!scope.row.isSet" @change="handleEdit(scope.$index, scope.row)" <el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')"
:disabled="!scope.row.isSet" @change="handleEdit(scope.$index, scope.row)"
> >
<el-option <el-option
v-for="item in receiveTypeOptions" v-for="item in receiveTypeOptions"
@ -69,7 +72,8 @@
</el-table-column> </el-table-column>
<el-table-column label="webhook" min-width="20%" prop="webhook"> <el-table-column label="webhook" min-width="20%" prop="webhook">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-input v-model="scope.row.webhook" placeholder="webhook地址" :disabled="!scope.row.isSet||scope.row.events === 'EMAIL'"></el-input> <el-input v-model="scope.row.webhook" placeholder="webhook地址"
:disabled="!scope.row.isSet||!scope.row.isReadOnly"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result"> <el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
@ -102,7 +106,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row class="row"> <el-row class="row">
<el-col :span="20"> <el-col :span="24">
<div class="grid-content bg-purple-dark"> <div class="grid-content bg-purple-dark">
<el-row> <el-row>
<el-col :span="10"> <el-col :span="10">
@ -125,7 +129,8 @@
> >
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events"> <el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.events" multiple :placeholder="$t('organization.message.select_events')" <el-select v-model="scope.row.event" :placeholder="$t('organization.message.select_events')"
@change="handleTestPlanReceivers(scope.row)"
prop="events" :disabled="!scope.row.isSet"> prop="events" :disabled="!scope.row.isSet">
<el-option <el-option
v-for="item in otherEventOptions" v-for="item in otherEventOptions"
@ -142,7 +147,7 @@
:placeholder="$t('commons.please_select')" :placeholder="$t('commons.please_select')"
@click.native="testPlanUserList()" style="width: 100%;" :disabled="!row.isSet"> @click.native="testPlanUserList()" style="width: 100%;" :disabled="!row.isSet">
<el-option <el-option
v-for="item in testPlanReceiverOptions" v-for="item in row.testPlanReceiverOptions"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.id"> :value="item.id">
@ -152,7 +157,8 @@
</el-table-column> </el-table-column>
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type"> <el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')" :disabled="!scope.row.isSet"> <el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')"
:disabled="!scope.row.isSet" @change="handleEdit(scope.$index, scope.row)">
<el-option <el-option
v-for="item in receiveTypeOptions" v-for="item in receiveTypeOptions"
:key="item.value" :key="item.value"
@ -164,7 +170,8 @@
</el-table-column> </el-table-column>
<el-table-column label="webhook" min-width="20%" prop="webhook"> <el-table-column label="webhook" min-width="20%" prop="webhook">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-input v-model="scope.row.webhook" placeholder="webhook地址" :disabled="!scope.row.isSet"></el-input> <el-input v-model="scope.row.webhook" placeholder="webhook地址"
:disabled="!scope.row.isSet||!scope.row.isReadOnly"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result"> <el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
@ -195,7 +202,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row class="row"> <el-row class="row">
<el-col :span="20"> <el-col :span="24">
<div class="grid-content bg-purple-dark"> <div class="grid-content bg-purple-dark">
<el-row> <el-row>
<el-col :span="10"> <el-col :span="10">
@ -218,7 +225,8 @@
> >
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events"> <el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.events" multiple :placeholder="$t('organization.message.select_events')" <el-select v-model="scope.row.event" :placeholder="$t('organization.message.select_events')"
@change="handleReviewReceivers(scope.row)"
prop="event" :disabled="!scope.row.isSet"> prop="event" :disabled="!scope.row.isSet">
<el-option <el-option
v-for="item in reviewTaskEventOptions" v-for="item in reviewTaskEventOptions"
@ -235,7 +243,7 @@
:placeholder="$t('commons.please_select')" :placeholder="$t('commons.please_select')"
@click.native="reviewUerList()" style="width: 100%;" :disabled="!row.isSet"> @click.native="reviewUerList()" style="width: 100%;" :disabled="!row.isSet">
<el-option <el-option
v-for="item in reviewReceiverOptions" v-for="item in row.reviewReceiverOptions"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.id"> :value="item.id">
@ -245,7 +253,8 @@
</el-table-column> </el-table-column>
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type"> <el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')" :disabled="!scope.row.isSet"> <el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')"
:disabled="!scope.row.isSet" @change="handleEdit(scope.$index, scope.row)">
<el-option <el-option
v-for="item in receiveTypeOptions" v-for="item in receiveTypeOptions"
:key="item.value" :key="item.value"
@ -257,7 +266,8 @@
</el-table-column> </el-table-column>
<el-table-column label="webhook" min-width="20%" prop="webhook"> <el-table-column label="webhook" min-width="20%" prop="webhook">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-input v-model="scope.row.webhook" placeholder="webhook地址" :disabled="!scope.row.isSet"></el-input> <el-input v-model="scope.row.webhook" placeholder="webhook地址"
:disabled="!scope.row.isSet||!scope.row.isReadOnly"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result"> <el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
@ -288,7 +298,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row class="row"> <el-row class="row">
<el-col :span="20"> <el-col :span="24">
<div class="grid-content bg-purple-dark"> <div class="grid-content bg-purple-dark">
<el-row> <el-row>
<el-col :span="10"> <el-col :span="10">
@ -311,7 +321,7 @@
> >
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events"> <el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.events" multiple :placeholder="$t('organization.message.select_events')" <el-select v-model="scope.row.event" :placeholder="$t('organization.message.select_events')"
prop="event" :disabled="!scope.row.isSet"> prop="event" :disabled="!scope.row.isSet">
<el-option <el-option
v-for="item in defectEventOptions" v-for="item in defectEventOptions"
@ -338,7 +348,8 @@
</el-table-column> </el-table-column>
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type"> <el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')" :disabled="!scope.row.isSet"> <el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')"
:disabled="!scope.row.isSet" @change="handleEdit(scope.$index, scope.row)">
<el-option <el-option
v-for="item in receiveTypeOptions" v-for="item in receiveTypeOptions"
:key="item.value" :key="item.value"
@ -350,7 +361,8 @@
</el-table-column> </el-table-column>
<el-table-column label="webhook" min-width="20%" prop="webhook"> <el-table-column label="webhook" min-width="20%" prop="webhook">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-input v-model="scope.row.webhook" placeholder="webhook地址" :disabled="!scope.row.isSet"></el-input> <el-input v-model="scope.row.webhook" placeholder="webhook地址"
:disabled="!scope.row.isSet||!scope.row.isReadOnly"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result"> <el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
@ -385,47 +397,53 @@
</template> </template>
<script> <script>
import {getCurrentUser} from "../../../../common/js/utils";
export default { export default {
name: "TaskNotification", name: "TaskNotification",
data() { data() {
return { return {
form: { form: {
jenkinsTask: [{ jenkinsTask: [{
taskType: "jenkinsTask", taskType: "jenkinsTask",
events: [], event: "",
userIds: [], userIds: [],
type: [], type: [],
webhook: "", webhook: "",
isSet: true, isSet: true,
identification: "", identification: "",
isReadOnly: false,
}], }],
testCasePlanTask: [{ testCasePlanTask: [{
taskType: "testPlanTask", taskType: "testPlanTask",
events: [], event: "",
userIds: [], userIds: [],
type: [], type: [],
webhook: "", webhook: "",
isSet: true, isSet: true,
identification: "", identification: "",
isReadOnly: false,
}], }],
reviewTask: [{ reviewTask: [{
taskType: "reviewTask", taskType: "reviewTask",
events: [], event: "",
userIds: [], userIds: [],
type: [], type: [],
webhook: "", webhook: "",
isSet: true, isSet: true,
identification: "", identification: "",
isReadOnly: false,
}], }],
defectTask: [{ defectTask: [{
taskType: "defectTask", taskType: "defectTask",
events: [], event: "",
userIds: [], userIds: [],
type: [], type: [],
webhook: "", webhook: "",
isSet: true, isSet: true,
identification: "", identification: "",
isReadOnly: false,
}], }],
}, },
jenkinsEventOptions: [ jenkinsEventOptions: [
@ -451,9 +469,6 @@ export default {
], ],
defectEventOptions: [ defectEventOptions: [
{value: 'CREATE', label: this.$t('commons.create')}, {value: 'CREATE', label: this.$t('commons.create')},
/*
{value: 'UPDATE', label: this.$t('commons.update')},
*/
], ],
// //
testPlanReceiverOptions: [], testPlanReceiverOptions: [],
@ -461,6 +476,8 @@ export default {
reviewReceiverOptions: [], reviewReceiverOptions: [],
// //
defectReceiverOptions: [], defectReceiverOptions: [],
rules: {},
} }
}, },
@ -473,7 +490,13 @@ export default {
}, },
methods: { methods: {
handleEdit(index, data) { handleEdit(index, data) {
data.isReadOnly = true;
if (data.type === 'EMAIL') {
data.isReadOnly = !data.isReadOnly
}
},
currentUser: () => {
return getCurrentUser();
}, },
initForm() { initForm() {
this.result = this.$get('/notice/search/message', response => { this.result = this.$get('/notice/search/message', response => {
@ -481,39 +504,32 @@ export default {
}) })
}, },
userList() { userList() {
this.result = this.$get('user/list', response => { this.result = this.$get('user/list/orgId', response => {
this.jenkinsReceiverOptions = response.data this.jenkinsReceiverOptions = response.data
}) })
}, },
reviewUerList() { reviewUerList() {
this.result = this.$get('user/list', response => { this.result = this.$get('user/list/orgId', response => {
this.reviewReceiverOptions = response.data this.reviewReceiverOptions = response.data
this.reviewReceiverOptions.unshift({id: 'EXECUTOR', name: this.$t('test_track.review.reviewer')},
{id: 'FOUNDER', name: this.$t('test_track.review.review_creator')},
{id: 'MAINTAINER', name: this.$t('test_track.case.maintainer')})
}) })
}, },
defectUserList() { defectUserList() {
this.result = this.$get('user/list', response => { this.result = this.$get('user/list/orgId', response => {
this.defectReceiverOptions = response.data this.defectReceiverOptions = response.data
/* this.defectReceiverOptions.unshift({id: 'FOUNDER', name: this.$t('api_test.creator')}, { /* this.defectReceiverOptions.push({id: 'FOUNDER', name: this.$t('api_test.creator')}, {
id: 'EXECUTOR', id: 'EXECUTOR',
name: this.$t('test_track.plan_view.executor') name: this.$t('test_track.plan_view.executor')
})*/ })*/
}) })
}, },
testPlanUserList() { testPlanUserList() {
this.result = this.$get('user/list', response => { this.result = this.$get('user/list/orgId', response => {
this.testPlanReceiverOptions = response.data this.testPlanReceiverOptions = 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) { handleAddTaskModel(type) {
let Task = {}; let Task = {};
Task.events = []; Task.event = [];
Task.userIds = []; Task.userIds = [];
Task.type = ""; Task.type = "";
Task.webhook = ""; Task.webhook = "";
@ -521,25 +537,24 @@ export default {
Task.identification = ""; Task.identification = "";
if (type === 'jenkinsTask') { if (type === 'jenkinsTask') {
Task.taskType = 'JENKINS_TASK' Task.taskType = 'JENKINS_TASK'
this.form.jenkinsTask.unshift(Task) this.form.jenkinsTask.push(Task)
} }
if (type === 'testPlanTask') { if (type === 'testPlanTask') {
Task.taskType = 'TEST_PLAN_TASK' Task.taskType = 'TEST_PLAN_TASK'
this.form.testCasePlanTask.unshift(Task) this.form.testCasePlanTask.push(Task)
} }
if (type === 'reviewTask') { if (type === 'reviewTask') {
Task.taskType = 'REVIEW_TASK' Task.taskType = 'REVIEW_TASK'
this.form.reviewTask.unshift(Task) this.form.reviewTask.push(Task)
} }
if (type === 'defectTask') { if (type === 'defectTask') {
Task.taskType = 'DEFECT_TASK' Task.taskType = 'DEFECT_TASK'
this.form.defectTask.unshift(Task) this.form.defectTask.push(Task)
} }
}, },
handleAddTask(index, data) { handleAddTask(index, data) {
let list = [] let list = []
if(data.events.length>0 && data.userIds.length>0 && data.type){ if (data.event && data.userIds.length > 0 && data.type) {
data.isSet = false data.isSet = false
list.push(data) list.push(data)
let param = {}; let param = {};
@ -548,6 +563,8 @@ export default {
this.initForm() this.initForm()
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
}) })
} else {
this.$warning(this.$t('organization.message.message'));
} }
}, },
removeRowTask(index, data) { // removeRowTask(index, data) { //
@ -558,7 +575,6 @@ export default {
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
this.initForm() this.initForm()
}) })
/*data.splice(index, 1)*/
}, },
rowClass() { rowClass() {
return "text-align:center" return "text-align:center"
@ -566,16 +582,54 @@ export default {
headClass() { headClass() {
return "text-align:center;background:'#ededed'" return "text-align:center;background:'#ededed'"
}, },
handleTestPlanReceivers(row) {
console.log(row);
let testPlanReceivers = JSON.parse(JSON.stringify(this.testPlanReceiverOptions));
switch (row.event) {
case "CREATE":
testPlanReceivers.unshift({id: 'EXECUTOR', name: this.$t('test_track.plan_view.executor')})
break;
case "UPDATE":
case "DELETE":
case "COMMENT":
testPlanReceivers.unshift({id: 'FOUNDER', name: this.$t('api_test.creator')});
break;
default:
break;
}
row.testPlanReceiverOptions = testPlanReceivers;
},
handleReviewReceivers(row) {
console.log(row);
let reviewReceiverOptions = JSON.parse(JSON.stringify(this.reviewReceiverOptions));
switch (row.event) {
case "CREATE":
reviewReceiverOptions.unshift({id: 'EXECUTOR', name: this.$t('test_track.review.reviewer')})
break;
case "UPDATE":
reviewReceiverOptions.unshift({id: 'FOUNDER', name: this.$t('test_track.review.review_creator')})
break;
case "DELETE":
reviewReceiverOptions.unshift({id: 'FOUNDER', name: this.$t('test_track.review.review_creator')})
break;
case "COMMENT":
reviewReceiverOptions.unshift({id: 'MAINTAINER', name: this.$t('test_track.case.maintainer')})
break;
default:
break;
}
row.reviewReceiverOptions = reviewReceiverOptions;
}
} }
} }
</script> </script>
<style scoped> <style scoped>
/deep/ .el-select__tags { /*/deep/ .el-select__tags {
flex-wrap: unset; flex-wrap: unset;
overflow: auto; overflow: auto;
} }*/
.row { .row {
margin-bottom: 30px; margin-bottom: 30px;

View File

@ -228,7 +228,13 @@ export default {
mail: 'mail', mail: 'mail',
nail_robot: 'Nail robot', nail_robot: 'Nail robot',
enterprise_wechat_robot: 'Enterprise wechat robot', enterprise_wechat_robot: 'Enterprise wechat robot',
notes: 'Note: 1. Event, receiving method and receiver are required;\n' +
'\n' +
'2. Webhook is required except email;\n' +
'\n' +
'3. Robots are selected as swarm robots, and "custom keyword" is selected for security verification: "task notification"',
message: 'Event, receiver and receiving method are required\n' +
'\n'
}, },
integration: { integration: {
select_defect_platform: 'Please select the defect management platform to be integrated:', select_defect_platform: 'Please select the defect management platform to be integrated:',

View File

@ -229,7 +229,10 @@ export default {
mail: '邮件', mail: '邮件',
nail_robot: '钉钉机器人', nail_robot: '钉钉机器人',
enterprise_wechat_robot: '企业微信机器人', enterprise_wechat_robot: '企业微信机器人',
notes: '注意: 1.事件,接收方式,接收人为必填项;\n' +
' 2.接收方式除邮件外webhook为必填\n' +
' 3.机器人选择为群机器人,安全验证选择“自定义关键词” "任务通知"',
message: '事件,接收人,接收方式为必填项'
}, },

View File

@ -256,6 +256,13 @@ export default {
mail: '郵件', mail: '郵件',
nail_robot: '釘釘機器人', nail_robot: '釘釘機器人',
enterprise_wechat_robot: '企業微信機器人', enterprise_wechat_robot: '企業微信機器人',
notes: '注意1.事件,接收管道,接收人為必填項;\n' +
'\n' +
'2.接收管道除郵件外webhook為必填\n' +
'\n' +
'3.機器人選擇為群機器人,安全驗證選擇“自定義關鍵字”:“任務通知”',
message: '事件,接收人,接收管道為必填項\n' +
'\n'
} }
}, },
project: { project: {