|
|
@ -0,0 +1,61 @@ |
|
|
|
package com.iflytop.gd.common.notification; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
import lombok.Getter; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 向前台推送的消息类 |
|
|
|
*/ |
|
|
|
|
|
|
|
@Getter |
|
|
|
public class Notification { |
|
|
|
private final String level; |
|
|
|
private final String content; |
|
|
|
private final String dateTime = DateTime.now().toString("yyyy/MM/dd HH:mm:ss"); |
|
|
|
|
|
|
|
private Notification(String level, String content) { |
|
|
|
this.level = level; |
|
|
|
this.content = content; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 创建Info级别通知 |
|
|
|
* @param content 通知内容 |
|
|
|
* @return 通知实例 |
|
|
|
*/ |
|
|
|
public static Notification infoNotification(String content) { |
|
|
|
return new Notification("info", content); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 创建Warn级别通知 |
|
|
|
* @param content 通知内容 |
|
|
|
* @return 通知实例 |
|
|
|
*/ |
|
|
|
public static Notification warnNotification(String content) { |
|
|
|
return new Notification("warn", content); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 创建Error级别通知 |
|
|
|
* @param content 通知内容 |
|
|
|
* @return 通知实例 |
|
|
|
*/ |
|
|
|
public static Notification errorNotification(String content) { |
|
|
|
return new Notification("error", content); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 创建Fatal级别通知 |
|
|
|
* @param content 通知内容 |
|
|
|
* @return 通知实例 |
|
|
|
*/ |
|
|
|
public static Notification fatalNotification(String content) { |
|
|
|
return new Notification("fatal", content); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |