fix(消息通知): swagger定时同步通知问题
--bug=1014692 --user=李玉号 【消息通知】swagger定时任务导入失败后没有通知 https://www.tapd.cn/55049933/s/1205391 --bug=1014691 --user=李玉号 【消息通知】swagger定时同步,同步成功后,没有发送企业微信通知 https://www.tapd.cn/55049933/s/1205397
This commit is contained in:
parent
6a87a14ff7
commit
2727fd2ee2
|
@ -1549,15 +1549,17 @@ public class ApiDefinitionService {
|
|||
}
|
||||
ApiImportParser runService = ApiDefinitionImportParserFactory.getApiImportParser(request.getPlatform());
|
||||
ApiDefinitionImport apiImport = null;
|
||||
Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
|
||||
if (StringUtils.isNotBlank(request.getSwaggerUrl())) {
|
||||
if (!request.getPlatform().equalsIgnoreCase("Swagger2")) {
|
||||
this.sendFailMessage(request, project);
|
||||
MSException.throwException("文件格式不符合要求");
|
||||
}
|
||||
if (!UrlTestUtils.testUrlWithTimeOut(request.getSwaggerUrl(), 30000)) {
|
||||
this.sendFailMessage(request, project);
|
||||
MSException.throwException(Translator.get("connection_timeout"));
|
||||
}
|
||||
}
|
||||
Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
|
||||
if (StringUtils.equals(request.getType(), "schedule")) {
|
||||
request.setProtocol("HTTP");
|
||||
}
|
||||
|
@ -1567,6 +1569,8 @@ public class ApiDefinitionService {
|
|||
apiImport.setMocks(new ArrayList<>());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 发送通知
|
||||
this.sendFailMessage(request, project);
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
String returnThrowException = e.getMessage();
|
||||
if (StringUtils.contains(returnThrowException, "模块树最大深度为")) {
|
||||
|
@ -1578,23 +1582,6 @@ public class ApiDefinitionService {
|
|||
MSException.throwException(Translator.get("parse_data_error"));
|
||||
}
|
||||
}
|
||||
// 发送通知
|
||||
if (StringUtils.equals(request.getType(), "schedule")) {
|
||||
String scheduleId = scheduleService.getScheduleInfo(request.getResourceId());
|
||||
String context = request.getSwaggerUrl() + "导入失败";
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("url", request.getSwaggerUrl());
|
||||
paramMap.put("projectId", request.getProjectId());
|
||||
NoticeModel noticeModel = NoticeModel.builder()
|
||||
.operator(project.getCreateUser())
|
||||
.context(context)
|
||||
.testId(scheduleId)
|
||||
.subject(Translator.get("swagger_url_scheduled_import_notification"))
|
||||
.paramMap(paramMap)
|
||||
.event(NoticeConstants.Event.IMPORT)
|
||||
.build();
|
||||
noticeSendService.send(NoticeConstants.TaskType.SWAGGER_TASK, noticeModel);
|
||||
}
|
||||
}
|
||||
try {
|
||||
importApi(request, apiImport);
|
||||
|
@ -1621,12 +1608,32 @@ public class ApiDefinitionService {
|
|||
noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.sendFailMessage(request, project);
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(Translator.get("user_import_format_wrong"));
|
||||
}
|
||||
return apiImport;
|
||||
}
|
||||
|
||||
private void sendFailMessage(ApiTestImportRequest request, Project project) {
|
||||
if (StringUtils.equals(request.getType(), "schedule")) {
|
||||
String scheduleId = scheduleService.getScheduleInfo(request.getResourceId());
|
||||
String context = request.getSwaggerUrl() + "导入失败";
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("url", request.getSwaggerUrl());
|
||||
paramMap.put("projectId", request.getProjectId());
|
||||
NoticeModel noticeModel = NoticeModel.builder()
|
||||
.operator(project.getCreateUser())
|
||||
.context(context)
|
||||
.testId(scheduleId)
|
||||
.subject(Translator.get("swagger_url_scheduled_import_notification"))
|
||||
.paramMap(paramMap)
|
||||
.event(NoticeConstants.Event.EXECUTE_FAILED)
|
||||
.build();
|
||||
noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkFileSuffixName(ApiTestImportRequest request, String suffixName) {
|
||||
if (suffixName.equalsIgnoreCase("jmx")) {
|
||||
if (!request.getPlatform().equalsIgnoreCase("JMeter")) {
|
||||
|
|
|
@ -84,19 +84,20 @@ export default {
|
|||
initForm() {
|
||||
this.result = this.$get('/notice/search/message/' + this.apiTestId, response => {
|
||||
this.scheduleTask = response.data;
|
||||
this.scheduleTask.testId = this.apiTestId;
|
||||
});
|
||||
},
|
||||
handleAddTaskModel() {
|
||||
let Task = {};
|
||||
Task.event = [];
|
||||
Task.userIds = [];
|
||||
Task.type = '';
|
||||
Task.webhook = '';
|
||||
Task.isSet = true;
|
||||
Task.identification = '';
|
||||
Task.taskType = 'SWAGGER_URL';
|
||||
Task.testId = this.testId;
|
||||
this.scheduleTask.unshift(Task);
|
||||
let task = {};
|
||||
task.event = [];
|
||||
task.userIds = [];
|
||||
task.type = '';
|
||||
task.webhook = '';
|
||||
task.isSet = true;
|
||||
task.identification = '';
|
||||
task.taskType = 'SWAGGER_URL';
|
||||
task.testId = this.apiTestId;
|
||||
this.scheduleTask.unshift(task);
|
||||
},
|
||||
handleTemplate(index, row) {
|
||||
if (hasLicense()) {
|
||||
|
@ -117,11 +118,6 @@ export default {
|
|||
handleReceivers(row) {
|
||||
row.receiverOptions = JSON.parse(JSON.stringify(this.scheduleReceiverOptions));
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
testId() {
|
||||
this.initForm();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue