E5F9 HR助手getEmployeeFieldInfo,getAll参数问题,没有此参数 by softboy99 · Pull Request #3925 · binarywang/WxJava · GitHub
[go: up one dir, main page]

Skip to content
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 @@ -38,13 +38,18 @@ public interface WxCpHrService {
* 需要配置人事助手的secret,调用接口前需给对应成员赋予人事小助手应用的权限。
*
* @param userid 员工userid
* @param fields 指定字段key列表,不填则返回全部字段
* @param fields 指定字段key列表
* @return 员工档案数据响应 wx cp hr employee field data resp
* @throws WxErrorException the wx error exception
*/
WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(String userid, List<String> fields) throws WxErrorException;
Comment on lines 40 to 45
Copy link
Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

该接口原注释曾表明 fields 可不填以返回全部字段;并且测试用例也以 fields=null 调用。这里把 fields 描述改成必填会造成文档与实际/既有用法不一致。建议在 Javadoc 中明确 fields 为空时的行为(例如:不填则返回全部字段)。

Copilot uses AI. Check for mistakes.

/**
* 获取员工档案数据.
* <p>
* 请求方式:POST(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/hr/get_staff_info?access_token=ACCESS_TOKEN
* 权限说明:
* 更新员工档案数据.
* <p>
* 请求方式:POST(HTTPS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ public WxCpHrEmployeeFieldInfoResp getFieldInfo(List<String> fields) throws WxEr

@Override
public WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(String userid, List<String> fields) throws WxErrorException {
return getEmployeeFieldInfo(userid,false,fields);
}
Comment on lines 42 to +44
Copy link
Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的格式与本文件其余部分不一致(逗号后缺少空格)。建议按既有风格调整为在逗号后留空格,避免 checkstyle/可读性问题。

Copilot uses AI. Check for mistakes.

@Override
public WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(String userid, boolean getAll, List<String> fields) throws WxErrorException {
if (userid == null || userid.trim().isEmpty()) {
throw new IllegalArgumentException("userid 不能为空");
}
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("userid", userid);
jsonObject.addProperty("get_all", getAll);
if (fields != null && !fields.isEmpty()) {
Comment on lines 52 to 54
Copy link
Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里无条件向请求体写入了 get_all 字段(即使为 false 也会发送)。从该接口的既有用法/测试(WxCpHrServiceImplTest#testGetEmployeeFieldInfo 传 fields=null)以及 PR 描述来看,接口并不支持该参数,发送后会触发 40058「invalid Request Parameter」。建议不要在请求体中包含 get_all,需要“获取全部字段”时直接省略 fields 字段即可。

Copilot uses AI. Check for mistakes.
jsonObject.add("fields", WxCpGsonBuilder.create().toJsonTree(fields));
}
Expand Down
0