forked from l306287405/wechat3rd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory.go
163 lines (147 loc) · 5.13 KB
/
category.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
155
156
157
158
159
160
161
162
163
package wechat3rd
import "github.com/l306287405/wechat3rd/core"
type GetAllCategoryResp struct {
core.Error
CategoriesList struct {
Categories []*AllCategory `json:"categories"`
} `json:"categories_list"` //类目信息列表
}
type AllCategory struct {
Id int `json:"id"`
Name string `json:"name,omitempty"`
Level int `json:"level,omitempty"`
Father int `json:"father,omitempty"`
Children []int `json:"children,omitempty"`
SensitiveType int8 `json:"sensitive_type,omitempty"`
Qualify struct {
ExterList []*struct {
InnerList []*struct {
Name string `json:"name"`
Url string `json:"url"`
} `json:"inner_list"`
} `json:"exter_list"`
} `json:"qualify,omitempty"`
}
// 获取可以设置的所有类目
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/getallcategories.html
func (s *Server) GetMiniProgramAllCategory(authorizerAccessToken string) (resp *GetAllCategoryResp) {
var (
u = CGIUrl + "/wxopen/getallcategories?"
)
resp = &GetAllCategoryResp{}
resp.Err(core.GetRequest(u, core.AuthTokenUrlValues(authorizerAccessToken), resp))
return
}
type GetCategoryResp struct {
core.Error
Categories []*struct {
First int `json:"first"`
FirstName string `json:"first_name"`
Second int `json:"second"`
SecondName string `json:"second_name"`
AuditStatus int `json:"audit_status"`
AuditReason string `json:"audit_reason"`
}
Limit int `json:"limit"`
Quota int `json:"quota"`
CategoryLimit int `json:"category_limit"`
}
// 获取已设置的所有类目
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/getcategory.html
func (s *Server) GetMiniProgramCategory(authorizerAccessToken string) (resp *GetCategoryResp) {
var (
u = CGIUrl + "/wxopen/getcategory?"
)
resp = &GetCategoryResp{}
resp.Err(core.GetRequest(u, core.AuthTokenUrlValues(authorizerAccessToken), resp))
return
}
type GetCategoriesByTypeResp struct {
core.Error
CategoriesList struct {
Categories []*Category `json:"categories"`
} `json:"categories_list"` //类目信息列表
}
// 获取不同主体类型的类目
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/getcategorybytype.html
func (s *Server) GetMiniProgramCategoriesByType(authorizerAccessToken string, verifyType ...int8) (resp *GetCategoriesByTypeResp) {
var (
u = CGIUrl + "/wxopen/getcategoriesbytype?"
req = &struct {
VerifyType int8 `json:"verify_type"`
}{}
)
resp = &GetCategoriesByTypeResp{}
if verifyType != nil {
req.VerifyType = verifyType[0]
}
resp.Err(core.PostJson(s.AuthToken2url(u, authorizerAccessToken), req, resp))
return
}
type Categories struct {
First int `json:"first"`
Second int `json:"second"`
Certicates []*CategoryCertCate `json:"certicates"`
}
type CategoryCertCate struct {
Key string `json:"key"`
Value string `json:"value"`
}
// 添加类目
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/addcategory.html
func (s *Server) AddMiniProgramCategory(authorizerAccessToken string, categories []*Categories) (resp *core.Error) {
var (
u = CGIUrl + "/wxopen/addcategory?"
req = &struct {
Categories []*Categories `json:"categories"`
}{Categories: categories}
)
resp = &core.Error{}
resp.Err(core.PostJson(s.AuthToken2url(u, authorizerAccessToken), req, resp))
return
}
type DeleteCategoryReq struct {
First int `json:"first"`
Second int `json:"second"`
}
// 删除类目
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/deletecategory.html
func (s *Server) DeleteMiniProgramCategory(authorizerAccessToken string, req *DeleteCategoryReq) (resp *core.Error) {
var (
u = CGIUrl + "/wxopen/deletecategory?"
)
resp = &core.Error{}
resp.Err(core.PostJson(s.AuthToken2url(u, authorizerAccessToken), req, resp))
return
}
// 修改类目资质信息
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/modifycategory.html
func (s *Server) ModifyMiniProgramCategory(authorizerAccessToken string, categories *Categories) (resp *core.Error) {
var (
u = CGIUrl + "/wxopen/modifycategory?"
)
resp = &core.Error{}
resp.Err(core.PostJson(s.AuthToken2url(u, authorizerAccessToken), categories, resp))
return
}
type CategoriesResp struct {
core.Error
CategoryList []*struct {
FirstClass string `json:"first_class"`
FirstId int `json:"first_id"`
SecondClass string `json:"second_class"`
SecondId int `json:"second_id"`
ThirdClass *string `json:"third_class,omitempty"`
ThirdId *int `json:"third_id,omitempty"`
} `json:"category_list"`
}
// 获取审核时可填写的类目信息
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/get_category.html
func (s *Server) GetMiniProgramAuditCategory(authorizerAccessToken string) (resp *CategoriesResp) {
var (
u = WECHAT_API_URL + "/wxa/get_category?"
)
resp = &CategoriesResp{}
resp.Err(core.GetRequest(u, core.AuthTokenUrlValues(authorizerAccessToken), resp))
return
}