Skip to content

Commit

Permalink
feat: 企业微信-打卡-月报数据
Browse files Browse the repository at this point in the history
  • Loading branch information
hellolxc committed Oct 9, 2023
1 parent e8c430e commit aea2223
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
7 changes: 4 additions & 3 deletions doc/api/work.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
71 changes: 71 additions & 0 deletions work/checkin/checkin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}

0 comments on commit aea2223

Please sign in to comment.