mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-11-01 20:13:12 +08:00
🎨 完善微信支付部分文档
This commit is contained in:
@ -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>
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址: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;
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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 {
|
||||
|
||||
@ -72,6 +72,13 @@ public class WxCpDepartmentServiceImplTest {
|
||||
this.wxCpService.getDepartmentService().delete(this.depart.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子部门ID列表
|
||||
* https://developer.work.weixin.qq.com/document/path/95350
|
||||
*
|
||||
* @param id
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test(dataProvider = "departIds")
|
||||
public void testSimpleList(Long id) throws WxErrorException {
|
||||
System.out.println("=================获取子部门ID列表");
|
||||
|
||||
@ -1,23 +1,26 @@
|
||||
package me.chanjar.weixin.cp.api.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.Gender;
|
||||
import me.chanjar.weixin.cp.bean.WxCpInviteResult;
|
||||
import me.chanjar.weixin.cp.bean.WxCpUser;
|
||||
import me.chanjar.weixin.cp.bean.user.WxCpDeptUserResult;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.testng.Assert.assertNotEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
@ -26,6 +29,7 @@ import static org.testng.Assert.*;
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxCpUserServiceImplTest {
|
||||
@Inject
|
||||
@ -129,4 +133,20 @@ public class WxCpUserServiceImplTest {
|
||||
System.out.printf("active stat: %d", activeStat);
|
||||
assertNotNull(activeStat);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员ID列表
|
||||
* 获取企业成员的userid与对应的部门ID列表,预计于2022年8月8号发布。若需要获取其他字段,参见「适配建议」。
|
||||
* <p>
|
||||
* https://developer.work.weixin.qq.com/document/40856
|
||||
*
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test
|
||||
public void testGetUserListId() throws WxErrorException {
|
||||
WxCpDeptUserResult result = this.wxCpService.getUserService().getUserListId(null, 10);
|
||||
log.info("返回结果为:{}", result.toJson());
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user