package com.yx.face.boot.component.wx;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @description: MyWxMpService <br>
 * @date: 2021/4/29 13:09 <br>
 * @author: PWB <br>
 */
@Slf4j
@Component
public class MyWxMpService {
    @Value("${weixin.appid}")
    private String appid;
    public void sendMsg(WxMaSubscribeMessage subscribeMessage) {
        final WxMaService wxService = WxMaConfiguration.getMaService(appid);
        try {
            wxService.getMsgService().sendSubscribeMsg(subscribeMessage);
        } catch (WxErrorException e) {
            log.info(e.getMessage());
        }
    }


}
