feat: 消息设置
This commit is contained in:
parent
d2e1b81c6a
commit
1b4047386e
|
@ -32,7 +32,7 @@ public class NoticeController {
|
|||
}
|
||||
|
||||
@GetMapping("/search/message")
|
||||
public List<MessageSettingDetail> searchMessage() {
|
||||
public MessageSettingDetail searchMessage() {
|
||||
return noticeService.searchMessage();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.util.List;
|
|||
@Data
|
||||
public class MessageDetail extends MessageTask {
|
||||
private List<String> userIds = new ArrayList<>();
|
||||
private List<String> userNames = new ArrayList<>();
|
||||
private List<String> events = new ArrayList<>();
|
||||
private String taskType;
|
||||
private String webhook;
|
||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.base.mapper.MessageTaskMapper;
|
|||
import io.metersphere.base.mapper.NoticeMapper;
|
||||
import io.metersphere.notice.controller.request.MessageRequest;
|
||||
import io.metersphere.notice.controller.request.NoticeRequest;
|
||||
import io.metersphere.notice.domain.MessageDetail;
|
||||
import io.metersphere.notice.domain.MessageSettingDetail;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
@ -16,7 +17,9 @@ import org.springframework.stereotype.Service;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.metersphere.commons.constants.NoticeConstants.EXECUTE_FAILED;
|
||||
import static io.metersphere.commons.constants.NoticeConstants.EXECUTE_SUCCESSFUL;
|
||||
|
@ -86,7 +89,7 @@ public class NoticeService {
|
|||
}
|
||||
|
||||
public void saveMessageTask(MessageRequest messageRequest) {
|
||||
String identification=UUID.randomUUID().toString();
|
||||
String identification = UUID.randomUUID().toString();
|
||||
messageRequest.getMessageDetail().forEach(list -> {
|
||||
list.getEvents().forEach(n -> {
|
||||
list.getUserIds().forEach(m -> {
|
||||
|
@ -106,12 +109,42 @@ public class NoticeService {
|
|||
|
||||
}
|
||||
|
||||
public List<MessageSettingDetail> searchMessage() {
|
||||
public MessageSettingDetail searchMessage() {
|
||||
MessageTaskExample messageTaskExample = new MessageTaskExample();
|
||||
messageTaskExample.createCriteria();
|
||||
List<MessageTask> messageTasks = new ArrayList<>();
|
||||
List<MessageSettingDetail> messageSettingDetail = new ArrayList<>();
|
||||
messageTasks = messageTaskMapper.selectByExample(messageTaskExample);
|
||||
List<MessageTask> messageTaskLists = new ArrayList<>();
|
||||
List<String> userIds = new ArrayList<>();
|
||||
List<String> events = new ArrayList<>();
|
||||
MessageSettingDetail messageSettingDetail = new MessageSettingDetail();
|
||||
MessageDetail messageDetail = new MessageDetail();
|
||||
List<MessageDetail> MessageDetailList = new ArrayList<>();
|
||||
messageTaskLists = messageTaskMapper.selectByExample(messageTaskExample);
|
||||
Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(e -> fetchGroupKey(e)));
|
||||
MessageTaskMap.forEach((k, v) -> {
|
||||
for (MessageTask m : v) {
|
||||
userIds.add(m.getId());
|
||||
events.add(m.getEvent());
|
||||
messageDetail.setTaskType(m.getTaskType());
|
||||
messageDetail.setWebhook(m.getWebhook());
|
||||
messageDetail.setIdentification(m.getIdentification());
|
||||
messageDetail.setType(m.getType());
|
||||
}
|
||||
messageDetail.setEvents(events);
|
||||
messageDetail.setUserIds(userIds);
|
||||
MessageDetailList.add(messageDetail);
|
||||
});
|
||||
List<MessageDetail> jenkinsTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals("jenkinsTask")).collect(Collectors.toList());
|
||||
List<MessageDetail> testCasePlanTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals("testPlanTask")).collect(Collectors.toList());
|
||||
List<MessageDetail> reviewTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals("reviewTask")).collect(Collectors.toList());
|
||||
List<MessageDetail> defectTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals("defect")).collect(Collectors.toList());
|
||||
messageSettingDetail.setJenkinsTask(jenkinsTask);
|
||||
messageSettingDetail.setTestCasePlanTask(testCasePlanTask);
|
||||
messageSettingDetail.setReviewTask(reviewTask);
|
||||
messageSettingDetail.setDefectTask(defectTask);
|
||||
return messageSettingDetail;
|
||||
}
|
||||
|
||||
private static String fetchGroupKey(MessageTask user) {
|
||||
return user.getTaskType() + "#" + user.getIdentification();
|
||||
}
|
||||
}
|
|
@ -15,8 +15,11 @@ import io.metersphere.commons.utils.LogUtil;
|
|||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.controller.request.member.QueryMemberRequest;
|
||||
import io.metersphere.notice.domain.MessageDetail;
|
||||
import io.metersphere.notice.domain.MessageSettingDetail;
|
||||
import io.metersphere.notice.service.DingTaskService;
|
||||
import io.metersphere.notice.service.MailService;
|
||||
import io.metersphere.notice.service.NoticeService;
|
||||
import io.metersphere.notice.service.WxChatTaskService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.track.dto.TestCaseReviewDTO;
|
||||
|
@ -77,6 +80,8 @@ public class TestCaseReviewService {
|
|||
DingTaskService dingTaskService;
|
||||
@Resource
|
||||
WxChatTaskService wxChatTaskService;
|
||||
@Resource
|
||||
NoticeService noticeService;
|
||||
|
||||
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
|
||||
checkCaseReviewExist(reviewRequest);
|
||||
|
@ -105,6 +110,9 @@ public class TestCaseReviewService {
|
|||
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
|
||||
testCaseReviewMapper.insert(reviewRequest);
|
||||
String context = getReviewContext(reviewRequest, "create");
|
||||
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
|
||||
List<MessageDetail> reviewTasklist = messageSettingDetail.getReviewTask();
|
||||
|
||||
try {
|
||||
if (StringUtils.equals(NoticeConstants.NAIL_ROBOT, "NAIL_ROBOT")) {
|
||||
dingTaskService.sendDingTask(context, userIds);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
alter table message_task modify webhook varchar(255) null comment 'webhook地址';
|
|
@ -26,7 +26,7 @@
|
|||
>
|
||||
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="events">
|
||||
<template slot-scope="scope">
|
||||
<el-select :disabled="isReadOnly" v-model="scope.row.events" multiple
|
||||
<el-select v-model="scope.row.events" multiple
|
||||
:placeholder="$t('organization.message.select_events')"
|
||||
prop="events">
|
||||
<el-option
|
||||
|
@ -386,7 +386,7 @@ export default {
|
|||
return {
|
||||
form: {
|
||||
jenkinsTask: [{
|
||||
taskType: 'jenkins',
|
||||
taskType: "jenkinsTask",
|
||||
events: [],
|
||||
userIds: [],
|
||||
type: [],
|
||||
|
@ -398,7 +398,7 @@ export default {
|
|||
}
|
||||
}],
|
||||
testPlanTask: [{
|
||||
taskType: 'testPlan',
|
||||
taskType: "testPlanTask",
|
||||
events: [],
|
||||
userIds: [],
|
||||
type: [],
|
||||
|
@ -410,7 +410,7 @@ export default {
|
|||
}
|
||||
}],
|
||||
reviewTask: [{
|
||||
taskType: 'review',
|
||||
taskType: "reviewTask",
|
||||
events: [],
|
||||
userIds: [],
|
||||
type: [],
|
||||
|
@ -422,7 +422,7 @@ export default {
|
|||
}
|
||||
}],
|
||||
defectTask: [{
|
||||
taskType: 'defect',
|
||||
taskType: "defect",
|
||||
events: [],
|
||||
userIds: [],
|
||||
type: [],
|
||||
|
@ -457,13 +457,13 @@ export default {
|
|||
defectReceiverOptions: [],
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
activated(){
|
||||
this.initForm()
|
||||
},
|
||||
methods: {
|
||||
initForm() {
|
||||
this.result = this.$get('/notice/search/message', response => {
|
||||
|
||||
/*this.form=response.data*/
|
||||
})
|
||||
},
|
||||
userList() {
|
||||
|
|
Loading…
Reference in New Issue