Skip to content

Commit 474f4fd

Browse files
authored
🎨 修复企业微信人事助手 getEmployeeFieldInfo 接口 userid 参数类型错误
1 parent e2120d6 commit 474f4fd

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpHrService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public interface WxCpHrService {
3737
* 权限说明:
3838
* 需要配置人事助手的secret,调用接口前需给对应成员赋予人事小助手应用的权限。
3939
*
40-
* @param userids 员工userid列表,不超过20个
41-
* @param fields 指定字段key列表,不填则返回全部字段
40+
* @param userid 员工userid
41+
* @param fields 指定字段key列表,不填则返回全部字段
4242
* @return 员工档案数据响应 wx cp hr employee field data resp
4343
* @throws WxErrorException the wx error exception
4444
*/
45-
WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(List<String> userids, List<String> fields) throws WxErrorException;
45+
WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(String userid, List<String> fields) throws WxErrorException;
4646

4747
/**
4848
* 更新员工档案数据.

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpHrServiceImpl.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,12 @@ public WxCpHrEmployeeFieldInfoResp getFieldInfo(List<String> fields) throws WxEr
3939
}
4040

4141
@Override
42-
public WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(List<String> userids, List<String> fields) throws WxErrorException {
43-
if (userids == null || userids.isEmpty()) {
42+
public WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(String userid, List<String> fields) throws WxErrorException {
43+
if (userid == null || userid.trim().isEmpty()) {
4444
throw new IllegalArgumentException("userid 不能为空");
4545
}
46-
if (userids.size() > 20) {
47-
throw new IllegalArgumentException("userid 每次最多传入20个");
48-
}
4946
JsonObject jsonObject = new JsonObject();
50-
jsonObject.add("userid", WxCpGsonBuilder.create().toJsonTree(userids));
47+
jsonObject.addProperty("userid", userid);
5148
if (fields != null && !fields.isEmpty()) {
5249
jsonObject.add("fields", WxCpGsonBuilder.create().toJsonTree(fields));
5350
}

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpHrServiceImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void testGetFieldInfoWithFilter() throws WxErrorException {
7575
public void testGetEmployeeFieldInfo() throws WxErrorException {
7676
WxCpHrService hrService = this.wxCpService.getHrService();
7777
WxCpHrEmployeeFieldDataResp resp = hrService.getEmployeeFieldInfo(
78-
Collections.singletonList(this.configStorage.getUserId()), null);
78+
this.configStorage.getUserId(), null);
7979
assertThat(resp).isNotNull();
8080
assertThat(resp.getEmployeeFieldList()).isNotNull();
8181
log.info("获取员工档案数据: {}", resp);

0 commit comments

Comments
 (0)