1
0
mirror of synced 2026-03-24 05:28:47 +08:00

🎨 修复企业微信人事助手 getEmployeeFieldInfo 接口 userid 参数类型错误

This commit is contained in:
Copilot
2026-03-09 17:15:33 +08:00
committed by GitHub
parent e2120d6a42
commit 474f4fda0a
3 changed files with 7 additions and 10 deletions

View File

@@ -37,12 +37,12 @@ public interface WxCpHrService {
* 权限说明:
* 需要配置人事助手的secret调用接口前需给对应成员赋予人事小助手应用的权限。
*
* @param userids 员工userid列表不超过20个
* @param fields 指定字段key列表不填则返回全部字段
* @param userid 员工userid
* @param fields 指定字段key列表不填则返回全部字段
* @return 员工档案数据响应 wx cp hr employee field data resp
* @throws WxErrorException the wx error exception
*/
WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(List<String> userids, List<String> fields) throws WxErrorException;
WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(String userid, List<String> fields) throws WxErrorException;
/**
* 更新员工档案数据.

View File

@@ -39,15 +39,12 @@ public class WxCpHrServiceImpl implements WxCpHrService {
}
@Override
public WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(List<String> userids, List<String> fields) throws WxErrorException {
if (userids == null || userids.isEmpty()) {
public WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(String userid, List<String> fields) throws WxErrorException {
if (userid == null || userid.trim().isEmpty()) {
throw new IllegalArgumentException("userid 不能为空");
}
if (userids.size() > 20) {
throw new IllegalArgumentException("userid 每次最多传入20个");
}
JsonObject jsonObject = new JsonObject();
jsonObject.add("userid", WxCpGsonBuilder.create().toJsonTree(userids));
jsonObject.addProperty("userid", userid);
if (fields != null && !fields.isEmpty()) {
jsonObject.add("fields", WxCpGsonBuilder.create().toJsonTree(fields));
}

View File

@@ -75,7 +75,7 @@ public class WxCpHrServiceImplTest {
public void testGetEmployeeFieldInfo() throws WxErrorException {
WxCpHrService hrService = this.wxCpService.getHrService();
WxCpHrEmployeeFieldDataResp resp = hrService.getEmployeeFieldInfo(
Collections.singletonList(this.configStorage.getUserId()), null);
this.configStorage.getUserId(), null);
assertThat(resp).isNotNull();
assertThat(resp.getEmployeeFieldList()).isNotNull();
log.info("获取员工档案数据: {}", resp);