🎨 #3928 【企业微信】修复第三方应用获取部门成员接口使用错误token的问题
This commit is contained in:
@@ -53,9 +53,29 @@ public interface WxCpTpUserService {
|
||||
* @param departId 必填。部门id
|
||||
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
|
||||
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
|
||||
* @param corpId 企业id
|
||||
* @return the list
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status, String corpId)
|
||||
throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取部门成员.
|
||||
*
|
||||
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98
|
||||
* </pre>
|
||||
*
|
||||
* @param departId 必填。部门id
|
||||
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
|
||||
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
|
||||
* @return the list
|
||||
* @throws WxErrorException the wx error exception
|
||||
* @deprecated 第三方应用调用此接口需要使用 corpId 对应的 access_token,请使用
|
||||
* {@link #listSimpleByDepartment(Long, Boolean, Integer, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,6 +97,42 @@ public class WxCpTpUserServiceImpl implements WxCpTpUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status, String corpId)
|
||||
throws WxErrorException {
|
||||
StringBuilder params = new StringBuilder();
|
||||
if (fetchChild != null) {
|
||||
params.append("fetch_child=").append(fetchChild ? "1" : "0");
|
||||
}
|
||||
if (status != null) {
|
||||
if (params.length() > 0) {
|
||||
params.append('&');
|
||||
}
|
||||
params.append("status=").append(status);
|
||||
} else {
|
||||
if (params.length() > 0) {
|
||||
params.append('&');
|
||||
}
|
||||
params.append("status=0");
|
||||
}
|
||||
if (params.length() > 0) {
|
||||
params.append('&');
|
||||
}
|
||||
params.append("access_token=")
|
||||
.append(mainService.getWxCpTpConfigStorage().getAccessToken(corpId));
|
||||
|
||||
String url = mainService.getWxCpTpConfigStorage().getApiUrl(USER_SIMPLE_LIST + departId);
|
||||
String responseContent = this.mainService.get(url, params.toString(), true);
|
||||
JsonObject tmpJsonElement = GsonParser.parse(responseContent);
|
||||
return WxCpGsonBuilder.create()
|
||||
.fromJson(
|
||||
tmpJsonElement.getAsJsonObject().get("userlist"),
|
||||
new TypeToken<List<WxCpUser>>() {
|
||||
}.getType()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status)
|
||||
throws WxErrorException {
|
||||
String params = "";
|
||||
|
||||
Reference in New Issue
Block a user