1
0
mirror of synced 2025-12-21 08:30:11 +08:00

🎨 完善微信支付部分文档

This commit is contained in:
0katekate0
2022-08-10 15:52:23 +08:00
committed by GitHub
parent 05f0fa2ac3
commit 52471fce89
8 changed files with 155 additions and 23 deletions

View File

@@ -5,6 +5,7 @@ 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.bean.user.WxCpDeptUserResult;
import java.util.ArrayList;
import java.util.Date;
@@ -224,9 +225,25 @@ public interface WxCpUserService {
* 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;
/**
* 获取成员ID列表
* 获取企业成员的userid与对应的部门ID列表预计于2022年8月8号发布。若需要获取其他字段参见「适配建议」。
* <p>
* 请求方式POSTHTTPS
* 请求地址https://qyapi.weixin.qq.com/cgi-bin/user/list_id?access_token=ACCESS_TOKEN
*
* @param cursor
* @param limit
* @return
* @throws WxErrorException
*/
WxCpDeptUserResult getUserListId(String cursor, Integer limit) throws WxErrorException;
}

View File

@@ -14,7 +14,7 @@ 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.bean.user.WxCpDeptUserResult;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import org.apache.commons.lang3.time.FastDateFormat;
@@ -231,7 +231,7 @@ public class WxCpUserServiceImpl implements WxCpUserService {
public WxCpUseridToOpenUseridResult useridToOpenUserid(ArrayList<String> useridList) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
JsonArray jsonArray = new JsonArray();
for(String userid:useridList){
for (String userid : useridList) {
jsonArray.add(userid);
}
jsonObject.add("userid_list", jsonArray);
@@ -240,4 +240,19 @@ public class WxCpUserServiceImpl implements WxCpUserService {
return WxCpUseridToOpenUseridResult.fromJson(responseContent);
}
@Override
public WxCpDeptUserResult getUserListId(String cursor, Integer limit) throws WxErrorException {
String apiUrl = this.mainService.getWxCpConfigStorage().getApiUrl(USER_LIST_ID);
JsonObject jsonObject = new JsonObject();
if (cursor != null) {
jsonObject.addProperty("cursor", cursor);
}
if (limit != null) {
jsonObject.addProperty("limit", limit);
}
String responseContent = this.mainService.post(apiUrl, jsonObject.toString());
return WxCpDeptUserResult.fromJson(responseContent);
}
}

View File

@@ -0,0 +1,58 @@
package me.chanjar.weixin.cp.bean.user;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* 获取成员ID列表返回参数
*
* @author <a href="https://gitee.com/Wang_Wong/">Wang_Wong</a>
* @date 2022/08/09
*/
@Data
public class WxCpDeptUserResult extends WxCpBaseResp {
private static final long serialVersionUID = 1420065684270213578L;
@SerializedName("next_cursor")
private String nextCursor;
@SerializedName("dept_user")
private List<DeptUserList> deptUser;
@Getter
@Setter
public static class DeptUserList implements Serializable {
private static final long serialVersionUID = 1420065684270213578L;
@SerializedName("userid")
private String userId;
@SerializedName("department")
private Long department;
public static DeptUserList fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, DeptUserList.class);
}
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}
public static WxCpDeptUserResult fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpDeptUserResult.class);
}
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}

View File

@@ -325,6 +325,8 @@ public interface WxCpApiPathConsts {
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";
String USER_LIST_ID = "/cgi-bin/user/list_id";
}
interface ExternalContact {