提交 0a3e0574 编写于 作者: W wenyann

fix(消息设置): 消息设置

上级 0da55f5e
......@@ -182,51 +182,41 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
List<String> userIds = new ArrayList<>();
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList = messageSettingDetail.getJenkinsTask();
if (StringUtils.equals(report.getStatus(), "Success")) {
}
String contextSuccess = report.getName() + "执行成功";
;
String contextFailed = report.getName() + "执行失败";
taskList.forEach(r -> {
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
r.getEvents().forEach(e -> {
if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, e) && StringUtils.equals(report.getStatus(), "Success")) {
if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL,r.getEvent()) && StringUtils.equals(report.getStatus(), "Success")) {
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);
}
});
break;
case NoticeConstants.WECHAT_ROBOT:
r.getEvents().forEach(e -> {
if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, e) && StringUtils.equals(report.getStatus(), "Success")) {
if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, r.getEvent()) && StringUtils.equals(report.getStatus(), "Success")) {
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);
}
});
break;
case NoticeConstants.EMAIL:
r.getEvents().forEach(e -> {
if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, e) && StringUtils.equals(report.getStatus(), "Success")) {
if (StringUtils.equals(NoticeConstants.EXECUTE_SUCCESSFUL, r.getEvent()) && StringUtils.equals(report.getStatus(), "Success")) {
try {
mailService.sendApiJenkinsNotification(contextSuccess, r);
} catch (MessagingException messagingException) {
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 {
mailService.sendApiJenkinsNotification(contextFailed, r);
} catch (MessagingException messagingException) {
messagingException.printStackTrace();
}
}
});
break;
}
});
......
......@@ -21,5 +21,7 @@ public class MessageTask implements Serializable {
private Boolean isSet;
private String organizationId;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -653,6 +653,76 @@ public class MessageTaskExample {
addCriterion("is_set not between", value1, value2, "isSet");
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 {
......
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class TestPlan implements Serializable {
......
......@@ -9,7 +9,8 @@
<result column="task_type" jdbcType="VARCHAR" property="taskType" />
<result column="webhook" jdbcType="VARCHAR" property="webhook" />
<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>
<sql id="Example_Where_Clause">
<where>
......@@ -70,7 +71,7 @@
</where>
</sql>
<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>
<select id="selectByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultMap="BaseResultMap">
select
......@@ -103,12 +104,14 @@
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.MessageTask">
insert into message_task (id, `type`, event,
user_id, task_type, webhook,
identification, is_set)
values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{webhook,jdbcType=VARCHAR},
#{identification,jdbcType=VARCHAR}, #{isSet,jdbcType=BIT})
insert into message_task (id, `type`, event,
user_id, task_type, webhook,
identification, is_set, organization_id
)
values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{webhook,jdbcType=VARCHAR},
#{identification,jdbcType=VARCHAR}, #{isSet,jdbcType=BIT}, #{organizationId,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.MessageTask">
insert into message_task
......@@ -137,6 +140,9 @@
<if test="isSet != null">
is_set,
</if>
<if test="organizationId != null">
organization_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
......@@ -163,6 +169,9 @@
<if test="isSet != null">
#{isSet,jdbcType=BIT},
</if>
<if test="organizationId != null">
#{organizationId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultType="java.lang.Long">
......@@ -198,6 +207,9 @@
<if test="record.isSet != null">
is_set = #{record.isSet,jdbcType=BIT},
</if>
<if test="record.organizationId != null">
organization_id = #{record.organizationId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -206,13 +218,14 @@
<update id="updateByExample" parameterType="map">
update message_task
set id = #{record.id,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
event = #{record.event,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
task_type = #{record.taskType,jdbcType=VARCHAR},
webhook = #{record.webhook,jdbcType=VARCHAR},
identification = #{record.identification,jdbcType=VARCHAR},
is_set = #{record.isSet,jdbcType=BIT}
`type` = #{record.type,jdbcType=VARCHAR},
event = #{record.event,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
task_type = #{record.taskType,jdbcType=VARCHAR},
webhook = #{record.webhook,jdbcType=VARCHAR},
identification = #{record.identification,jdbcType=VARCHAR},
is_set = #{record.isSet,jdbcType=BIT},
organization_id = #{record.organizationId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -241,18 +254,22 @@
<if test="isSet != null">
is_set = #{isSet,jdbcType=BIT},
</if>
<if test="organizationId != null">
organization_id = #{organizationId,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},
user_id = #{userId,jdbcType=VARCHAR},
task_type = #{taskType,jdbcType=VARCHAR},
webhook = #{webhook,jdbcType=VARCHAR},
identification = #{identification,jdbcType=VARCHAR},
is_set = #{isSet,jdbcType=BIT}
set `type` = #{type,jdbcType=VARCHAR},
event = #{event,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
task_type = #{taskType,jdbcType=VARCHAR},
webhook = #{webhook,jdbcType=VARCHAR},
identification = #{identification,jdbcType=VARCHAR},
is_set = #{isSet,jdbcType=BIT},
organization_id = #{organizationId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
......@@ -9,14 +9,14 @@ public interface NoticeConstants {
String CREATE = "CREATE";
String UPDATE = "UPDATE";
String DELETE = "DELETE";
String COMMENT = "COMMENT";
String JENKINS_TASK = "JENKINS_TASK";
String TEST_PLAN_TASK = "TEST_PLAN_TASK";
String REVIEW_TASK = "REVIEW_TASK";
String DEFECT_TASK = "DEFECT_TASK";
String FOUNDER = "FOUNDER";
String EXECUTOR = "EXECUTOR";
String MAINTAINER = "MAINTAINER";
String COMMENT = "COMMENT";
String FOUNDER = "FOUNDER";//创建人
String EXECUTOR = "EXECUTOR";//负责人(评审人)
String MAINTAINER = "MAINTAINER";//维护人
String API = "API";
String SCHEDULE = "SCHEDULE";
......
......@@ -133,7 +133,10 @@ public class UserController {
public List<User> getUserList() {
return userService.getUserList();
}
@GetMapping("/list/orgId")
public List<User> getUserListByOrgId() {
return userService.getUserListByOrgId();
}
@PostMapping("/update/current")
public UserDTO updateCurrentUser(@RequestBody User user) {
userService.updateUser(user);
......
......@@ -9,10 +9,11 @@ import java.util.List;
@Data
public class MessageDetail {
private List<String> userIds = new ArrayList<>();
private List<String> events = new ArrayList<>();
private String event;
private String taskType;
private String webhook;
private String type;
private String identification;
private String organizationId;
private Boolean isSet;
}
......@@ -27,30 +27,17 @@ public class DingTaskService {
public 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)) {
if (StringUtils.equals(eventType, messageDetail.getEvent())) {
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);
}
if (StringUtils.equals(NoticeConstants.CREATE, eventType) && StringUtils.equals(NoticeConstants.EXECUTOR, u)) {
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)) {
}else{
addresseeIdList.addAll(userIds);
}
});
sendDingTask(context, addresseeIdList, messageDetail.getWebhook());
}
});
}
public void sendDingTask(String context, List<String> userIds, String Webhook) {
......
......@@ -172,7 +172,7 @@ public class MailService {
public void sendReviewerNotice(MessageDetail messageDetail, List<String> userIds, SaveTestCaseReviewRequest reviewRequest, String eventType) {
Map<String, String> context = getReviewContext(reviewRequest);
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);
} catch (Exception e) {
LogUtil.error(e);
......@@ -183,7 +183,7 @@ public class MailService {
public void sendTestPlanStartNotice(MessageDetail messageDetail, List<String> userIds, AddTestPlanRequest testPlan, String eventType) {
Map<String, String> context = getTestPlanContext(testPlan);
context.put("creator", userIds.toString());
context.put("creator", testPlan.getCreator());
try {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/testPlanStart.html"), StandardCharsets.UTF_8);
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) {
List<String> addresseeIdList = new ArrayList<>();
messageDetail.getEvents().forEach(e -> {
if (StringUtils.equals(eventType, e)) {
if (StringUtils.equals(eventType, messageDetail.getEvent())) {
messageDetail.getUserIds().forEach(u -> {
if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) {
addresseeIdList.add(u);
......@@ -446,7 +445,6 @@ public class MailService {
});
}
});
return addresseeIdList;
}
}
......
......@@ -7,6 +7,8 @@ import io.metersphere.base.domain.NoticeExample;
import io.metersphere.base.mapper.MessageTaskMapper;
import io.metersphere.base.mapper.NoticeMapper;
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.NoticeRequest;
import io.metersphere.notice.domain.MessageDetail;
......@@ -31,9 +33,6 @@ public class NoticeService {
@Resource
private MessageTaskMapper messageTaskMapper;
@Resource
MailService mailService;
public void saveNotice(NoticeRequest noticeRequest) {
NoticeExample example = new NoticeExample();
example.createCriteria().andTestIdEqualTo(noticeRequest.getTestId());
......@@ -93,29 +92,30 @@ public class NoticeService {
public void saveMessageTask(MessageRequest messageRequest) {
String identification = UUID.randomUUID().toString();
SessionUser user = SessionUtils.getUser();
String orgId = user.getLastOrganizationId();
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.setEvent(list.getEvent());
message.setTaskType(list.getTaskType());
message.setUserId(m);
message.setType(list.getType());
message.setWebhook(list.getWebhook());
message.setIdentification(identification);
message.setIsSet(list.getIsSet());
message.setOrganizationId(orgId);
messageTaskMapper.insert(message);
});
});
});
}
public MessageSettingDetail searchMessage() {
SessionUser user = SessionUtils.getUser();
String orgId = user.getLastOrganizationId();
MessageTaskExample messageTaskExample = new MessageTaskExample();
messageTaskExample.createCriteria();
messageTaskExample.createCriteria().andOrganizationIdEqualTo(orgId);
List<MessageTask> messageTaskLists = new ArrayList<>();
MessageSettingDetail messageSettingDetail = new MessageSettingDetail();
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)));
MessageTaskMap.forEach((k, v) -> {
Set userIds = new HashSet();
Set events = new HashSet();
MessageDetail messageDetail = new MessageDetail();
for (MessageTask m : v) {
userIds.add(m.getUserId());
events.add(m.getEvent());
messageDetail.setEvent(m.getEvent());
messageDetail.setTaskType(m.getTaskType());
messageDetail.setWebhook(m.getWebhook());
messageDetail.setIdentification(m.getIdentification());
messageDetail.setType(m.getType());
messageDetail.setIsSet(m.getIsSet());
}
messageDetail.setEvents(new ArrayList(events));
messageDetail.setUserIds(new ArrayList(userIds));
MessageDetailList.add(messageDetail);
});
......@@ -158,86 +156,4 @@ public class NoticeService {
example.createCriteria().andIdentificationEqualTo(identification);
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);
}
});
}
}*/
}
\ No newline at end of file
......@@ -26,30 +26,16 @@ public class WxChatTaskService {
public 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)) {
if (StringUtils.equals(eventType, messageDetail.getEvent())) {
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);
}
if (StringUtils.equals(NoticeConstants.CREATE, eventType) && StringUtils.equals(NoticeConstants.EXECUTOR, u)) {
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)) {
}else{
addresseeIdList.addAll(userIds);
}
if (StringUtils.equals(NoticeConstants.COMMENT, eventType) && StringUtils.equals(NoticeConstants.MAINTAINER, u)) {
addresseeIdList.addAll(userIds);
}
});
enterpriseWechatTask(context, addresseeIdList, messageDetail.getWebhook());
}
});
}
public void enterpriseWechatTask(String context, List<String> userIds, String Webhook) {
......
......@@ -266,6 +266,13 @@ public class UserService {
example.setOrderByClause("update_time desc");
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) {
return extUserMapper.getUserList(request);
......
......@@ -184,6 +184,8 @@ public class TestCaseReviewService {
testCaseReview.setUpdateTime(System.currentTimeMillis());
checkCaseReviewExist(testCaseReview);
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
List<String> userIds=new ArrayList<>();
userIds.addAll(testCaseReview.getUserIds());
try {
String context = getReviewContext(testCaseReview, NoticeConstants.CREATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
......@@ -191,13 +193,13 @@ public class TestCaseReviewService {
taskList.forEach(r -> {
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
dingTaskService.sendNailRobot(r, testCaseReview.getUserIds(), context, NoticeConstants.CREATE);
dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.CREATE);
break;
case NoticeConstants.WECHAT_ROBOT:
wxChatTaskService.sendWechatRobot(r, testCaseReview.getUserIds(), context, NoticeConstants.CREATE);
wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.CREATE);
break;
case NoticeConstants.EMAIL:
mailService.sendReviewerNotice(r, testCaseReview.getUserIds(), testCaseReview, NoticeConstants.CREATE);
mailService.sendReviewerNotice(r, userIds, testCaseReview, NoticeConstants.CREATE);
break;
}
});
......
......@@ -115,7 +115,6 @@ public class TestPlanService {
testPlan.setUpdateTime(System.currentTimeMillis());
testPlan.setCreator(SessionUtils.getUser().getId());
testPlanMapper.insert(testPlan);
List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal());
try {
......@@ -160,33 +159,34 @@ public class TestPlanService {
testPlan.setActualStartTime(System.currentTimeMillis());
} else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus())) {
List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal());
AddTestPlanRequest testPlans = new AddTestPlanRequest();
//已完成,写入实际完成时间
testPlan.setActualEndTime(System.currentTimeMillis());
try {
BeanUtils.copyBean(testPlans, testPlan);
String context = getTestPlanContext(testPlans, NoticeConstants.CREATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList = messageSettingDetail.getReviewTask();
taskList.forEach(r -> {
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.CREATE);
break;
case NoticeConstants.WECHAT_ROBOT:
wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.CREATE);
break;
case NoticeConstants.EMAIL:
mailService.sendTestPlanStartNotice(r, userIds, testPlans, NoticeConstants.CREATE);
break;
}
});
} catch (Exception e) {
LogUtil.error(e);
}
}
List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal());
AddTestPlanRequest testPlans = new AddTestPlanRequest();
/* try {
BeanUtils.copyBean(testPlans, testPlan);
String context = getTestPlanContext(testPlans, NoticeConstants.CREATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList = messageSettingDetail.getReviewTask();
taskList.forEach(r -> {
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.CREATE);
break;
case NoticeConstants.WECHAT_ROBOT:
wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.CREATE);
break;
case NoticeConstants.EMAIL:
mailService.sendTestPlanStartNotice(r, userIds, testPlans, NoticeConstants.CREATE);
break;
}
});
} catch (Exception e) {
LogUtil.error(e);
}*/
return testPlanMapper.updateByPrimaryKeySelective(testPlan);
}
......@@ -253,7 +253,7 @@ public class TestPlanService {
BeanUtils.copyBean(testPlans, testPlan);
String context = getTestPlanContext(testPlans, NoticeConstants.DELETE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList = messageSettingDetail.getReviewTask();
List<MessageDetail> taskList = messageSettingDetail.getTestCasePlanTask();
taskList.forEach(r -> {
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
......@@ -493,7 +493,7 @@ public class TestPlanService {
BeanUtils.copyBean(_testPlans, testPlans);
String context = getTestPlanContext(_testPlans, NoticeConstants.UPDATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList = messageSettingDetail.getReviewTask();
List<MessageDetail> taskList = messageSettingDetail.getTestCasePlanTask();
taskList.forEach(r -> {
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
......
alter table message_task
add organization_id varchar(255) null;
\ No newline at end of file
......@@ -6,7 +6,7 @@
</head>
<body>
<div>
<p style="text-align: left">${creator} 发起的:<br>
<p style="text-align: left">${creator} 发起的用例评审:<br>
${reviewName}<br>
计划开始时间是:${start}<br>
计划结束时间为:${end}<br>
......
......@@ -12,7 +12,7 @@
计划结束时间为:${end}<br>
请跟进!<br>
点击下面链接进入测试计划页面</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>
</body>
</html>
\ No newline at end of file
<template>
<div style="margin-left: 40px">
<el-alert
:title="$t('organization.message.notes')"
type="info">
</el-alert>
<el-form :model="form" ref="from">
<el-row class="row">
<el-col :span="20">
<el-col :span="24">
<div class="grid-content bg-purple-dark">
<el-row>
<el-col :span="10">
......@@ -28,7 +32,7 @@
>
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
<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')"
prop="events" :disabled="!scope.row.isSet">
<el-option
......@@ -56,7 +60,8 @@
</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')" :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
v-for="item in receiveTypeOptions"
......@@ -69,7 +74,8 @@
</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地址" :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>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
......@@ -102,7 +108,7 @@
</el-col>
</el-row>
<el-row class="row">
<el-col :span="20">
<el-col :span="24">
<div class="grid-content bg-purple-dark">
<el-row>
<el-col :span="10">
......@@ -125,7 +131,7 @@
>
<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')"
<el-select v-model="scope.row.event" :placeholder="$t('organization.message.select_events')"
prop="events" :disabled="!scope.row.isSet">
<el-option
v-for="item in otherEventOptions"
......@@ -152,7 +158,8 @@
</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')" :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
v-for="item in receiveTypeOptions"
:key="item.value"
......@@ -164,7 +171,8 @@
</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地址" :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>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
......@@ -195,7 +203,7 @@
</el-col>
</el-row>
<el-row class="row">
<el-col :span="20">
<el-col :span="24">
<div class="grid-content bg-purple-dark">
<el-row>
<el-col :span="10">
......@@ -218,7 +226,7 @@
>
<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')"
<el-select v-model="scope.row.event" :placeholder="$t('organization.message.select_events')"
prop="event" :disabled="!scope.row.isSet">
<el-option
v-for="item in reviewTaskEventOptions"
......@@ -245,7 +253,8 @@
</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')" :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
v-for="item in receiveTypeOptions"
:key="item.value"
......@@ -257,7 +266,8 @@
</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地址" :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>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
......@@ -288,7 +298,7 @@
</el-col>
</el-row>
<el-row class="row">
<el-col :span="20">
<el-col :span="24">
<div class="grid-content bg-purple-dark">
<el-row>
<el-col :span="10">
......@@ -311,7 +321,7 @@
>
<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')"
<el-select v-model="scope.row.event" :placeholder="$t('organization.message.select_events')"
prop="event" :disabled="!scope.row.isSet">
<el-option
v-for="item in defectEventOptions"
......@@ -338,7 +348,8 @@
</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')" :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
v-for="item in receiveTypeOptions"
:key="item.value"
......@@ -350,7 +361,8 @@
</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地址" :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>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
......@@ -385,47 +397,53 @@
</template>
<script>
import {getCurrentUser, listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
export default {
name: "TaskNotification",
data() {
return {
form: {
jenkinsTask: [{
taskType: "jenkinsTask",
events: [],
event: "",
userIds: [],
type: [],
webhook: "",
isSet: true,
identification: "",
isReadOnly: false,
}],
testCasePlanTask: [{
taskType: "testPlanTask",
events: [],
event: "",
userIds: [],
type: [],
webhook: "",
isSet: true,
identification: "",
isReadOnly: false,
}],
reviewTask: [{
taskType: "reviewTask",
events: [],
event: "",
userIds: [],
type: [],
webhook: "",
isSet: true,
identification: "",
isReadOnly: false,
}],
defectTask: [{
taskType: "defectTask",
events: [],
event: "",
userIds: [],
type: [],
webhook: "",
isSet: true,
identification: "",
isReadOnly: false,
}],
},
jenkinsEventOptions: [
......@@ -443,17 +461,14 @@ export default {
{value: 'UPDATE', label: this.$t('commons.update')},
{value: 'DELETE', label: this.$t('commons.delete')}
],
reviewTaskEventOptions:[
reviewTaskEventOptions: [
{value: 'CREATE', label: this.$t('commons.create')},
{value: 'UPDATE', label: this.$t('commons.update')},
{value: 'DELETE', label: this.$t('commons.delete')},
{value: 'COMMENT', label: this.$t('commons.comment')}
],
defectEventOptions:[
defectEventOptions: [
{value: 'CREATE', label: this.$t('commons.create')},
/*
{value: 'UPDATE', label: this.$t('commons.update')},
*/
],
//测试计划
testPlanReceiverOptions: [],
......@@ -461,6 +476,8 @@ export default {
reviewReceiverOptions: [],
//缺陷
defectReceiverOptions: [],
rules: {},
}
},
......@@ -472,8 +489,14 @@ export default {
this.reviewUerList()
},
methods: {
handleEdit(index, data){
handleEdit(index, data) {
data.isReadOnly = true;
if (data.type === 'EMAIL') {
data.isReadOnly = !data.isReadOnly
}
},
currentUser: () => {
return getCurrentUser();
},
initForm() {
this.result = this.$get('/notice/search/message', response => {
......@@ -481,12 +504,12 @@ export default {
})
},
userList() {
this.result = this.$get('user/list', response => {
this.result = this.$get('user/list/orgId', response => {
this.jenkinsReceiverOptions = response.data
})
},
reviewUerList() {
this.result = this.$get('user/list', response => {
this.result = this.$get('user/list/orgId', response => {
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')},
......@@ -494,16 +517,16 @@ export default {
})
},
defectUserList() {
this.result = this.$get('user/list', response => {
this.result = this.$get('user/list/orgId', response => {
this.defectReceiverOptions = response.data
/* this.defectReceiverOptions.unshift({id: 'FOUNDER', name: this.$t('api_test.creator')}, {
id: 'EXECUTOR',
name: this.$t('test_track.plan_view.executor')
})*/
/* this.defectReceiverOptions.unshift({id: 'FOUNDER', name: this.$t('api_test.creator')}, {
id: 'EXECUTOR',
name: this.$t('test_track.plan_view.executor')
})*/
})
},
testPlanUserList() {
this.result = this.$get('user/list', response => {
this.result = this.$get('user/list/orgId', response => {
this.testPlanReceiverOptions = response.data
this.testPlanReceiverOptions.unshift({id: 'FOUNDER', name: this.$t('api_test.creator')}, {
id: 'EXECUTOR',
......@@ -513,7 +536,7 @@ export default {
},
handleAddTaskModel(type) {
let Task = {};
Task.events = [];
Task.event = [];
Task.userIds = [];
Task.type = "";
Task.webhook = "";
......@@ -536,10 +559,9 @@ export default {
this.form.defectTask.unshift(Task)
}
},
handleAddTask(index, data) {
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
list.push(data)
let param = {};
......@@ -558,7 +580,6 @@ export default {
this.$success(this.$t('commons.delete_success'));
this.initForm()
})
/*data.splice(index, 1)*/
},
rowClass() {
return "text-align:center"
......@@ -572,10 +593,10 @@ export default {
</script>
<style scoped>
/deep/ .el-select__tags {
/*/deep/ .el-select__tags {
flex-wrap: unset;
overflow: auto;
}
}*/
.row {
margin-bottom: 30px;
......
......@@ -218,16 +218,21 @@ export default {
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',
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',
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"'
},
integration: {
......
......@@ -219,17 +219,19 @@ export default {
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:'企业微信机器人',
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: '企业微信机器人',
notes: '注意: 1.事件,接收方式,接收人为必填项;\n' +
' 2.接收方式除邮件外webhook为必填;\n' +
' 3.机器人选择为群机器人,安全验证选择“自定义关键词” :"任务通知"'
},
......
......@@ -253,9 +253,14 @@ export default {
not_integrated: '未集成該平臺',
choose_platform: '請選擇集成的平臺',
verified: '驗證通過',
mail:'郵件',
nail_robot:'釘釘機器人',
enterprise_wechat_robot:'企業微信機器人',
mail: '郵件',
nail_robot: '釘釘機器人',
enterprise_wechat_robot: '企業微信機器人',
notes: '注意:1.事件,接收管道,接收人為必填項;\n' +
'\n' +
'2.接收管道除郵件外webhook為必填;\n' +
'\n' +
'3.機器人選擇為群機器人,安全驗證選擇“自定義關鍵字”:“任務通知”'
}
},
project: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册