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

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

/**
 * @author reghao
 * @date 2025-10-13 15:31:48
 */
@Getter
public class DingTestMsg {
    private String sendTime;
    private String sendBy;

    public DingTestMsg() {
        this.sendTime = DateTimeConverter.format(System.currentTimeMillis());
        this.sendBy = UserContext.getUser().getUsername();
    }

    public DingMsg dingMsg() {
        String title = "ding 测试通知";

        StringBuilder sb = new StringBuilder();
        sb.append("# 钉钉 webhook 测试").append(System.lineSeparator());
        sb.append("### 发送时间: ").append(sendTime).append(System.lineSeparator());
        sb.append("### 测试用户: ").append(sendBy);
        String text = sb.toString();
        return new DingMsg(title, text);
    }
}
