-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathedu_living.go
154 lines (142 loc) · 4.54 KB
/
edu_living.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package wework
import (
"github.com/go-laoji/wecom-go-sdk/v2/internal"
)
type GetUserAllLivingIdRequest struct {
UserId string `json:"userid" validate:"required"`
Cursor string `json:"cursor,omitempty"`
Limit int `json:"limit"`
}
type GetUserAllLivingIdResponse struct {
internal.BizResponse
NextCursor string `json:"next_cursor"`
LivingIdList []string `json:"livingid_list"`
}
// GetUserAllLivingId 获取老师直播ID列表
// https://open.work.weixin.qq.com/api/doc/90001/90143/93856
func (ww *weWork) GetUserAllLivingId(corpId uint, request GetUserAllLivingIdRequest) (resp GetUserAllLivingIdResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/living/get_user_all_livingid")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type GetLivingInfoResponse struct {
internal.BizResponse
LivingInfo struct {
Theme string `json:"theme"`
LivingStart int `json:"living_start"`
LivingDuration int `json:"living_duration"`
AnchorUserId string `json:"anchor_userid"`
LivingRange struct {
PartyIds []int `json:"partyids"`
GroupNames []string `json:"group_names"`
} `json:"living_range"`
ViewerNum int `json:"viewer_num"`
CommentNum int `json:"comment_num"`
OpenReplay int `json:"open_replay"`
PushStreamURL string `json:"push_stream_url"`
} `json:"living_info"`
}
// GetLivingInfo 获取直播详情
// https://open.work.weixin.qq.com/api/doc/90001/90143/93857
func (ww *weWork) GetLivingInfo(corpId uint, liveId string) (resp GetLivingInfoResponse) {
_, err := ww.getRequest(corpId).SetResult(&resp).
SetQueryParam("livingid", liveId).Get("/cgi-bin/school/living/get_living_info")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type GetWatchStatRequest struct {
LivingId string `json:"livingid" validate:"required"`
NextKey string `json:"next_key"`
}
type GetWatchStatResponse struct {
internal.BizResponse
Ending int `json:"ending"`
NextKey string `json:"next_key"`
StatInfoes struct {
Students []struct {
StudentUserid string `json:"student_userid"`
ParentUserid string `json:"parent_userid"`
Partyids []int `json:"partyids"`
WatchTime int `json:"watch_time"`
EnterTime int `json:"enter_time"`
LeaveTime int `json:"leave_time"`
IsComment int `json:"is_comment"`
} `json:"students"`
Visitors []struct {
Nickname string `json:"nickname"`
WatchTime int `json:"watch_time"`
EnterTime int `json:"enter_time"`
LeaveTime int `json:"leave_time"`
IsComment int `json:"is_comment"`
} `json:"visitors"`
} `json:"stat_infoes"`
}
// GetWatchStat 获取观看直播统计
// https://open.work.weixin.qq.com/api/doc/90001/90143/93858
func (ww *weWork) GetWatchStat(corpId uint, request GetWatchStatRequest) (resp GetWatchStatResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/school/living/get_watch_stat")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type GetUnWatchStatResponse struct {
internal.BizResponse
Ending int `json:"ending"`
NextKey string `json:"next_key"`
StatInfo struct {
Students []struct {
StudentUserid string `json:"student_userid"`
ParentUserid string `json:"parent_userid"`
Partyids []int `json:"partyids"`
} `json:"students"`
} `json:"stat_info"`
}
// GetUnWatchStat 获取未观看直播统计
// https://open.work.weixin.qq.com/api/doc/90001/90143/93859
func (ww *weWork) GetUnWatchStat(corpId uint, request GetWatchStatRequest) (resp GetUnWatchStatResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/school/living/get_unwatch_stat")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
// DeleteReplayData 删除直播回放
// https://open.work.weixin.qq.com/api/doc/90001/90143/93860
func (ww *weWork) DeleteReplayData(corpId uint, livingId string) (resp internal.BizResponse) {
h := H{}
h["livingid"] = livingId
_, err := ww.getRequest(corpId).SetBody(h).SetResult(&resp).
Post("/cgi-bin/living/delete_replay_data")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}