guang
2023-07-28 55697aaa2e4974d5b443e731581e4c50609946b7
src/main/java/com/hx/mp/util/CorpMpUtil.java
@@ -1,13 +1,12 @@
package com.hx.mp.util;
import com.hx.corp.entity.AppLetInfo;
import com.hx.util.corp.entity.AppLetInfo;
import com.hx.exception.TipsException;
import com.hx.util.HttpMethodUtil;
import com.hx.util.StringUtils;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.apache.commons.io.IOUtils;
import org.apache.poi.util.SystemOutLogger;
import java.io.OutputStream;
import java.net.HttpURLConnection;
@@ -43,8 +42,7 @@
    public static final String URL_INFO_USER = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={0}&userid={1}";
    /**发送消息*/
    public static final String URL_MESSAGE_SEND = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=";
    /*生成小程序链接*/
    public static final String URL_LINK = "https://api.weixin.qq.com/wxa/generate_urllink";
    /**
     * 添加工作人员
@@ -346,25 +344,4 @@
        return obj;
    }
    /**
     * 生成小程序链接
     * @param path 通过 URL Link 进入的小程序页面路径,必须是已经发布的小程序存在的页面,不可携带 query 。path 为空时会跳转小程序主页
     * @param token 接口调用凭证,该参数为 URL 参数,非 Body 参数。使用getAccessToken 或者
     * @param env_version 默认值"release"。要打开的小程序版本。正式版为 "release",体验版为"trial",开发版为"develop",仅在微信外打开时生效。
     * @param query 通过 URL Link 进入小程序时的query,最大1024个字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~%
     * @return appLetInfo
     */
    public static AppLetInfo getAppLetUrl(String path, String token, String env_version, String query) {
        Map<String, Object> map = new HashMap();
        map.put("access_token", token);
        com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject();
        data.put("path", path);
        data.put("env_version", env_version);
        if (!StringUtils.isEmpty(query)){
            data.put("query", query);
        }
        String datas = HttpMethodUtil.HttpURLUtilJson(URL_LINK, data.toString(), map, (Map)null, "POST");
        AppLetInfo appLetInfo = com.alibaba.fastjson.JSONObject.parseObject(datas, AppLetInfo.class);
        return appLetInfo;
    }
}