package com.xjrsoft.module.oa.service.impl;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.xjrsoft.common.utils.LocalDateTimeUtil;
import com.xjrsoft.module.oa.dto.ChangeNewsDto;
import com.xjrsoft.module.oa.service.INewsService;
import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
import com.xjrsoft.module.organization.service.IWeChatService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * @description：TODO
 * @author： phoenix
 * @create： 2024/1/18 10:11
 * @Version 1.0
 */
@SpringBootTest
class NewsServiceImplTest {

    @Autowired
    private INewsService newsService;


    @Autowired
    private IWeChatService weChatService;

    @Test
    void changeStatus() {
        newsService.changeStatus(new ChangeNewsDto(){{
            setId(1747799025202032641L);
            setStatus(2);
        }});
    }

    @Test
    void dataHandle() {
        newsService.dataHandle(1747971884062928896L);
    }

    @Test
    void sendMessage() {
        WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
        weChatSendMessageDto.setUserId("o8d_c6cbhCMpgNmXNe3yXZlADgNM");
        weChatSendMessageDto.setTemplateId("qmpXORPM1Cocqn503Qa4On6BJhR92UZ00eod2-6IcGo");
        weChatSendMessageDto.setUrl(StrUtil.format("{}/pages/message/notice/detail?id={}", "https://zhxy.cqtlzjzx.com/app/#", 1828978101761650689L));
        weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextIdStr());
        JSONObject data = new JSONObject();

        JSONObject data1 = new JSONObject();
        data1.put("value", "关于调整2024年秋季学期开学及召开教");
        data.put("thing23", data1);

        JSONObject data2 = new JSONObject();
        data2.put("value", "重庆铜梁职业教育中心");
        data.put("thing29", data2);

        JSONObject data3 = new JSONObject();
        data3.put("value", "2024-08-29 10:09:34");
        data.put("time17", data3);
        weChatSendMessageDto.setContent(data);
        weChatService.sendTemplateMessage(weChatSendMessageDto);
    }
}