Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: alert template #795

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ public boolean sendAlertNotifyV3(AlertNotifyRequest notify, AlertNotifyRecordLat
notify.setAlertRuleExtra(extra);
NotificationTemplate notificationTemplate = extra == null ? null : extra.getDingTalkTemplate();
if (notificationTemplate == null) {
Long alertNotificationTemplateId = alertRule.getAlertNotificationTemplateId();
if (alertNotificationTemplateId != null) {
String alertRuleAlertTemplateUuid = alertRule.getAlertTemplateUuid();
if (StringUtils.isNotEmpty(alertRuleAlertTemplateUuid)) {
AlertTemplate alertTemplate =
this.alertTemplateMapper.selectById(alertNotificationTemplateId);
this.alertTemplateMapper.selectById(alertRuleAlertTemplateUuid);
if (alertTemplate != null) {
AlertTemplateDTO templateDTO = this.alertTemplateConverter.doToDTO(alertTemplate);
notificationTemplate = templateDTO.templateConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public void doManage() {
if (StringUtils.isNotBlank(pageRequest.getTarget().templateName)) {
queryWrapper.like("template_name", pageRequest.getTarget().templateName);
}
queryWrapper.orderByDesc("gmt_modified");

Page<AlertTemplate> p = alertTemplateMapper.selectPage(page, queryWrapper);
MonitorPageResult<AlertTemplateDTO> pageResult = new MonitorPageResult<>();
Expand Down Expand Up @@ -286,8 +287,8 @@ public void doManage() {
@PostMapping("/check")
@ResponseBody
@MonitorScopeAuth(targetType = AuthTargetType.TENANT, needPower = PowerConstants.EDIT)
public JsonResult<Boolean> checkTemplateText(@RequestBody AlertTemplateDTO templateDTO) {
final JsonResult<Boolean> result = new JsonResult<>();
public JsonResult<AlertTemplateDTO> checkTemplateText(@RequestBody AlertTemplateDTO templateDTO) {
final JsonResult<AlertTemplateDTO> result = new JsonResult<>();

facadeTemplate.manage(result, new ManageCallback() {
@Override
Expand All @@ -297,12 +298,19 @@ public void checkParameter() {

@Override
public void doManage() {
if (templateDTO.templateConfig == null
|| StringUtils.isEmpty(templateDTO.templateConfig.text)) {
JsonResult.createSuccessResult(result, false);
NotificationTemplate template = templateDTO.getTemplateConfig();
if (template == null) {
result.setMessage("templateConfig is null");
return;
}
JsonResult.createSuccessResult(result, templateDTO.templateConfig.parseText());

if (StringUtils.isNotEmpty(template.text)) {
result.setSuccess(template.parseText());
} else if (!CollectionUtils.isEmpty(template.fieldMap)) {
template.text = template.getTemplateJson();
result.setSuccess(true);
}
result.setData(templateDTO);
}
});

Expand Down
Loading