package com.njcn.msgpush.module.push.sms;

import com.njcn.msgpush.module.push.constant.MsgPushConstant;
import com.njcn.msgpush.module.push.controller.admin.message.vo.MessageRecordReqVO;
import com.njcn.msgpush.module.push.service.message.MessageRecordService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @author caozehui
 * @data 2026-02-06
 */
@Slf4j
@SpringBootTest
@EnableScheduling
public class MsgPushClientTest {

    @Autowired
    private MessageRecordService messageRecordService;

    @Test
    public void testSend() throws InterruptedException {
        List<MessageRecordReqVO> messageIdList = new ArrayList<>();
//        for (int i = 0; i < 5; i++) {
//            MessageRecordReqVO message = new MessageRecordReqVO();
//            message.setMessageId(i + "c518e2a3c");
//            message.setAppName("NPQS-9500");
//            message.setChannel(MsgPushConstant.CHANNEL_SMS);
//            message.setTitle("灿能云");
//            message.setReceiver("18839431215");
//            message.setTemplateCode("SMS_481710295");
//            message.setTemplateParams("{\"code\":\"65432" + i + "\"}");
//            message.setProviderType(MsgPushConstant.PROVIDER_TYPE_ALI_YUN);
//            messageIdList.add(message);
//        }
        for (int i = 0; i < 1; i++) {
            MessageRecordReqVO message = new MessageRecordReqVO();
            message.setMessageId(String.valueOf(UUID.randomUUID()));
            message.setAppName("NPQS-9000");
            message.setChannel(MsgPushConstant.CHANNEL_SMS);
            message.setReceiver("18839431215");
            message.setContent("【南京灿能电力】测试短信" + i + "，请忽略。" + LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            message.setProviderType(MsgPushConstant.PROVIDER_TYPE_TELECOM);
            messageIdList.add(message);
        }
        boolean sendResult = messageRecordService.send(messageIdList);

        Thread.sleep(9000);
        System.out.println(sendResult);
    }
}
