From aea22236bef7549e40feb395520ac422860feb54 Mon Sep 17 00:00:00 2001 From: Thinker Date: Mon, 9 Oct 2023 14:55:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1-?= =?UTF-8?q?=E6=89=93=E5=8D=A1-=E6=9C=88=E6=8A=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/api/work.md | 7 ++-- work/checkin/checkin.go | 71 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/doc/api/work.md b/doc/api/work.md index 2c3be66cd..3be65c7f3 100644 --- a/doc/api/work.md +++ b/doc/api/work.md @@ -120,9 +120,10 @@ host: https://qyapi.weixin.qq.com/ [官方文档](https://developer.work.weixin.qq.com/document/path/96497) -| 名称 | 请求方式 | URL | 是否已实现 | 使用方法 | 贡献者 | -| ---------------- | -------- | --------------------- | ---------- | -------------------------- |---------| -| 获取打卡日报数据 | POST | /cgi-bin/checkin/getcheckin_daydata | YES | (r *Client) GetDayData | Thinker | +| 名称 | 请求方式 | URL | 是否已实现 | 使用方法 | 贡献者 | +|----------| -------- | --------------------- | ---------- | -------------------------- |---------| +| 获取打卡日报数据 | POST | /cgi-bin/checkin/getcheckin_daydata | YES | (r *Client) GetDayData | Thinker | +| 获取打卡月报数据 | POST | /cgi-bin/checkin/getcheckin_monthdata | YES | (r *Client) GetMonthData | Thinker | ## 应用管理 TODO diff --git a/work/checkin/checkin.go b/work/checkin/checkin.go index 1416cce90..ffcbd8907 100644 --- a/work/checkin/checkin.go +++ b/work/checkin/checkin.go @@ -11,6 +11,8 @@ const ( getCheckinDataURL = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token=%s" // getDayDataURL 获取打卡日报数据 getDayDataURL = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckin_daydata?access_token=%s" + // getMonthDataURL 获取打卡月报数据 + getMonthDataURL = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckin_monthdata?access_token=%s" ) type ( @@ -190,3 +192,72 @@ func (r *Client) GetDayData(req *GetCheckinDataRequest) (result *GetDayDataRespo } return } + +type ( + // GetMonthDataResponse 获取打卡月报数据 + GetMonthDataResponse struct { + util.CommonError + Datas []MonthDataItem `json:"datas"` + } + + MonthDataItem struct { + BaseInfo MonthBaseInfo `json:"base_info"` + SummaryInfo MonthSummaryInfo `json:"summary_info"` + ExceptionInfos []ExceptionInfo `json:"exception_infos"` + SpItems []SpItem `json:"sp_items"` + OverWorkInfo OverWorkInfo `json:"overwork_info"` + } + + // MonthBaseInfo 基础信息 + MonthBaseInfo struct { + RecordType int64 `json:"record_type"` + Name string `json:"name"` + NameEx string `json:"name_ex"` + DepartsName string `json:"departs_name"` + AcctId string `json:"acctid"` + RuleInfo MonthRuleInfo `json:"rule_info"` + } + + // MonthRuleInfo 打卡人员所属规则信息 + MonthRuleInfo struct { + GroupId int64 `json:"groupid"` + GroupName string `json:"groupname"` + } + + // MonthSummaryInfo 汇总信息 + MonthSummaryInfo struct { + WorkDays int64 `json:"work_days"` + ExceptDays int64 `json:"except_days"` + RegularDays int64 `json:"regular_days"` + RegularWorkSec int64 `json:"regular_work_sec"` + StandardWorkSec int64 `json:"standard_work_sec"` + } + + // OverWorkInfo 加班情况 + OverWorkInfo struct { + WorkdayOverSec int64 `json:"workday_over_sec"` + HolidayOverSec int64 `json:"holidays_over_sec"` + RestDayOverSec int64 `json:"restdays_over_sec"` + } +) + +// GetMonthData 获取打卡月报数据 +// @see https://developer.work.weixin.qq.com/document/path/96499 +func (r *Client) GetMonthData(req *GetCheckinDataRequest) (result *GetMonthDataResponse, err error) { + var ( + response []byte + accessToken string + ) + if accessToken, err = r.GetAccessToken(); err != nil { + return + } + if response, err = util.PostJSON(fmt.Sprintf(getMonthDataURL, accessToken), req); err != nil { + return + } + + result = new(GetMonthDataResponse) + if err = util.DecodeWithError(response, result, "GetMonthData"); err != nil { + return + } + return +}