feat: add GetVacationQuota to AppCheckin

This commit is contained in:
jiangyong 2026-06-27 11:58:36 +08:00
parent 68cc3c14e6
commit 67e974de0e
1 changed files with 31 additions and 0 deletions

View File

@ -225,3 +225,34 @@ func (q *AppCheckin) GetCheckinDataV2(startDay, endDay string, userIds []string)
return userDatas, nil
}
type VacationQuota struct {
VacationName string `json:"vacation_name"`
LeftQuota int64 `json:"left_quota"`
UsedQuota int64 `json:"used_quota"`
TotalQuota int64 `json:"total_quota"`
}
func (q *AppCheckin) GetVacationQuota(userid string) ([]*VacationQuota, error) {
reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/checkin/getvacationquota?access_token=%s", q.GetToken())
reqParam := fmt.Sprintf(`{"userid":"%s"}`, userid)
rspBody, err := util.HttpPostJson(reqUrl, nil, []byte(reqParam))
if err != nil {
return nil, err
}
g := gjson.ParseBytes(rspBody)
if g.Get("errcode").Int() != 0 {
return nil, fmt.Errorf("%d:%s", g.Get("errcode").Int(), g.Get("errmsg").String())
}
items := make([]*VacationQuota, 0)
for _, v := range g.Get("lists").Array() {
item := &VacationQuota{
VacationName: v.Get("vacation_name").String(),
LeftQuota: v.Get("left_quota").Int(),
UsedQuota: v.Get("used_quota").Int(),
TotalQuota: v.Get("total_quota").Int(),
}
items = append(items, item)
}
return items, nil
}