Skip to content

实现企业微信人事助手 API (HR Assistant)#3892

Merged
binarywang merged 3 commits intodevelopfrom
copilot/check-hr-assistant-api-support
Feb 28, 2026
Merged

实现企业微信人事助手 API (HR Assistant)#3892
binarywang merged 3 commits intodevelopfrom
copilot/check-hr-assistant-api-support

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

企业微信 SDK 缺少人事助手相关 API 支持(官方文档)。本 PR 新增完整的人事助手服务层。

新增内容

API 路径常量 (WxCpApiPathConsts.Hr)

  • GET_FIELD_INFO — 获取员工档案字段配置
  • GET_EMPLOYEE_FIELD_INFO — 获取员工档案数据
  • UPDATE_EMPLOYEE_FIELD_INFO — 更新员工档案数据

Bean 类 (bean/hr/)

  • WxCpHrFieldType — 字段类型枚举(TEXT/DATE/NUMBER/SINGLE_SELECT/MULTI_SELECT/ATTACHMENT/PHONE/EMAIL),含 fromCode(int) 工厂方法
  • WxCpHrEmployeeFieldInfo — 字段配置,fieldType 保留 Integer 用于 JSON 反序列化,新增 getFieldTypeEnum() 方法返回 WxCpHrFieldType 枚举
  • WxCpHrEmployeeFieldValue — 字段值(涵盖 text、option、multi-option、date、attachment)
  • WxCpHrEmployeeFieldData — 单员工档案数据
  • WxCpHrEmployeeFieldInfoResp / WxCpHrEmployeeFieldDataResp — 响应包装类

服务接口与实现

  • WxCpHrService + WxCpHrServiceImpl
  • getEmployeeFieldInfo:客户端侧校验 userids 非空且不超过 20 个,不满足时抛 IllegalArgumentException
  • updateEmployeeFieldInfo:客户端侧校验 userid 非空白、fieldList 非空,不满足时抛 IllegalArgumentException
  • WxCpService#getHrService() 注册入主服务,BaseWxCpServiceImpl 默认初始化

使用示例

WxCpHrService hrService = wxCpService.getHrService();

// 获取所有字段配置
WxCpHrEmployeeFieldInfoResp fields = hrService.getFieldInfo(null);

// 通过枚举判断字段类型
for (WxCpHrEmployeeFieldInfo info : fields.getFieldInfoList()) {
    WxCpHrFieldType type = info.getFieldTypeEnum(); // e.g. WxCpHrFieldType.TEXT
}

// 获取员工档案(userids 必填,最多 20 个)
WxCpHrEmployeeFieldDataResp data = hrService.getEmployeeFieldInfo(
    List.of("userid1"), null);

// 更新员工档案
WxCpHrEmployeeFieldData.FieldItem item = new WxCpHrEmployeeFieldData.FieldItem();
item.setFieldKey("sys_field_name");
WxCpHrEmployeeFieldValue value = new WxCpHrEmployeeFieldValue();
value.setTextValue("张三");
item.setFieldValue(value);
hrService.updateEmployeeFieldInfo("userid1", List.of(item));
Original prompt

This section details on the original issue you should resolve

<issue_title>企业微信是否支持人事助手相关API?</issue_title>
<issue_description>企业微信是否支持人事助手相关API?

官方文档地址

https://developer.work.weixin.qq.com/document/path/99132
</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: 全部用中文
需要用中文,包括PR标题和分析总结过程


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate support for HR assistant API in WeChat Work 实现企业微信人事助手 API (HR Assistant) Feb 28, 2026
@binarywang binarywang marked this pull request as ready for review February 28, 2026 02:40
Copilot AI review requested due to automatic review settings February 28, 2026 02:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

本 PR 为 weixin-java-cp 模块补齐企业微信「人事助手(HR Assistant)」相关能力,在现有 WxCpService 服务体系中新增 HR Service,并补充对应的 API 路径常量、请求/响应 Bean 与集成测试用例。

Changes:

  • 新增人事助手 API 路径常量 WxCpApiPathConsts.Hr(获取字段配置/获取档案数据/更新档案数据)
  • 新增 HR 领域 Bean(字段信息、字段值、员工档案数据、响应包装类)
  • 新增 WxCpHrService 接口与 WxCpHrServiceImpl 实现,并在 WxCpService/BaseWxCpServiceImpl 中注册 getHrService()

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java 增加 HR Assistant 相关接口路径常量,供服务实现拼装请求 URL
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpHrService.java 新增 HR Assistant 服务接口定义(字段配置/档案数据查询与更新)
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpHrServiceImpl.java 新增 HR Assistant 服务实现,负责组装请求体并调用企业微信 API
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java 在主服务接口中新增 getHrService() 入口
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java 默认初始化并暴露 WxCpHrService,纳入统一服务管理
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/hr/WxCpHrEmployeeFieldInfo.java 新增员工档案字段配置 Bean(字段 key/名称/类型/系统字段/选项列表等)
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/hr/WxCpHrEmployeeFieldValue.java 新增字段值承载 Bean(文本/选项/日期/附件等值类型)
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/hr/WxCpHrEmployeeFieldData.java 新增单员工档案数据 Bean(userid + 字段列表)
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/hr/WxCpHrEmployeeFieldInfoResp.java 新增“字段配置”响应包装类(继承 WxCpBaseResp)
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/hr/WxCpHrEmployeeFieldDataResp.java 新增“员工档案数据”响应包装类(继承 WxCpBaseResp)
weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpHrServiceImplTest.java 新增 HR Assistant 集成测试用例,覆盖字段配置查询/档案查询/档案更新调用路径

@binarywang
Copy link
Owner

@copilot apply changes based on the comments in this thread

Repository owner deleted a comment from augmentcode bot Feb 28, 2026
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
@binarywang binarywang merged commit 389f178 into develop Feb 28, 2026
1 check passed
@binarywang binarywang deleted the copilot/check-hr-assistant-api-support branch February 28, 2026 09:01
@binarywang binarywang added this to the 4.8.2 milestone Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

企业微信是否支持人事助手相关API?

3 participants