package com.mortals.xhx.common.utils;

import com.alibaba.fastjson.JSON;
import com.mortals.framework.util.HttpUtil;
import com.mortals.xhx.busiz.req.ApiThirdPartyReq;
import com.mortals.xhx.common.code.MessageTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE;

/**
 * 短信发送任务
 *
 * @author: zxfei
 * @date: 2022/4/28 10:56
 * @description:
 **/
@Slf4j
@AllArgsConstructor
public class SendSmsTask implements Runnable {
    /**
     * 短信消息
     */
    private AlarmSmsSendEntity alarmSmsSendEntity;

    /**
     * 接口地址
     */
    private String sendUrl;

    @Override
    public void run() {
        // TODO: 2022/7/5 短信发送
        String resp = null;
        try {
            Map<String, String> header = new HashMap<>();
            header.put(HEADER_CONTENT_TYPE, "application/json");
            // resp = HttpUtil.doPost(sendUrl, header, JSON.toJSONString(deviceReqApiReq));

            //发送成功添加到响应队列，由线程批量更新

            SmsQueueManager.offerRespQueue(alarmSmsSendEntity);

            log.debug("resp:{}", resp);
        } catch (Exception e) {
            log.error("异常:", e);
        }
    }
}
