HR助手getEmployeeFieldInfo,getAll参数问题,没有此参数#3925
HR助手getEmployeeFieldInfo,getAll参数问题,没有此参数#3925binarywang merged 5 commits intobinarywang:developfrom
Conversation
merge latest from fork source
…参数不符合系统要求,需要参照具体API接口说明,微信原始报文:{"errcode":40058,"errmsg":"invalid Request Parameter
|
auggie review |
There was a problem hiding this comment.
Pull request overview
该 PR 试图修复/调整企业微信「人事助手」接口 getEmployeeFieldInfo 的入参处理方式,通过新增 getAll 参数与请求体字段来控制是否获取全部档案字段,并同步更新接口注释。
Changes:
- 为
WxCpHrService#getEmployeeFieldInfo新增(userid, boolean getAll, fields)重载方法 WxCpHrServiceImpl#getEmployeeFieldInfo请求体新增写入get_all,并在fields为空时增加参数校验逻辑- 更新
WxCpHrService中对fields/getAll的 Javadoc 描述
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpHrServiceImpl.java | 新增重载实现、请求体写入 get_all、调整 fields 为空时的校验逻辑 |
| weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpHrService.java | 新增重载方法签名并更新参数文档 |
| jsonObject.addProperty("userid", userid); | ||
| jsonObject.addProperty("get_all", getAll); | ||
| if (fields != null && !fields.isEmpty()) { |
There was a problem hiding this comment.
这里无条件向请求体写入了 get_all 字段(即使为 false 也会发送)。从该接口的既有用法/测试(WxCpHrServiceImplTest#testGetEmployeeFieldInfo 传 fields=null)以及 PR 描述来看,接口并不支持该参数,发送后会触发 40058「invalid Request Parameter」。建议不要在请求体中包含 get_all,需要“获取全部字段”时直接省略 fields 字段即可。
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpHrServiceImpl.java
Outdated
Show resolved
Hide resolved
| public WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(String userid, List<String> fields) throws WxErrorException { | ||
| return getEmployeeFieldInfo(userid,false,fields); | ||
| } |
There was a problem hiding this comment.
这里的格式与本文件其余部分不一致(逗号后缺少空格)。建议按既有风格调整为在逗号后留空格,避免 checkstyle/可读性问题。
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpHrServiceImpl.java
Outdated
Show resolved
Hide resolved
| * @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; |
There was a problem hiding this comment.
该接口原注释曾表明 fields 可不填以返回全部字段;并且测试用例也以 fields=null 调用。这里把 fields 描述改成必填会造成文档与实际/既有用法不一致。建议在 Javadoc 中明确 fields 为空时的行为(例如:不填则返回全部字段)。
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpHrService.java
Outdated
Show resolved
Hide resolved
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpHrService.java
Outdated
Show resolved
Hide resolved
🤖 Augment PR SummarySummary: Adds a 🤖 Was this summary useful? React with 👍 or 👎 |
| * @return 员工档案数据响应 wx cp hr employee field data resp | ||
| * @throws WxErrorException the wx error exception | ||
| */ | ||
| WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(String userid, boolean getAll, List<String> fields) throws WxErrorException; |
There was a problem hiding this comment.
Adding a new abstract method to the public WxCpHrService interface is a source/binary breaking change for any external custom implementations. Please double-check this is acceptable for the project’s compatibility guarantees.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| jsonObject.add("fields", WxCpGsonBuilder.create().toJsonTree(fields)); | ||
| }else{ | ||
| if(!getAll) | ||
| throw new IllegalArgumentException("fields 不能为空"); |
There was a problem hiding this comment.
With this validation, existing calls like getEmployeeFieldInfo(userid, null) will now throw IllegalArgumentException (and it also breaks WxCpHrServiceImplTest.testGetEmployeeFieldInfo). If the intent is to keep supporting “get all fields” when fields is omitted, this behavioral change likely needs to be revisited.
Severity: medium
Other Locations
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpHrServiceImpl.java:43
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@softboy99 麻烦处理下review comment里提到的问题,谢谢 |
…rvice.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…pHrServiceImpl.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…rvice.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
HR助手getEmployeeFieldInfo,getAll参数问题,没有此参数,请求报错错误代码:40058, 错误信息:不合法的参数;传递参数不符合系统要求,需要参照具体API接口说明,微信原始报文:{"errcode":40058,"errmsg":"invalid Request Parameter