-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ospp] support custom notice template (#1233)
Signed-off-by: Eden4701 <Eden4701@163.com> Co-authored-by: ulikehhh <2762242004@qq.com>
- Loading branch information
Showing
63 changed files
with
1,984 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,4 +90,4 @@ private Message(byte code, String msg) { | |
private Message(T data) { | ||
this.data = data; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
common/src/main/java/org/dromara/hertzbeat/common/entity/manager/NoticeTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dromara.hertzbeat.common.entity.manager; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.validator.constraints.Length; | ||
import org.springframework.data.annotation.CreatedBy; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedBy; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import javax.persistence.*; | ||
import javax.validation.constraints.Min; | ||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import java.time.LocalDateTime; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY; | ||
import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_WRITE; | ||
|
||
/** | ||
* Notification strategy entity | ||
* 通知策略 | ||
* | ||
* @author eden4701 | ||
*/ | ||
@Entity | ||
@Table(name = "hzb_notice_template") | ||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Schema(description = "Notify Policy Template | 通知模板实体") | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class NoticeTemplate { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Schema(title = "Notification Template Entity Primary Key Index ID", | ||
description = "通知模板实体主键索引ID", | ||
example = "87584674384", accessMode = READ_ONLY) | ||
private Long id; | ||
|
||
@Schema(title = "Template name", | ||
description = "模板名称", | ||
example = "dispatch-1", accessMode = READ_WRITE) | ||
@Length(max = 100) | ||
@NotBlank | ||
private String name; | ||
|
||
@Schema(title = "Notification information method: 0-SMS 1-Email 2-webhook 3-WeChat Official Account 4-Enterprise WeChat Robot 5-DingTalk Robot 6-FeiShu Robot 7-Telegram Bot 8-SlackWebHook 9-Discord Bot 10-Enterprise WeChat app message", | ||
description = "通知信息方式: 0-手机短信 1-邮箱 2-webhook 3-微信公众号 4-企业微信机器人 5-钉钉机器人 6-飞书机器人 7-Telegram机器人 8-SlackWebHook 9-Discord机器人 10-企业微信-应用消息", | ||
accessMode = READ_WRITE) | ||
@Min(0) | ||
@NotNull | ||
private Byte type; | ||
|
||
@Schema(title = "Is it a preset template: true- preset template false- custom template.", | ||
description = "是否为预设模板: true-预设模板 false-自定义模板", | ||
accessMode = READ_WRITE) | ||
@NotNull | ||
private Boolean presetTemplate; | ||
|
||
|
||
@Schema(title = "Template content", | ||
description = "模板内容", | ||
example = "[${title}]\n" + | ||
"${targetLabel} : ${target}\n" + | ||
"<#if (monitorId??)>${monitorIdLabel} : ${monitorId} </#if>\n" + | ||
"<#if (monitorName??)>${monitorNameLabel} : ${monitorName} </#if>\n" + | ||
"${priorityLabel} : ${priority}\n" + | ||
"${triggerTimeLabel} : ${triggerTime}\n" + | ||
"${contentLabel} : ${content}", accessMode = READ_WRITE) | ||
@Length(max = 100000) | ||
@NotBlank | ||
@Column(name = "template_content", columnDefinition = "MEDIUMTEXT") | ||
private String templateContent; | ||
|
||
@Schema(title = "The creator of this record", description = "此条记录创建者", example = "tom", accessMode = READ_ONLY) | ||
@CreatedBy | ||
private String creator; | ||
|
||
@Schema(title = "This record was last modified by", | ||
description = "此条记录最新修改者", | ||
example = "tom", accessMode = READ_ONLY) | ||
@LastModifiedBy | ||
private String modifier; | ||
|
||
@Schema(title = "This record creation time (millisecond timestamp)", | ||
description = "记录创建时间", accessMode = READ_ONLY) | ||
@CreatedDate | ||
private LocalDateTime gmtCreate; | ||
|
||
@Schema(title = "Record the latest modification time (timestamp in milliseconds)", | ||
description = "记录最新修改时间", accessMode = READ_ONLY) | ||
@LastModifiedDate | ||
private LocalDateTime gmtUpdate; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.