| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,60 @@ | |||
| 1 | + package me.chanjar.weixin.cp.api; | ||
| 2 | + | ||
| 3 | + import me.chanjar.weixin.common.error.WxErrorException; | ||
| 4 | + import me.chanjar.weixin.cp.bean.hr.WxCpHrEmployeeFieldData; | ||
| 5 | + import me.chanjar.weixin.cp.bean.hr.WxCpHrEmployeeFieldDataResp; | ||
| 6 | + import me.chanjar.weixin.cp.bean.hr.WxCpHrEmployeeFieldInfoResp; | ||
| 7 | + | ||
| 8 | + import java.util.List; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * 人事助手相关接口. | ||
| 12 | + * 官方文档:https://developer.work.weixin.qq.com/document/path/99132 | ||
| 13 | + * | ||
| 14 | + * @author <a href="https://github.com/leejoker">leejoker</a> created on 2024-01-01 | ||
| 15 | + */ | ||
| 16 | + public interface WxCpHrService { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 获取员工档案字段信息. | ||
| 20 | + * <p> | ||
| 21 | + * 请求方式:POST(HTTPS) | ||
| 22 | + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/hr/employee/get_field_info?access_token=ACCESS_TOKEN | ||
| 23 | + * 权限说明: | ||
| 24 | + * 需要配置人事助手的secret,调用接口前需给对应成员赋予人事小助手应用的权限。 | ||
| 25 | + * | ||
| 26 | + * @param fields 指定字段key列表,不填则返回全部字段 | ||
| 27 | + * @return 字段信息响应 wx cp hr employee field info resp | ||
| 28 | + * @throws WxErrorException the wx error exception | ||
| 29 | + */ | ||
| 30 | + WxCpHrEmployeeFieldInfoResp getFieldInfo(List<String> fields) throws WxErrorException; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 获取员工档案数据. | ||
| 34 | + * <p> | ||
| 35 | + * 请求方式:POST(HTTPS) | ||
| 36 | + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/hr/employee/get_employee_field_info?access_token=ACCESS_TOKEN | ||
| 37 | + * 权限说明: | ||
| 38 | + * 需要配置人事助手的secret,调用接口前需给对应成员赋予人事小助手应用的权限。 | ||
| 39 | + * | ||
| 40 | + * @param userids 员工userid列表,不超过20个 | ||
| 41 | + * @param fields 指定字段key列表,不填则返回全部字段 | ||
| 42 | + * @return 员工档案数据响应 wx cp hr employee field data resp | ||
| 43 | + * @throws WxErrorException the wx error exception | ||
| 44 | + */ | ||
| 45 | + WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(List<String> userids, List<String> fields) throws WxErrorException; | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 更新员工档案数据. | ||
| 49 | + * <p> | ||
| 50 | + * 请求方式:POST(HTTPS) | ||
| 51 | + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/hr/employee/update_employee_field_info?access_token=ACCESS_TOKEN | ||
| 52 | + * 权限说明: | ||
| 53 | + * 需要配置人事助手的secret,调用接口前需给对应成员赋予人事小助手应用的权限。 | ||
| 54 | + * | ||
| 55 | + * @param userid 员工userid | ||
| 56 | + * @param fieldList 字段数据列表 | ||
| 57 | + * @throws WxErrorException the wx error exception | ||
| 58 | + */ | ||
| 59 | + void updateEmployeeFieldInfo(String userid, List<WxCpHrEmployeeFieldData.FieldItem> fieldList) throws WxErrorException; | ||
| 60 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -594,4 +594,11 @@ public interface WxCpService extends WxService { | |||
| 594 | 594 | * @return 智能机器人服务 intelligent robot service | |
| 595 | 595 | */ | |
| 596 | 596 | WxCpIntelligentRobotService getIntelligentRobotService(); | |
| 597 | + | ||
| 598 | + /** | ||
| 599 | + * 获取人事助手服务 | ||
| 600 | + * | ||
| 601 | + * @return 人事助手服务 hr service | ||
| 602 | + */ | ||
| 603 | + WxCpHrService getHrService(); | ||
| 597 | 604 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
| 75 | 75 | private final WxCpMeetingService meetingService = new WxCpMeetingServiceImpl(this); | |
| 76 | 76 | private final WxCpCorpGroupService corpGroupService = new WxCpCorpGroupServiceImpl(this); | |
| 77 | 77 | private final WxCpIntelligentRobotService intelligentRobotService = new WxCpIntelligentRobotServiceImpl(this); | |
| 78 | + private final WxCpHrService hrService = new WxCpHrServiceImpl(this); | ||
| 78 | 79 | ||
| 79 | 80 | /** | |
| 80 | 81 | * 全局的是否正在刷新access token的锁. | |
@@ -708,4 +709,9 @@ public WxCpCorpGroupService getCorpGroupService() { | |||
| 708 | 709 | public WxCpIntelligentRobotService getIntelligentRobotService() { | |
| 709 | 710 | return this.intelligentRobotService; | |
| 710 | 711 | } | |
| 712 | + | ||
| 713 | + @Override | ||
| 714 | + public WxCpHrService getHrService() { | ||
| 715 | + return this.hrService; | ||
| 716 | + } | ||
| 711 | 717 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,77 @@ | |||
| 1 | + package me.chanjar.weixin.cp.api.impl; | ||
| 2 | + | ||
| 3 | + import com.google.gson.JsonObject; | ||
| 4 | + import lombok.RequiredArgsConstructor; | ||
| 5 | + import me.chanjar.weixin.common.error.WxErrorException; | ||
| 6 | + import me.chanjar.weixin.cp.api.WxCpHrService; | ||
| 7 | + import me.chanjar.weixin.cp.api.WxCpService; | ||
| 8 | + import me.chanjar.weixin.cp.bean.hr.WxCpHrEmployeeFieldData; | ||
| 9 | + import me.chanjar.weixin.cp.bean.hr.WxCpHrEmployeeFieldDataResp; | ||
| 10 | + import me.chanjar.weixin.cp.bean.hr.WxCpHrEmployeeFieldInfoResp; | ||
| 11 | + import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||
| 12 | + | ||
| 13 | + import java.util.List; | ||
| 14 | + | ||
| 15 | + import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Hr.*; | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 人事助手相关接口实现类. | ||
| 19 | + * 官方文档:https://developer.work.weixin.qq.com/document/path/99132 | ||
| 20 | + * | ||
| 21 | + * @author <a href="https://github.com/leejoker">leejoker</a> created on 2024-01-01 | ||
| 22 | + */ | ||
| 23 | + @RequiredArgsConstructor | ||
| 24 | + public class WxCpHrServiceImpl implements WxCpHrService { | ||
| 25 | + | ||
| 26 | + private final WxCpService cpService; | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public WxCpHrEmployeeFieldInfoResp getFieldInfo(List<String> fields) throws WxErrorException { | ||
| 30 | + JsonObject jsonObject = new JsonObject(); | ||
| 31 | + if (fields != null && !fields.isEmpty()) { | ||
| 32 | + jsonObject.add("fields", WxCpGsonBuilder.create().toJsonTree(fields)); | ||
| 33 | + } | ||
| 34 | + String response = this.cpService.post( | ||
| 35 | + this.cpService.getWxCpConfigStorage().getApiUrl(GET_FIELD_INFO), | ||
| 36 | + jsonObject.toString() | ||
| 37 | + ); | ||
| 38 | + return WxCpHrEmployeeFieldInfoResp.fromJson(response); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public WxCpHrEmployeeFieldDataResp getEmployeeFieldInfo(List<String> userids, List<String> fields) throws WxErrorException { | ||
| 43 | + if (userids == null || userids.isEmpty()) { | ||
| 44 | + throw new IllegalArgumentException("userids 不能为空"); | ||
| 45 | + } | ||
| 46 | + if (userids.size() > 20) { | ||
| 47 | + throw new IllegalArgumentException("userids 每次最多传入20个"); | ||
| 48 | + } | ||
| 49 | + JsonObject jsonObject = new JsonObject(); | ||
| 50 | + jsonObject.add("userids", WxCpGsonBuilder.create().toJsonTree(userids)); | ||
| 51 | + if (fields != null && !fields.isEmpty()) { | ||
| 52 | + jsonObject.add("fields", WxCpGsonBuilder.create().toJsonTree(fields)); | ||
| 53 | + } | ||
| 54 | + String response = this.cpService.post( | ||
| 55 | + this.cpService.getWxCpConfigStorage().getApiUrl(GET_EMPLOYEE_FIELD_INFO), | ||
| 56 | + jsonObject.toString() | ||
| 57 | + ); | ||
| 58 | + return WxCpHrEmployeeFieldDataResp.fromJson(response); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public void updateEmployeeFieldInfo(String userid, List<WxCpHrEmployeeFieldData.FieldItem> fieldList) throws WxErrorException { | ||
| 63 | + if (userid == null || userid.trim().isEmpty()) { | ||
| 64 | + throw new IllegalArgumentException("userid 不能为空"); | ||
| 65 | + } | ||
| 66 | + if (fieldList == null || fieldList.isEmpty()) { | ||
| 67 | + throw new IllegalArgumentException("fieldList 不能为空"); | ||
| 68 | + } | ||
| 69 | + JsonObject jsonObject = new JsonObject(); | ||
| 70 | + jsonObject.addProperty("userid", userid); | ||
| 71 | + jsonObject.add("field_list", WxCpGsonBuilder.create().toJsonTree(fieldList)); | ||
| 72 | + this.cpService.post( | ||
| 73 | + this.cpService.getWxCpConfigStorage().getApiUrl(UPDATE_EMPLOYEE_FIELD_INFO), | ||
| 74 | + jsonObject.toString() | ||
| 75 | + ); | ||
| 76 | + } | ||
| 77 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,52 @@ | |||
| 1 | + package me.chanjar.weixin.cp.bean.hr; | ||
| 2 | + | ||
| 3 | + import com.google.gson.annotations.SerializedName; | ||
| 4 | + import lombok.Data; | ||
| 5 | + import lombok.NoArgsConstructor; | ||
| 6 | + | ||
| 7 | + import java.io.Serializable; | ||
| 8 | + import java.util.List; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * 人事助手-员工档案数据(单个员工). | ||
| 12 | + * | ||
| 13 | + * @author <a href="https://github.com/leejoker">leejoker</a> created on 2024-01-01 | ||
| 14 | + */ | ||
| 15 | + @Data | ||
| 16 | + @NoArgsConstructor | ||
| 17 | + public class WxCpHrEmployeeFieldData implements Serializable { | ||
| 18 | + private static final long serialVersionUID = 4593693598671765396L; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 员工userid. | ||
| 22 | + */ | ||
| 23 | + @SerializedName("userid") | ||
| 24 | + private String userid; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 字段数据列表. | ||
| 28 | + */ | ||
| 29 | + @SerializedName("field_list") | ||
| 30 | + private List<FieldItem> fieldList; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 字段数据项. | ||
| 34 | + */ | ||
| 35 | + @Data | ||
| 36 | + @NoArgsConstructor | ||
| 37 | + public static class FieldItem implements Serializable { | ||
| 38 | + private static final long serialVersionUID = 1L; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 字段key. | ||
| 42 | + */ | ||
| 43 | + @SerializedName("field_key") | ||
| 44 | + private String fieldKey; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 字段值. | ||
| 48 | + */ | ||
| 49 | + @SerializedName("field_value") | ||
| 50 | + private WxCpHrEmployeeFieldValue fieldValue; | ||
| 51 | + } | ||
| 52 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,38 @@ | |||
| 1 | + package me.chanjar.weixin.cp.bean.hr; | ||
| 2 | + | ||
| 3 | + import com.google.gson.annotations.SerializedName; | ||
| 4 | + import lombok.Data; | ||
| 5 | + import lombok.EqualsAndHashCode; | ||
| 6 | + import lombok.NoArgsConstructor; | ||
| 7 | + import me.chanjar.weixin.cp.bean.WxCpBaseResp; | ||
| 8 | + import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||
| 9 | + | ||
| 10 | + import java.util.List; | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 人事助手-获取员工档案数据响应. | ||
| 14 | + * | ||
| 15 | + * @author <a href="https://github.com/leejoker">leejoker</a> created on 2024-01-01 | ||
| 16 | + */ | ||
| 17 | + @Data | ||
| 18 | + @NoArgsConstructor | ||
| 19 | + @EqualsAndHashCode(callSuper = true) | ||
| 20 | + public class WxCpHrEmployeeFieldDataResp extends WxCpBaseResp { | ||
| 21 | + private static final long serialVersionUID = 6593693598671765396L; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 员工档案数据列表. | ||
| 25 | + */ | ||
| 26 | + @SerializedName("employee_field_list") | ||
| 27 | + private List<WxCpHrEmployeeFieldData> employeeFieldList; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * From json wx cp hr employee field data resp. | ||
| 31 | + * | ||
| 32 | + * @param json the json | ||
| 33 | + * @return the wx cp hr employee field data resp | ||
| 34 | + */ | ||
| 35 | + public static WxCpHrEmployeeFieldDataResp fromJson(String json) { | ||
| 36 | + return WxCpGsonBuilder.create().fromJson(json, WxCpHrEmployeeFieldDataResp.class); | ||
| 37 | + } | ||
| 38 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,103 @@ | |||
| 1 | + package me.chanjar.weixin.cp.bean.hr; | ||
| 2 | + | ||
| 3 | + import com.google.gson.annotations.SerializedName; | ||
| 4 | + import lombok.Data; | ||
| 5 | + import lombok.NoArgsConstructor; | ||
| 6 | + | ||
| 7 | + import java.io.Serializable; | ||
| 8 | + import java.util.List; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * 人事助手-员工档案字段信息. | ||
| 12 | + * | ||
| 13 | + * @author <a href="https://github.com/leejoker">leejoker</a> created on 2024-01-01 | ||
| 14 | + */ | ||
| 15 | + @Data | ||
| 16 | + @NoArgsConstructor | ||
| 17 | + public class WxCpHrEmployeeFieldInfo implements Serializable { | ||
| 18 | + private static final long serialVersionUID = 2593693598671765396L; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 字段key. | ||
| 22 | + */ | ||
| 23 | + @SerializedName("field_key") | ||
| 24 | + private String fieldKey; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 字段英文名称. | ||
| 28 | + */ | ||
| 29 | + @SerializedName("field_en_name") | ||
| 30 | + private String fieldEnName; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 字段中文名称. | ||
| 34 | + */ | ||
| 35 | + @SerializedName("field_zh_name") | ||
| 36 | + private String fieldZhName; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 字段类型. | ||
| 40 | + * 具体取值参见 {@link WxCpHrFieldType} | ||
| 41 | + */ | ||
| 42 | + @SerializedName("field_type") | ||
| 43 | + private Integer fieldType; | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * 获取字段类型枚举. | ||
| 47 | + * | ||
| 48 | + * @return 字段类型枚举,未匹配时返回 null | ||
| 49 | + */ | ||
| 50 | + public WxCpHrFieldType getFieldTypeEnum() { | ||
| 51 | + return fieldType == null ? null : WxCpHrFieldType.fromCode(fieldType); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 是否系统字段. | ||
| 56 | + * 0: 否 | ||
| 57 | + * 1: 是 | ||
| 58 | + */ | ||
| 59 | + @SerializedName("is_sys") | ||
| 60 | + private Integer isSys; | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 字段详情. | ||
| 64 | + */ | ||
| 65 | + @SerializedName("field_detail") | ||
| 66 | + private FieldDetail fieldDetail; | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * 字段详情. | ||
| 70 | + */ | ||
| 71 | + @Data | ||
| 72 | + @NoArgsConstructor | ||
| 73 | + public static class FieldDetail implements Serializable { | ||
| 74 | + private static final long serialVersionUID = 1L; | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 选项列表(单选/多选字段专用). | ||
| 78 | + */ | ||
| 79 | + @SerializedName("option_list") | ||
| 80 | + private List<Option> optionList; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * 选项. | ||
| 85 | + */ | ||
| 86 | + @Data | ||
| 87 | + @NoArgsConstructor | ||
| 88 | + public static class Option implements Serializable { | ||
| 89 | + private static final long serialVersionUID = 1L; | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 选项key. | ||
| 93 | + */ | ||
| 94 | + @SerializedName("key") | ||
| 95 | + private String key; | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * 选项值. | ||
| 99 | + */ | ||
| 100 | + @SerializedName("value") | ||
| 101 | + private String value; | ||
| 102 | + } | ||
| 103 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments