| | |
| | | package com.hx.util.corp; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.hx.exception.TipsException; |
| | | import com.hx.util.HttpMethodUtil; |
| | | import com.hx.util.StringUtils; |
| | | import com.hx.util.corp.entity.AppLetInfo; |
| | | import com.hx.util.corp.entity.OpenIdAUserId; |
| | | import com.hx.util.corp.entity.WeiXinInfo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | private static Logger logger = LoggerFactory.getLogger(CorpMpUtil.class.getName()); |
| | | |
| | | /**链接-获取应用accessToken*/ |
| | | public static final String URL_GET_USER_INFO= "https://qyapi.weixin.qq.com/cgi-bin/user/get"; |
| | | public static final String URL_GET_USER_INFO = "https://qyapi.weixin.qq.com/cgi-bin/user/get"; |
| | | |
| | | /**openid转userid*/ |
| | | public static final String URL_OPENID_TO_USERID = "https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_userid"; |
| | | |
| | | /**userid转openid*/ |
| | | public static final String URL_USERID_TO_OPENID = "https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_openid"; |
| | | |
| | | /**获取小程序链接*/ |
| | | public static final String URL_LINK = "https://api.weixin.qq.com/wxa/generate_urllink"; |
| | | |
| | | |
| | | /** |
| | | * openId获取userId |
| | | * @param openId 用户openId |
| | | * @return 返回 |
| | | */ |
| | | public static OpenIdAUserId openIdToUserId(String openId, String token) { |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("access_token",token); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("openid",openId); |
| | | |
| | | String datas = HttpMethodUtil.HttpURLUtilJson(URL_OPENID_TO_USERID, data.toString(), map, null, "GET"); |
| | | OpenIdAUserId openIdAUserId = JSONObject.parseObject(datas, OpenIdAUserId.class); |
| | | return openIdAUserId; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * userId获取openId |
| | | * @param userid 企业员工id |
| | | * @return 返回 |
| | | */ |
| | | public static OpenIdAUserId userIdToOpenId(String userid, String token) { |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("access_token",token); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("userid",userid); |
| | | |
| | | String datas = HttpMethodUtil.HttpURLUtilJson(URL_USERID_TO_OPENID, data.toString(), map, null, "GET"); |
| | | OpenIdAUserId openIdAUserId = JSONObject.parseObject(datas, OpenIdAUserId.class); |
| | | return openIdAUserId; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取企业微信员工信息 |
| | |
| | | return weiXinInfo; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | } |