package com.ylx.massage.utils;

import com.alibaba.fastjson.JSONObject;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.BufferedInputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName WxQrCodeUtil  //类名称
 * @Description:  微信分享二维码
 * @Author: 22168
 * @CreateDate: 2023/12/31 1:08	//创建时间
 * @Version: 1.0    //版本号
 */
@Component
public class WxQrCodeUtil {
    @Resource
    private WxUtil wxUtil;
//    @Resource
//    private FileUtil fileUtil;
    public String getWxQrcode(String cOpenId){
        Connection connect = Jsoup.connect("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + wxUtil.getAccessTokenStr());
        // 构建参数
        Map<String, String> data = new HashMap<>();
        data.put("scene",cOpenId);
        connect.requestBody(JSONObject.toJSONString(data));
        connect.ignoreContentType(true);
        connect.method(Connection.Method.POST);
        try {
            BufferedInputStream bufferedInputStream = connect.execute().bodyStream();
           return null; //fileUtil.uploadFileAndGetUrl(bufferedInputStream, UUIDUtil.getUUID());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}
