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

【企业微信】 批量获取审批单号接口增加新的分页字段new_cursor和new_next_cursor支持,并将旧的方法标注@Deprecated #3187

Merged
merged 2 commits into from
Dec 15, 2023
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 @@ -93,6 +93,7 @@ List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime
* @return WxCpApprovalInfo approval info
* @throws WxErrorException .
*/
@Deprecated
WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, Integer cursor, Integer size,
List<WxCpApprovalInfoQueryFilter> filters) throws WxErrorException;

Expand All @@ -106,9 +107,39 @@ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime,
* @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo me.chanjar.weixin.cp.api
* .WxCpOaService#getApprovalInfome.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo
*/
@Deprecated
WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException;


/**
* <pre>
*
* 批量获取审批单号
*
* 审批应用及有权限的自建应用,可通过Secret调用本接口,以获取企业一段时间内企业微信“审批应用”单据的审批编号,支持按模板类型、申请人、部门、申请单审批状态等条件筛选。
* 自建应用调用此接口,需在“管理后台-应用管理-审批-API-审批数据权限”中,授权应用允许提交审批单据。
*
* 一次拉取调用最多拉取100个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。
*
* API doc : https://work.weixin.qq.com/api/doc/90000/90135/91816
*
* 1 接口频率限制 600次/分钟
* 2 请求的参数endtime需要大于startime, 起始时间跨度不能超过31天;
* 3 老的分页游标字段cursor和next_cursor待废弃,请开发者使用新字段new_cursor和new_next_cursor。
* </pre>
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param newCursor 分页查询游标,默认为0,后续使用返回的next_cursor进行分页拉取
binarywang marked this conversation as resolved.
Show resolved Hide resolved
* @param size 一次请求拉取审批单数量,默认值为100,上限值为100
* @param filters 筛选条件,可对批量拉取的审批申请设置约束条件,支持设置多个条件,nullable
* @return WxCpApprovalInfo approval info
* @throws WxErrorException .
*/
WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, String newCursor, Integer size,
List<WxCpApprovalInfoQueryFilter> filters) throws WxErrorException;


/**
* <pre>
* 获取审批申请详情
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,43 @@ public WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date e

@Override
public WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException {
return this.getApprovalInfo(startTime, endTime, null, null, null);
return this.getApprovalInfo(startTime, endTime, 0, null, null);
binarywang marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, String newCursor,
Integer size, List<WxCpApprovalInfoQueryFilter> filters)
throws WxErrorException {
if (newCursor == null) {
newCursor = "";
}

if (size == null) {
size = 100;
}

if (size < 0 || size > 100) {
throw new IllegalArgumentException("size参数错误,请使用[1-100]填充,默认100");
}

JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("starttime", startTime.getTime() / 1000L);
jsonObject.addProperty("endtime", endTime.getTime() / 1000L);
jsonObject.addProperty("size", size);
jsonObject.addProperty("new_cursor", newCursor);

if (filters != null && !filters.isEmpty()) {
JsonArray filterJsonArray = new JsonArray();
for (WxCpApprovalInfoQueryFilter filter : filters) {
filterJsonArray.add(new JsonParser().parse(filter.toJson()));
}
jsonObject.add("filters", filterJsonArray);
}

final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_INFO);
String responseContent = this.mainService.post(url, jsonObject.toString());

return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalInfo.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public class WxCpApprovalInfo implements Serializable {
@SerializedName("next_cursor")
private Integer nextCursor;

@SerializedName("new_next_cursor")
private String newNextCursor;
}