mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-02 20:02:37 +08:00
🆕 #2752 【小程序】增加查询小程序版本信息的接口以及第三方userid_to_openuserid的接口
This commit is contained in:
parent
1747190674
commit
d056cc8abe
@ -3,8 +3,10 @@ package me.chanjar.weixin.cp.api;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpInviteResult;
|
||||
import me.chanjar.weixin.cp.bean.WxCpUser;
|
||||
import me.chanjar.weixin.cp.bean.WxCpUseridToOpenUseridResult;
|
||||
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -217,4 +219,14 @@ public interface WxCpUserService {
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
Integer getActiveStat(Date date) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* userid转换为open_userid
|
||||
* 将自建应用或代开发应用获取的userid转换为第三方应用的userid
|
||||
* https://developer.work.weixin.qq.com/document/path/95603
|
||||
* @param useridList
|
||||
* @return the WxCpUseridToOpenUseridResult
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList<String> useridList) throws WxErrorException;
|
||||
}
|
||||
|
@ -12,11 +12,14 @@ import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.api.WxCpUserService;
|
||||
import me.chanjar.weixin.cp.bean.WxCpInviteResult;
|
||||
import me.chanjar.weixin.cp.bean.WxCpUser;
|
||||
import me.chanjar.weixin.cp.bean.WxCpUseridToOpenUseridResult;
|
||||
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
|
||||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
import org.apache.commons.lang3.time.FastDateFormat;
|
||||
|
||||
import java.text.Format;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -223,4 +226,18 @@ public class WxCpUserServiceImpl implements WxCpUserService {
|
||||
JsonObject tmpJson = GsonParser.parse(responseContent);
|
||||
return tmpJson.get("active_cnt").getAsInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList<String> useridList) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
for(String userid:useridList){
|
||||
jsonArray.add(userid);
|
||||
}
|
||||
jsonObject.add("userid_list", jsonArray);
|
||||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(USERID_TO_OPEN_USERID);
|
||||
String responseContent = this.mainService.post(url, jsonObject.toString());
|
||||
return WxCpUseridToOpenUseridResult.fromJson(responseContent);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
package me.chanjar.weixin.cp.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* userid转换为open_userid
|
||||
* 将自建应用或代开发应用获取的userid转换为第三方应用的userid
|
||||
* 中间对象
|
||||
* Created by gxh0797 on 2022.07.26.
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class WxCpUseridToOpenUserid implements Serializable {
|
||||
private static final long serialVersionUID = 1420065684270213578L;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static WxCpUseridToOpenUserid fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpUseridToOpenUserid.class);
|
||||
}
|
||||
|
||||
@SerializedName("userid")
|
||||
private String userid;
|
||||
|
||||
@SerializedName("open_userid")
|
||||
private String openUserid;
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package me.chanjar.weixin.cp.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* userid转换为open_userid
|
||||
* 将自建应用或代开发应用获取的userid转换为第三方应用的userid
|
||||
* Created by gxh0797 on 2022.07.26.
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class WxCpUseridToOpenUseridResult implements Serializable {
|
||||
private static final long serialVersionUID = 1420065684270213578L;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static WxCpUseridToOpenUseridResult fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpUseridToOpenUseridResult.class);
|
||||
}
|
||||
|
||||
@SerializedName("errcode")
|
||||
private Integer errCode;
|
||||
|
||||
@SerializedName("errmsg")
|
||||
private String errMsg;
|
||||
|
||||
@SerializedName("open_userid_list")
|
||||
private List<WxCpUseridToOpenUserid> openUseridList;
|
||||
|
||||
@SerializedName("invalid_userid_list")
|
||||
private List<String> invalidUseridList;
|
||||
|
||||
|
||||
}
|
@ -324,6 +324,7 @@ public interface WxCpApiPathConsts {
|
||||
String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid=";
|
||||
String GET_JOIN_QR_CODE = "/cgi-bin/corp/get_join_qrcode?size_type=";
|
||||
String GET_ACTIVE_STAT = "/cgi-bin/user/get_active_stat";
|
||||
String USERID_TO_OPEN_USERID = "/cgi-bin/batch/userid_to_openuserid";
|
||||
}
|
||||
|
||||
interface ExternalContact {
|
||||
|
@ -251,6 +251,11 @@ public interface WxOpenMaService extends WxMaService {
|
||||
*/
|
||||
String API_WX_AMP_LINK_UN = "https://api.weixin.qq.com/cgi-bin/wxopen/wxampunlink";
|
||||
|
||||
/**
|
||||
* 小程序管理-查询小程序版本信息
|
||||
*/
|
||||
String API_GET_VERSION_INFO = "https://api.weixin.qq.com/wxa/getversioninfo";
|
||||
|
||||
/**
|
||||
* 获得小程序的域名配置信息
|
||||
*
|
||||
@ -702,4 +707,12 @@ public interface WxOpenMaService extends WxMaService {
|
||||
*/
|
||||
WxOpenResult wxAmpUnLink(String appid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 查询小程序版本信息
|
||||
*
|
||||
* @return the wx open result
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
WxOpenResult getVersionInfo() throws WxErrorException;
|
||||
|
||||
}
|
||||
|
@ -439,4 +439,12 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOpenResult getVersionInfo() throws WxErrorException {
|
||||
JsonObject params = new JsonObject();
|
||||
String response = post(API_GET_VERSION_INFO, GSON.toJson(params));
|
||||
WxOpenResult result = WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user