-
Notifications
You must be signed in to change notification settings - Fork 0
/
codelist.go
44 lines (37 loc) · 1.08 KB
/
codelist.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
/**
* Created by GoLand.
* User: 姜伟
* Date: 2020/1/11 0011
* Time: 15:07
*/
package codetemplate
import (
"github.com/a07061625/gompf/mpf"
"github.com/a07061625/gompf/mpf/api"
"github.com/a07061625/gompf/mpf/api/wx"
"github.com/a07061625/gompf/mpf/mpconstant/errorcode"
)
// 获取代码模版库中的所有小程序代码模版
type codeList struct {
wx.BaseWxOpen
}
func (cl *codeList) SendRequest() api.APIResult {
cl.ReqURI = "https://api.weixin.qq.com/wxa/gettemplatelist?access_token=" + wx.NewUtilWx().GetOpenAccessToken()
client, req := cl.GetRequest()
resp, result := cl.SendInner(client, req, errorcode.WxOpenRequestGet)
if resp.RespCode > 0 {
return result
}
respData, _ := mpf.JSONUnmarshalMap(resp.Content)
errCode, ok := respData["errcode"]
if ok && (errCode.(int) == 0) {
result.Data = respData
} else {
result.Code = errorcode.WxOpenRequestGet
result.Msg = respData["errmsg"].(string)
}
return result
}
func NewCodeList() *codeList {
return &codeList{wx.NewBaseWxOpen()}
}