feat: 前置条件字符长度限制
This commit is contained in:
parent
ce222275fb
commit
1169f46fac
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.notice.controller;
|
||||
|
||||
import io.metersphere.notice.controller.request.NoticeRequest;
|
||||
import io.metersphere.notice.domain.MessageDetail;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import io.metersphere.notice.service.NoticeService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -25,8 +26,8 @@ public class NoticeController {
|
|||
}
|
||||
|
||||
@PostMapping("save/message")
|
||||
public void saveMessage() {
|
||||
|
||||
public void saveMessage(@RequestBody MessageDetail messageDetail) {
|
||||
noticeService.saveMessageTask(messageDetail);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
package io.metersphere.notice.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MessageDetail {
|
||||
private List<String> userIds = new ArrayList<>();
|
||||
private List<String> userNames = new ArrayList<>();
|
||||
private List<String> events = new ArrayList<>();
|
||||
private String id;
|
||||
private String type;
|
||||
private String taskType;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package io.metersphere.notice.message;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
|
||||
public class LinkMessage implements Message {
|
||||
|
||||
private String title;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package io.metersphere.notice.message;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -9,7 +8,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
|
||||
public class TextMessage implements Message {
|
||||
private String text;
|
||||
private List<String> mentionedMobileList;
|
||||
|
|
|
@ -1,9 +1,33 @@
|
|||
package io.metersphere.notice.service;
|
||||
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.OapiRobotSendRequest;
|
||||
import com.dingtalk.api.response.OapiRobotSendResponse;
|
||||
import com.taobao.api.ApiException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Service
|
||||
public class DingTaskService {
|
||||
|
||||
public void sendDingTask() {
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=5129dc4c073d28f67c7452e0de6536c3ca496728d8c014d0a209b88a8814307a");
|
||||
OapiRobotSendRequest request = new OapiRobotSendRequest();
|
||||
request.setMsgtype("text");
|
||||
OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
|
||||
text.setContent("测试计划任务通知:‘创建人’发起的‘测试计划名称‘ 的’计划开始时间‘,’计划结束时间‘请跟进!");
|
||||
request.setText(text);
|
||||
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
|
||||
at.setAtMobiles(Arrays.asList("15135125273"));
|
||||
request.setAt(at);
|
||||
OapiRobotSendResponse response = null;
|
||||
try {
|
||||
response = client.execute(request);
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(response.getErrcode());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.base.domain.Notice;
|
|||
import io.metersphere.base.domain.NoticeExample;
|
||||
import io.metersphere.base.mapper.NoticeMapper;
|
||||
import io.metersphere.notice.controller.request.NoticeRequest;
|
||||
import io.metersphere.notice.domain.MessageDetail;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -78,4 +79,7 @@ public class NoticeService {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void saveMessageTask(MessageDetail messageDetail) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,27 @@
|
|||
package io.metersphere.notice.service;
|
||||
|
||||
import io.metersphere.notice.message.TextMessage;
|
||||
import io.metersphere.notice.util.SendResult;
|
||||
import io.metersphere.notice.util.WxChatbotClient;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class WxChatTaskService {
|
||||
public void enterpriseWechatTask() {
|
||||
TextMessage message = new TextMessage("脸给你打歪");
|
||||
List<String> mentionedMobileList = new ArrayList<String>();
|
||||
mentionedMobileList.add("15135125273");//@群内成员 手机号
|
||||
message.setMentionedMobileList(mentionedMobileList);
|
||||
message.setIsAtAll(true);//@所有人
|
||||
try {
|
||||
SendResult result = WxChatbotClient.send("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a03acc34-4988-4200-a9c7-7c9b30c5601e", message);
|
||||
System.out.println(result);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<span style="font-weight:bold;">{{$t('organization.message.jenkins_task_notification')}}</span>
|
||||
</el-col>
|
||||
<el-col :span="14">
|
||||
<el-button type="text" icon="el-icon-plus" size="mini" @click="handleAddStep('jenkinsTask')">
|
||||
<el-button type="text" icon="el-icon-plus" size="mini" @click="handleAddJenkins('jenkinsTask')">
|
||||
{{$t('organization.message.create_new_notification')}}
|
||||
</el-button>
|
||||
</el-col>
|
||||
|
@ -91,6 +91,279 @@
|
|||
</el-table>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="row">
|
||||
<el-col :span="20">
|
||||
<div class="grid-content bg-purple-dark">
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<span style="font-weight:bold;">{{$t('organization.message.test_plan_task_notification')}}</span>
|
||||
</el-col>
|
||||
<el-col :span="14">
|
||||
<el-button type="text" icon="el-icon-plus" size="mini" @click="handleAddTestPlan('testPlanTask')">
|
||||
{{$t('organization.message.create_new_notification')}}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-table
|
||||
:data="testPlanTask"
|
||||
class="tb-edit"
|
||||
border
|
||||
size="mini"
|
||||
:header-cell-style="{background:'#EDEDED'}"
|
||||
>
|
||||
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="event">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.event" multiple :placeholder="$t('organization.message.select_events')" prop="event">
|
||||
<el-option
|
||||
v-for="item in testPlanEventOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('schedule.receiver')" prop="receiver" min-width="20%">
|
||||
<template v-slot:default="{row}">
|
||||
<el-select v-model="row.userIds" filterable multiple
|
||||
:placeholder="$t('commons.please_select')"
|
||||
@click.native="userList()" style="width: 100%;">
|
||||
<el-option
|
||||
v-for="item in testPlanReceiverOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')">
|
||||
<el-option
|
||||
v-for="item in receiveOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="webhook" min-width="20%" prop="webhook">
|
||||
<template v-slot:default="scope">
|
||||
<el-input v-model="scope.row.webhook" placeholder="webhook地址"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
|
||||
<template v-slot:default="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="mini"
|
||||
v-show="!scope.row.showAdd"
|
||||
@click="handleAddTask(scope.$index,scope.row)"
|
||||
>{{$t('commons.add')}}
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
v-show="!scope.row.showCancel"
|
||||
@click="removeRowTestPlan(scope.$index,scope.row)"
|
||||
>{{$t('commons.cancel')}}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
v-show="scope.row.showDelete"
|
||||
@click="removeRowTestPlan(scope.$index,scope.row)"
|
||||
></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="row">
|
||||
<el-col :span="20">
|
||||
<div class="grid-content bg-purple-dark">
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<span style="font-weight:bold;">{{$t('organization.message.test_review_task_notice')}}</span>
|
||||
</el-col>
|
||||
<el-col :span="14">
|
||||
<el-button type="text" icon="el-icon-plus" size="mini" @click="handleAddReview('reviewTask')">
|
||||
{{$t('organization.message.create_new_notification')}}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-table
|
||||
:data="reviewTask"
|
||||
class="tb-edit"
|
||||
border
|
||||
size="mini"
|
||||
:header-cell-style="{background:'#EDEDED'}"
|
||||
>
|
||||
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="event">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.event" multiple :placeholder="$t('organization.message.select_events')" prop="event">
|
||||
<el-option
|
||||
v-for="item in reviewEventOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('schedule.receiver')" prop="receiver" min-width="20%">
|
||||
<template v-slot:default="{row}">
|
||||
<el-select v-model="row.userIds" filterable multiple
|
||||
:placeholder="$t('commons.please_select')"
|
||||
@click.native="userList()" style="width: 100%;">
|
||||
<el-option
|
||||
v-for="item in reviewReceiverOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')">
|
||||
<el-option
|
||||
v-for="item in receiveOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="webhook" min-width="20%" prop="webhook">
|
||||
<template v-slot:default="scope">
|
||||
<el-input v-model="scope.row.webhook" placeholder="webhook地址"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
|
||||
<template v-slot:default="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="mini"
|
||||
v-show="!scope.row.showAdd"
|
||||
@click="handleAddTask(scope.$index,scope.row)"
|
||||
>{{$t('commons.add')}}
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
v-show="!scope.row.showCancel"
|
||||
@click="removeRowReview(scope.$index,scope.row)"
|
||||
>{{$t('commons.cancel')}}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
v-show="scope.row.showDelete"
|
||||
@click="removeRowReview(scope.$index,scope.row)"
|
||||
></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="row">
|
||||
<el-col :span="20">
|
||||
<div class="grid-content bg-purple-dark">
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<span style="font-weight:bold;">{{$t('organization.message.defect_task_notification')}}</span>
|
||||
</el-col>
|
||||
<el-col :span="14">
|
||||
<el-button type="text" icon="el-icon-plus" size="mini" @click="handleAddDefect('defectTask')">
|
||||
{{$t('organization.message.create_new_notification')}}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-table
|
||||
:data="defectTask"
|
||||
class="tb-edit"
|
||||
border
|
||||
size="mini"
|
||||
:header-cell-style="{background:'#EDEDED'}"
|
||||
>
|
||||
<el-table-column :label="$t('schedule.event')" min-width="20%" prop="event">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.event" multiple :placeholder="$t('organization.message.select_events')" prop="event">
|
||||
<el-option
|
||||
v-for="item in defectEventOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('schedule.receiver')" prop="receiver" min-width="20%">
|
||||
<template v-slot:default="{row}">
|
||||
<el-select v-model="row.userIds" filterable multiple
|
||||
:placeholder="$t('commons.please_select')"
|
||||
@click.native="userList()" style="width: 100%;">
|
||||
<el-option
|
||||
v-for="item in defectReceiverOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('schedule.receiving_mode')" min-width="20%" prop="type">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.type" :placeholder="$t('organization.message.select_receiving_method')">
|
||||
<el-option
|
||||
v-for="item in defectOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="webhook" min-width="20%" prop="webhook">
|
||||
<template v-slot:default="scope">
|
||||
<el-input v-model="scope.row.webhook" placeholder="webhook地址"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('commons.operating')" min-width="20%" prop="result">
|
||||
<template v-slot:default="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="mini"
|
||||
v-show="!scope.row.showAdd"
|
||||
@click="handleAddTask(scope.$index,scope.row)"
|
||||
>{{$t('commons.add')}}
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
v-show="!scope.row.showCancel"
|
||||
@click="removeRowDefect(scope.$index,scope.row)"
|
||||
>{{$t('commons.cancel')}}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
v-show="scope.row.showDelete"
|
||||
@click="removeRowDefect(scope.$index,scope.row)"
|
||||
></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -101,17 +374,44 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
jenkinsTask: [{}],
|
||||
planCaseTask: [{}],
|
||||
jenkinsEventOptions: [
|
||||
{value: 'EXECUTE_SUCCESSFUL', label: this.$t('schedule.event_success')},
|
||||
{value: 'EXECUTE_FAILED', label: this.$t('schedule.event_failed')}
|
||||
],
|
||||
jenkinsReceiverOptions: [],
|
||||
|
||||
testPlanTask:[{}],
|
||||
testPlanEventOptions: [
|
||||
{value: 'CREATE', label: this.$t('commons.create')},
|
||||
{value: 'UPDATE', label: this.$t('commons.update')},
|
||||
{value: 'DELETE', label: this.$t('commons.delete')}
|
||||
],
|
||||
testPlanReceiverOption:[],
|
||||
testPlanReceiverOptions:[],
|
||||
receiveOptions: [
|
||||
{value: 'email', label: this.$t('organization.message.mail')},
|
||||
{value: 'nailRobot', label: this.$t('organization.message.nail_robot')},
|
||||
{value: 'wechatRobot', label: this.$t('organization.message.enterprise_wechat_robot')}
|
||||
],
|
||||
reviewTask:[{}],
|
||||
reviewEventOptions:[
|
||||
{value: 'CREATE', label: this.$t('commons.create')},
|
||||
{value: 'UPDATE', label: this.$t('commons.update')},
|
||||
{value: 'DELETE', label: this.$t('commons.delete')}
|
||||
],
|
||||
reviewReceiverOptions:[],
|
||||
defectTask:[{}],
|
||||
defectEventOptions:[
|
||||
{value: 'CREATE', label: this.$t('commons.create')},
|
||||
{value: 'UPDATE', label: this.$t('commons.update')},
|
||||
{value: 'DELETE', label: this.$t('commons.delete')}
|
||||
],
|
||||
defectOptions:[
|
||||
{value: 'email', label: this.$t('organization.message.mail')},
|
||||
{value: 'nailRobot', label: this.$t('organization.message.nail_robot')},
|
||||
{value: 'wechatRobot', label: this.$t('organization.message.enterprise_wechat_robot')}
|
||||
],
|
||||
defectReceiverOptions:[{}],
|
||||
webhook: "",
|
||||
showAdd: true,
|
||||
showDelete: false,
|
||||
|
@ -125,22 +425,53 @@ export default {
|
|||
this.jenkinsReceiverOptions = response.data
|
||||
})
|
||||
},
|
||||
handleAddStep(index, data) {
|
||||
handleAddJenkins(index, data) {
|
||||
this.showAdd = true;
|
||||
this.showCancel = true;
|
||||
this.showDelete = false;
|
||||
let jenkinsTask = {};
|
||||
this.jenkinsTask.unshift(jenkinsTask)
|
||||
},
|
||||
handleAddTestPlan(index, data) {
|
||||
this.showAdd = true;
|
||||
this.showCancel = true;
|
||||
this.showDelete = false;
|
||||
let testPlanTask = {};
|
||||
this.testPlanTask.unshift(testPlanTask)
|
||||
},
|
||||
handleAddReview(index, data) {
|
||||
this.showAdd = true;
|
||||
this.showCancel = true;
|
||||
this.showDelete = false;
|
||||
let reviewTask = {};
|
||||
this.reviewTask.unshift(reviewTask)
|
||||
},
|
||||
handleAddDefect(index, data) {
|
||||
this.showAdd = true;
|
||||
this.showCancel = true;
|
||||
this.showDelete = false;
|
||||
let defectTask = {};
|
||||
this.defectTask.unshift(defectTask)
|
||||
},
|
||||
handleAddTask(index,row) {
|
||||
this.result = this.$post('/notice/save', this.jenkinsTask, () => {
|
||||
this.result = this.$post('/notice/save/message', this.jenkinsTask, () => {
|
||||
|
||||
})
|
||||
|
||||
},
|
||||
removeRow(index, rows) { //删除
|
||||
this.jenkinsTask.splice(index, 1)
|
||||
},
|
||||
removeRowTestPlan(index, rows) { //删除
|
||||
this.testPlanTask.splice(index, 1)
|
||||
},
|
||||
removeRowReview(index, rows) { //删除
|
||||
this.reviewTask.splice(index, 1)
|
||||
},
|
||||
removeRowDefect(index, rows) { //删除
|
||||
this.defectTask.splice(index, 1)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue