package co.yixiang.yshop.module.mp.framework.cp.config;

import lombok.SneakyThrows;
import me.chanjar.weixin.cp.api.WxCpMessageService;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;

/**
 * @author pepis
 * @apiNote
 **/
public class WxCpTest {
    @SneakyThrows
    public static void main(String[] args) {
        WxCpDefaultConfigImpl config = new WxCpDefaultConfigImpl();
        config.setCorpId("wwf6e740daf74076e3");      // 设置微信企业号的appid
        config.setCorpSecret("EjFXqvCeJ9ihLo2PLlOsX0pY4XVbV1qDbQY_5V5vpag");  // 设置微信企业号的app corpSecret
        config.setAgentId(1000002);     // 设置微信企业号应用ID
        config.setToken("ELV");       // 设置微信企业号应用的token
        config.setAesKey("G8rwnJtzSqs6me8ssHofuJ7tFgngWeFTnMXAHD4OEoi");      // 设置微信企业号应用的EncodingAESKey

        WxCpServiceImpl wxCpService = new WxCpServiceImpl();
        wxCpService.setWxCpConfigStorage(config);

        String userId = "TianYong";
        WxCpMessage message = WxCpMessage.TEXT().agentId(1000002).toUser(userId).content("Hello World").build();
        WxCpMessageService messageService = wxCpService.getMessageService();
        messageService.send(message);
    }
}
