package cn.reghao.bnt.web.devops.app.model.vo.msg;

import cn.reghao.bnt.web.admin.service.notifier.ding.DingMsg;
import cn.reghao.jutil.jdk.converter.DateTimeConverter;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalDateTime;

/**
 * 应用部署通知消息
 *
 * @author reghao
 * @date 2020-06-24 10:32:34
 */
@AllArgsConstructor
@Getter
public class CdnRereshNotifyMsg {
    private String buildId;
    private String appId;
    private String domain;
    private LocalDateTime refreshTime;
    private String result;

    public DingMsg dingMsg() {
        String title = "CDN 刷新通知";
        StringBuilder sb = new StringBuilder();
        sb.append("# CDN 刷新").append(System.lineSeparator());
        sb.append("### 构建 ID: ").append(buildId).append(System.lineSeparator());
        sb.append("### 应用: ").append(appId).append(System.lineSeparator());
        sb.append("### 域名: ").append(domain).append(System.lineSeparator());
        sb.append("### 刷新时间: ").append(DateTimeConverter.format(refreshTime)).append(System.lineSeparator());
        sb.append("### 刷新结果: ").append(result);
        String text = sb.toString();
        return new DingMsg(title, text);
    }
}
