diff --git a/apis.md.go b/apis.md.go index a399c00..ecc457a 100644 --- a/apis.md.go +++ b/apis.md.go @@ -576,6 +576,48 @@ func (c *WorkwxApp) execOAGetApprovalDetail(req reqOAGetApprovalDetail) (respOAG return resp, nil } +// execOAGetCorpVacationConf 获取企业假期管理配置 +func (c *WorkwxApp) execOAGetCorpVacationConf(req reqOAGetCorpVacationConf) (respOAGetCorpVacationConf, error) { + var resp respOAGetCorpVacationConf + err := c.executeQyapiGet("/cgi-bin/oa/vacation/getcorpconf", req, &resp, true) + if err != nil { + return respOAGetCorpVacationConf{}, err + } + if bizErr := resp.TryIntoErr(); bizErr != nil { + return respOAGetCorpVacationConf{}, bizErr + } + + return resp, nil +} + +// execOAGetUserVacationQuota 获取成员假期余额 +func (c *WorkwxApp) execOAGetUserVacationQuota(req reqOAGetUserVacationQuota) (respOAGetUserVacationQuota, error) { + var resp respOAGetUserVacationQuota + err := c.executeQyapiJSONPost("/cgi-bin/oa/vacation/getuservacationquota", req, &resp, true) + if err != nil { + return respOAGetUserVacationQuota{}, err + } + if bizErr := resp.TryIntoErr(); bizErr != nil { + return respOAGetUserVacationQuota{}, bizErr + } + + return resp, nil +} + +// execOASetOneUserVacationQuota 修改成员假期余额 +func (c *WorkwxApp) execOASetOneUserVacationQuota(req reqOASetOneUserVacationQuota) (respOASetOneUserVacationQuota, error) { + var resp respOASetOneUserVacationQuota + err := c.executeQyapiJSONPost("/cgi-bin/oa/vacation/setoneuserquota", req, &resp, true) + if err != nil { + return respOASetOneUserVacationQuota{}, err + } + if bizErr := resp.TryIntoErr(); bizErr != nil { + return respOASetOneUserVacationQuota{}, bizErr + } + + return resp, nil +} + // execMsgAuditListPermitUser 获取会话内容存档开启成员列表 func (c *WorkwxApp) execMsgAuditListPermitUser(req reqMsgAuditListPermitUser) (respMsgAuditListPermitUser, error) { var resp respMsgAuditListPermitUser diff --git a/docs/apis.md b/docs/apis.md index f70358e..35b32e1 100644 --- a/docs/apis.md +++ b/docs/apis.md @@ -159,6 +159,9 @@ Name|Request Type|Response Type|Access Token|URL|Doc `execOAApplyEvent`|`reqOAApplyEvent`|`respOAApplyEvent`|+|`POST /cgi-bin/oa/applyevent`|[提交审批申请](https://work.weixin.qq.com/api/doc/90000/90135/91853) `execOAGetApprovalInfo`|`reqOAGetApprovalInfo`|`respOAGetApprovalInfo`|+|`POST /cgi-bin/oa/getapprovalinfo`|[批量获取审批单号](https://work.weixin.qq.com/api/doc/90000/90135/91816) `execOAGetApprovalDetail`|`reqOAGetApprovalDetail`|`respOAGetApprovalDetail`|+|`POST /cgi-bin/oa/getapprovaldetail`|[获取审批申请详情](https://work.weixin.qq.com/api/doc/90000/90135/91983) +`execOAGetCorpVacationConf`| `reqOAGetCorpVacationConf` | `respOAGetCorpVacationConf` |+| `GET /cgi-bin/oa/vacation/getcorpconf` |[获取企业假期管理配置](https://developer.work.weixin.qq.com/document/path/93375) +`execOAGetUserVacationQuota`| `reqOAGetUserVacationQuota` | `respOAGetUserVacationQuota` |+| `POST /cgi-bin/oa/vacation/getuservacationquota` |[获取成员假期余额](https://developer.work.weixin.qq.com/document/path/93376) +`execOASetOneUserVacationQuota`| `reqOASetOneUserVacationQuota` | `respOASetOneUserVacationQuota` |+| `POST /cgi-bin/oa/vacation/setoneuserquota` |[修改成员假期余额](https://developer.work.weixin.qq.com/document/path/93377) # 企业支付 diff --git a/docs/oa.md b/docs/oa.md index c3ab1b0..baead9e 100644 --- a/docs/oa.md +++ b/docs/oa.md @@ -414,3 +414,72 @@ const OAApprovalInfoFilterKeyDepartment OAApprovalInfoFilterKey = "department" // OAApprovalInfoFilterKeySpStatus 审批状态 const OAApprovalInfoFilterKeySpStatus OAApprovalInfoFilterKey = "sp_status" ``` + +### `CorpVacationConf` 企业假期管理配置 + +Name|JSON|Type|Doc +:---|:---|:---|:-- +`ID`|`id`|`uint32`| 假期id +`Name`|`name`|`string`| 假期名称 +`TimeAttr`|`time_attr`|`uint32`| 假期时间刻度:0-按天请假;1-按小时请假 +`DurationType`|`duration_type`|`uint32`| 时长计算类型:0-自然日;1-工作日 +`QuotaAttr`|`quota_attr`|`CorpVacationConfQuotaAttr`| 假期发放相关配置 +`PerdayDuration`|`perday_duration`|`uint32`| 单位换算值,即1天对应的秒数,可将此值除以3600得到一天对应的小时。 +`IsNewovertime`|`is_newovertime`|`*uint32`| 是否关联加班调休,0-不关联,1-关联,关联后改假期类型变为调休假 +`EnterCompTimeLimit`|`enter_comp_time_limit`|`*uint32`| 入职时间大于n个月可用该假期,单位为月 +`ExpireRule`|`expire_rule`|`*CorpVacationConfExpireRule`| 假期过期规则 + +### `CorpVacationConfQuotaAttr` 企业假期管理配置-假期发放相关配置 + +Name|JSON|Type|Doc +:---|:---|:-------------|:-- +`Type`|`type`|`uint32`| 假期发放类型:0-不限额;1-自动按年发放;2-手动发放;3-自动按月发放 +`AutoresetTime`|`autoreset_time`|`uint32`| 自动发放时间戳,若假期发放为自动发放,此参数代表自动发放日期。注:返回时间戳的年份是无意义的,请只使用返回时间的月和日;若at_entry_date为true,该字段则无效,假期发放时间为员工入职时间 +`AutoresetDuration`|`autoreset_duration`|`uint32`| 自动发放时长,单位为秒。注:只有自动按年发放和自动按月发放时有效,若选择了按照工龄和司龄发放,该字段无效,发放时长请使用区间中的quota +`QuotaRuleType`|`quota_rule_type`|`*uint32`| 额度计算类型,自动按年发放时有效,0-固定额度;1-按工龄计算;2-按司龄计算 +`QuotaRules`|`quota_rules`|`*CorpVacationConfQuotaRules`| 额度计算规则,自动按年发放时有效 +`AtEntryDate`|`at_entry_date`|`*bool`| 是否按照入职日期发放假期,只有在自动按年发放类型有效,选择后发放假期的时间会成为员工入职的日期 +`AutoResetMonthDay`|`auto_reset_month_day`|`*uint32`| 自动按月发放的发放时间,只有自动按月发放类型有效 + +### `CorpVacationConfQuotaRules` 企业假期管理配置-额度计算规则 + +Name|JSON|Type|Doc +:---|:---|:-------------|:-- +`List`|`list`|`[]CorpVacationConfQuotaRule`| 额度计算规则区间,只有在选择了按照工龄计算或者按照司龄计算时有效 + +### `CorpVacationConfQuotaRule` 企业假期管理配置-额度计算规则区间 + +Name|JSON|Type|Doc +:---|:---|:-------------|:-- +`Quota`|`quota`|`uint32`| 区间发放时长,单位为s +`Begin`|`begin`|`uint32`| 区间开始点,单位为年 +`End`|`end`|`uint32`| 区间结束点,无穷大则为0,单位为年 +`BasedOnActualWorkTime`|`based_on_actual_work_time`|`bool`| 是否根据实际入职时间计算假期,选择后会根据员工在今年的实际工作时间发放假期 + +### `CorpVacationConfExpireRule` 企业假期管理配置-假期过期规则 + +Name|JSON|Type|Doc +:---|:---|:-------------|:-- +`Type`|`type`|`uint32`| 过期规则类型,1-按固定时间过期,2-从发放日按年过期,3-从发放日按月过期,4-不过期 +`Duration`|`duration`|`uint64`| 有效期,按年过期为年,按月过期为月,只有在以上两种情况时有效 +`Date`|`date`|`CorpVacationConfDate`| 失效日期,只有按固定时间过期时有效 +`ExternDurationEnable`|`extern_duration_enable`|`bool`| 是否允许延长有效期 +`ExternDuration`|`extern_duration`|`CorpVacationConfDate`| 延长有效期的具体时间,只有在extern_duration_enable为true时有效 + +### `CorpVacationConfDate` 企业假期管理配置-失效日期 + +Name|JSON|Type|Doc +:---|:---|:-------------|:-- +`Month`|`month`|`uint32`| 月份 +`Day`|`day`|`uint32`| 日 + +### `UserVacationQuota` 假期列表 + +Name|JSON|Type|Doc +:---|:---|:-------------|:-- +`ID`|`id`|`uint32`| 假期id +`AssignDuration`|`assignduration`|`uint32`| 发放时长,单位为秒 +`UsedDuration`|`usedduration`|`uint32`| 使用时长,单位为秒 +`LeftDuration`|`leftduration`|`uint32`| 剩余时长,单位为秒 +`VacationName`|`vacationname`|`string`| 假期名称 +`RealAssignDuration`|`real_assignduration`|`uint32`| 假期的实际发放时长,通常在设置了按照实际工作时间发放假期后进行计算 diff --git a/errcodes/mod.go b/errcodes/mod.go index 15b375f..1ffb12f 100644 --- a/errcodes/mod.go +++ b/errcodes/mod.go @@ -5,7 +5,7 @@ package errcodes // ErrCode 错误码类型 // // 全局错误码文档: https://developer.work.weixin.qq.com/document/path/90313 -// 文档爬取时间: 2024-02-26 16:40:36 +0800 +// 文档爬取时间: 2024-02-27 13:07:17 +0800 // // NOTE: 关于错误码的名字为何如此无聊: // diff --git a/models.go b/models.go index fab42e0..4bb83ed 100644 --- a/models.go +++ b/models.go @@ -1250,11 +1250,11 @@ type Button struct { Type int `json:"type,omitempty"` // 按钮文案,建议不超过10个字 Text string `json:"text"` - //按钮样式,目前可填1~4,不填或错填默认1 + // 按钮样式,目前可填1~4,不填或错填默认1 Style int `json:"style,omitempty"` // 按钮key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复,button_list.type是0时必填 Key string `json:"key,omitempty"` - //跳转事件的url,button_list.type是1时必填 + // 跳转事件的url,button_list.type是1时必填 URL string `json:"url,omitempty"` } @@ -1910,3 +1910,58 @@ type respKfSyncMsg struct { HasMore int `json:"has_more"` MsgList []KfMsg `json:"msg_list"` } + +// reqOAGetCorpVacationConf 获取企业假期管理配置 +type reqOAGetCorpVacationConf struct { +} + +var _ urlValuer = reqOAGetCorpVacationConf{} + +func (x reqOAGetCorpVacationConf) intoURLValues() url.Values { + return url.Values{} +} + +// respOAGetCorpVacationConf 获取企业假期管理配置 响应 +type respOAGetCorpVacationConf struct { + respCommon + // Lists 假期列表 + Lists []CorpVacationConf `json:"lists"` +} + +// reqOAGetUserVacationQuota 获取成员假期余额 +type reqOAGetUserVacationQuota struct { + UserID string `json:"userid"` +} + +var _ bodyer = reqOAGetUserVacationQuota{} + +func (x reqOAGetUserVacationQuota) intoBody() ([]byte, error) { + return marshalIntoJSONBody(x) +} + +// respOAGetUserVacationQuota 获取成员假期余额 响应 +type respOAGetUserVacationQuota struct { + respCommon + // Lists 假期列表 + Lists []UserVacationQuota `json:"lists"` +} + +// reqOASetOneUserVacationQuota 修改成员假期余额 +type reqOASetOneUserVacationQuota struct { + UserID string `json:"userid"` + VacationID string `json:"vacation_id"` + LeftDuration string `json:"leftduration"` + TimeAttr int64 `json:"time_attr"` + Remarks string `json:"remarks"` +} + +var _ bodyer = reqOASetOneUserVacationQuota{} + +func (x reqOASetOneUserVacationQuota) intoBody() ([]byte, error) { + return marshalIntoJSONBody(x) +} + +// respOASetOneUserVacationQuota 修改成员假期余额 响应 +type respOASetOneUserVacationQuota struct { + respCommon +} diff --git a/oa.go b/oa.go index 1eebc9d..5f99cad 100644 --- a/oa.go +++ b/oa.go @@ -53,6 +53,36 @@ func (c *WorkwxApp) GetOAApprovalDetail(spNo string) (*OAApprovalDetail, error) return &resp.Info, nil } +// GetOAGetCorpVacationConf 获取企业假期管理配置 +func (c *WorkwxApp) GetOAGetCorpVacationConf() ([]CorpVacationConf, error) { + resp, err := c.execOAGetCorpVacationConf(reqOAGetCorpVacationConf{}) + if err != nil { + return nil, err + } + return resp.Lists, nil +} + +// GetOAGetUserVacationQuota 获取成员假期余额 +func (c *WorkwxApp) GetOAGetUserVacationQuota(userID string) ([]UserVacationQuota, error) { + resp, err := c.execOAGetUserVacationQuota(reqOAGetUserVacationQuota{UserID: userID}) + if err != nil { + return nil, err + } + return resp.Lists, nil +} + +// GetOASetOneUserVacationQuota 修改成员假期余额 +func (c *WorkwxApp) GetOASetOneUserVacationQuota(req GetOASetOneUserVacationQuota) error { + _, err := c.execOASetOneUserVacationQuota(reqOASetOneUserVacationQuota{ + UserID: req.UserID, + VacationID: req.VacationID, + LeftDuration: req.LeftDuration, + TimeAttr: req.TimeAttr, + Remarks: req.Remarks, + }) + return err +} + // GetOAApprovalInfoReq 批量获取审批单号请求 type GetOAApprovalInfoReq struct { // StartTime 审批单提交的时间范围,开始时间,UNix时间戳 @@ -154,3 +184,12 @@ type OAApprovalInfoCommentUserInfo struct { // UserID 备注人userid UserID string `xml:"UserId"` } + +// GetOASetOneUserVacationQuota 修改成员假期余额 +type GetOASetOneUserVacationQuota struct { + UserID string + VacationID string + LeftDuration string + TimeAttr int64 + Remarks string +} diff --git a/oa.md.go b/oa.md.go index f895c61..dd2b98b 100644 --- a/oa.md.go +++ b/oa.md.go @@ -487,3 +487,99 @@ const OAApprovalInfoFilterKeyDepartment OAApprovalInfoFilterKey = "department" // OAApprovalInfoFilterKeySpStatus 审批状态 const OAApprovalInfoFilterKeySpStatus OAApprovalInfoFilterKey = "sp_status" + +// CorpVacationConf 企业假期管理配置 +type CorpVacationConf struct { + // ID 假期id + ID uint32 `json:"id"` + // Name 假期名称 + Name string `json:"name"` + // TimeAttr 假期时间刻度:0-按天请假;1-按小时请假 + TimeAttr uint32 `json:"time_attr"` + // DurationType 时长计算类型:0-自然日;1-工作日 + DurationType uint32 `json:"duration_type"` + // QuotaAttr 假期发放相关配置 + QuotaAttr CorpVacationConfQuotaAttr `json:"quota_attr"` + // PerdayDuration 单位换算值,即1天对应的秒数,可将此值除以3600得到一天对应的小时。 + PerdayDuration uint32 `json:"perday_duration"` + // IsNewovertime 是否关联加班调休,0-不关联,1-关联,关联后改假期类型变为调休假 + IsNewovertime *uint32 `json:"is_newovertime"` + // EnterCompTimeLimit 入职时间大于n个月可用该假期,单位为月 + EnterCompTimeLimit *uint32 `json:"enter_comp_time_limit"` + // ExpireRule 假期过期规则 + ExpireRule *CorpVacationConfExpireRule `json:"expire_rule"` +} + +// CorpVacationConfQuotaAttr 企业假期管理配置-假期发放相关配置 +type CorpVacationConfQuotaAttr struct { + // Type 假期发放类型:0-不限额;1-自动按年发放;2-手动发放;3-自动按月发放 + Type uint32 `json:"type"` + // AutoresetTime 自动发放时间戳,若假期发放为自动发放,此参数代表自动发放日期。注:返回时间戳的年份是无意义的,请只使用返回时间的月和日;若at_entry_date为true,该字段则无效,假期发放时间为员工入职时间 + AutoresetTime uint32 `json:"autoreset_time"` + // AutoresetDuration 自动发放时长,单位为秒。注:只有自动按年发放和自动按月发放时有效,若选择了按照工龄和司龄发放,该字段无效,发放时长请使用区间中的quota + AutoresetDuration uint32 `json:"autoreset_duration"` + // QuotaRuleType 额度计算类型,自动按年发放时有效,0-固定额度;1-按工龄计算;2-按司龄计算 + QuotaRuleType *uint32 `json:"quota_rule_type"` + // QuotaRules 额度计算规则,自动按年发放时有效 + QuotaRules *CorpVacationConfQuotaRules `json:"quota_rules"` + // AtEntryDate 是否按照入职日期发放假期,只有在自动按年发放类型有效,选择后发放假期的时间会成为员工入职的日期 + AtEntryDate *bool `json:"at_entry_date"` + // AutoResetMonthDay 自动按月发放的发放时间,只有自动按月发放类型有效 + AutoResetMonthDay *uint32 `json:"auto_reset_month_day"` +} + +// CorpVacationConfQuotaRules 企业假期管理配置-额度计算规则 +type CorpVacationConfQuotaRules struct { + // List 额度计算规则区间,只有在选择了按照工龄计算或者按照司龄计算时有效 + List []CorpVacationConfQuotaRule `json:"list"` +} + +// CorpVacationConfQuotaRule 企业假期管理配置-额度计算规则区间 +type CorpVacationConfQuotaRule struct { + // Quota 区间发放时长,单位为s + Quota uint32 `json:"quota"` + // Begin 区间开始点,单位为年 + Begin uint32 `json:"begin"` + // End 区间结束点,无穷大则为0,单位为年 + End uint32 `json:"end"` + // BasedOnActualWorkTime 是否根据实际入职时间计算假期,选择后会根据员工在今年的实际工作时间发放假期 + BasedOnActualWorkTime bool `json:"based_on_actual_work_time"` +} + +// CorpVacationConfExpireRule 企业假期管理配置-假期过期规则 +type CorpVacationConfExpireRule struct { + // Type 过期规则类型,1-按固定时间过期,2-从发放日按年过期,3-从发放日按月过期,4-不过期 + Type uint32 `json:"type"` + // Duration 有效期,按年过期为年,按月过期为月,只有在以上两种情况时有效 + Duration uint64 `json:"duration"` + // Date 失效日期,只有按固定时间过期时有效 + Date CorpVacationConfDate `json:"date"` + // ExternDurationEnable 是否允许延长有效期 + ExternDurationEnable bool `json:"extern_duration_enable"` + // ExternDuration 延长有效期的具体时间,只有在extern_duration_enable为true时有效 + ExternDuration CorpVacationConfDate `json:"extern_duration"` +} + +// CorpVacationConfDate 企业假期管理配置-失效日期 +type CorpVacationConfDate struct { + // Month 月份 + Month uint32 `json:"month"` + // Day 日 + Day uint32 `json:"day"` +} + +// UserVacationQuota 假期列表 +type UserVacationQuota struct { + // ID 假期id + ID uint32 `json:"id"` + // AssignDuration 发放时长,单位为秒 + AssignDuration uint32 `json:"assignduration"` + // UsedDuration 使用时长,单位为秒 + UsedDuration uint32 `json:"usedduration"` + // LeftDuration 剩余时长,单位为秒 + LeftDuration uint32 `json:"leftduration"` + // VacationName 假期名称 + VacationName string `json:"vacationname"` + // RealAssignDuration 假期的实际发放时长,通常在设置了按照实际工作时间发放假期后进行计算 + RealAssignDuration uint32 `json:"real_assignduration"` +}