package com.yiqi.crm.handle;


import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @desc 图片处理器
 */
@Component
public class ImgHandler extends AbstractHandler {

    @Override
    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> map, WxMpService wxMpService,
                                    WxSessionManager wxSessionManager) throws WxErrorException {
        // msgType 消息类型
        String msgType = wxMessage.getMsgType();
        // content 消息内容
        String content = wxMessage.getContent();
        if (msgType.equals(WxConsts.XmlMsgType.IMAGE)) {
            //TODO: 如果需要做微信消息日志存储，可以在这里进行日志存储到数据库，这里省略不写。
        }
        // 获取微信用户基本信息
//        WxMpUser userWxInfo = wxMpService.getUserService().userInfo(wxMessage.getFromUser(), "zh_CN");
//        if (null != userWxInfo) {
//        new ImageBuilder().build(content, wxMessage, wxMpService);
        return WxMpXmlOutMessage
                .IMAGE()
                .mediaId("https://myy-1252734862.cos.ap-shanghai.myqcloud.com/image/2023-07/thumb/78d3e607fb2b4100905ed94dac2d1018.jpg")
                .fromUser(wxMessage.getToUser())
                .toUser(wxMessage.getFromUser())
                .build();

    }



}

