Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

查询小程序版本信息 #2752 #2757

Merged
merged 2 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
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;
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
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;
Expand Down Expand Up @@ -223,4 +226,18 @@ public Integer getActiveStat(Date date) throws WxErrorException {
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);
}

}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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;


}
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ interface User {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
* 获得小程序的域名配置信息
*
Expand Down Expand Up @@ -702,4 +707,12 @@ WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, Li
*/
WxOpenResult wxAmpUnLink(String appid) throws WxErrorException;

/**
* 查询小程序版本信息
*
* @return the wx open result
* @throws WxErrorException the wx error exception
*/
WxOpenResult getVersionInfo() throws WxErrorException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,12 @@ private JsonArray toJsonArray(List<String> strList) {
}
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;
}
}