mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 12:52:27 +08:00
feat: Add Checkin (#719)
* feat: Add Checkin - Implement 'getcheckindata' API * refactor: Change variable names * refactor: Change struct name
This commit is contained in:
69
work/checkin/checkin.go
Normal file
69
work/checkin/checkin.go
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package checkin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/silenceper/wechat/v2/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// getCheckinDataURL 获取打卡记录数据
|
||||||
|
getCheckinDataURL = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token=%s"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// GetCheckinDataRequest 获取打卡记录数据请求
|
||||||
|
GetCheckinDataRequest struct {
|
||||||
|
OpenCheckinDataType int64 `json:"opencheckindatatype"`
|
||||||
|
StartTime int64 `json:"starttime"`
|
||||||
|
EndTime int64 `json:"endtime"`
|
||||||
|
UserIDList []string `json:"useridlist"`
|
||||||
|
}
|
||||||
|
// GetCheckinDataResponse 获取打卡记录数据响应
|
||||||
|
GetCheckinDataResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
CheckinData []*GetCheckinDataItem `json:"checkindata"`
|
||||||
|
}
|
||||||
|
// GetCheckinDataItem 打卡记录数据
|
||||||
|
GetCheckinDataItem struct {
|
||||||
|
UserID string `json:"userid"`
|
||||||
|
GroupName string `json:"groupname"`
|
||||||
|
CheckinType string `json:"checkin_type"`
|
||||||
|
ExceptionType string `json:"exception_type"`
|
||||||
|
CheckinTime int64 `json:"checkin_time"`
|
||||||
|
LocationTitle string `json:"location_title"`
|
||||||
|
LocationDetail string `json:"location_detail"`
|
||||||
|
WifiName string `json:"wifiname"`
|
||||||
|
Notes string `json:"notes"`
|
||||||
|
WifiMac string `json:"wifimac"`
|
||||||
|
MediaIDs []string `json:"mediaids"`
|
||||||
|
SchCheckinTime int64 `json:"sch_checkin_time"`
|
||||||
|
GroupID int64 `json:"groupid"`
|
||||||
|
ScheduleID int64 `json:"schedule_id"`
|
||||||
|
TimelineID int64 `json:"timeline_id"`
|
||||||
|
Lat int64 `json:"lat,omitempty"`
|
||||||
|
Lng int64 `json:"lng,omitempty"`
|
||||||
|
DeviceID string `json:"deviceid,omitempty"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetCheckinData 获取打卡记录数据
|
||||||
|
// @see https://developer.work.weixin.qq.com/document/path/90262
|
||||||
|
func (r *Client) GetCheckinData(req *GetCheckinDataRequest) (*GetCheckinDataResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(getCheckinDataURL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &GetCheckinDataResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "GetCheckinData"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
17
work/checkin/client.go
Normal file
17
work/checkin/client.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package checkin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/silenceper/wechat/v2/work/context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Client 打卡接口实例
|
||||||
|
type Client struct {
|
||||||
|
*context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClient 初始化实例
|
||||||
|
func NewClient(ctx *context.Context) *Client {
|
||||||
|
return &Client{
|
||||||
|
ctx,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/silenceper/wechat/v2/credential"
|
"github.com/silenceper/wechat/v2/credential"
|
||||||
"github.com/silenceper/wechat/v2/work/addresslist"
|
"github.com/silenceper/wechat/v2/work/addresslist"
|
||||||
"github.com/silenceper/wechat/v2/work/appchat"
|
"github.com/silenceper/wechat/v2/work/appchat"
|
||||||
|
"github.com/silenceper/wechat/v2/work/checkin"
|
||||||
"github.com/silenceper/wechat/v2/work/config"
|
"github.com/silenceper/wechat/v2/work/config"
|
||||||
"github.com/silenceper/wechat/v2/work/context"
|
"github.com/silenceper/wechat/v2/work/context"
|
||||||
"github.com/silenceper/wechat/v2/work/externalcontact"
|
"github.com/silenceper/wechat/v2/work/externalcontact"
|
||||||
@@ -85,3 +86,8 @@ func (wk *Work) GetAppChat() *appchat.Client {
|
|||||||
func (wk *Work) GetInvoice() *invoice.Client {
|
func (wk *Work) GetInvoice() *invoice.Client {
|
||||||
return invoice.NewClient(wk.ctx)
|
return invoice.NewClient(wk.ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCheckin 获取打卡接口实例
|
||||||
|
func (wk *Work) GetCheckin() *checkin.Client {
|
||||||
|
return checkin.NewClient(wk.ctx)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user