package cn.axzo.msg.center.utils;

import cn.axzo.riven.client.common.enums.DingTalkMsgTypeEnum;
import cn.axzo.riven.client.feign.DingDingMsgApi;
import cn.axzo.riven.client.model.SampleMarkdown;
import cn.axzo.riven.client.req.DingDingSendRebootGroupMsgReq;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author yanglin
 */
@Component
@RequiredArgsConstructor
public class DingTalkService {

    private final DingDingMsgApi dingDingMsgApi;

    public void send(String title, String markdown) {
        DingDingSendRebootGroupMsgReq req = new DingDingSendRebootGroupMsgReq();
        //消息类型
        req.setMsgType(DingTalkMsgTypeEnum.sampleMarkdown);
        req.setDingDingJson(new SampleMarkdown(title, markdown).toJson());
        //与nacos配置保持一致
        req.setDingDingScene("TODO_WARN");
        dingDingMsgApi.sendRebootGroupMsg(req);
    }

}
