-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.go
130 lines (111 loc) · 3.14 KB
/
api.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
package ministore
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"time"
)
// Exec ..
// func (c *Client) exec(url string, req interface{}, rsp interface{}) error {
// codec, err := json.Marshal(req)
// if err != nil {
// return err
// }
// resp, err := http.Post(url, "application/json",
// bytes.NewReader(codec))
// if err != nil {
// return err
// }
// defer resp.Body.Close()
// body, err := ioutil.ReadAll(resp.Body)
// if err != nil {
// return err
// }
// return json.Unmarshal(body, rsp)
// }
func (c *Client) CheckAuth(ctx context.Context, uri string, body io.Reader) (*http.Response, error) {
return c.client.post(ctx,uri,body)
}
//CheckAuthReq 登录验证
type CheckAuthReq struct {
Code string `json:"code"` //code string 是 跳转码(小商店服务市场跳转到第三方url里面会带上code)
}
//CheckAuthRsp ..
type CheckAuthRsp struct {
APPID string `json:"appid"`
ServiceID int `json:"service_id"`
}
// CheckAuthReq.Exec(req,resp)
// Response ..
type Response struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
Data interface{}
}
// Exec ..
func (c *CheckAuthReq) Exec(componentAccessToken string) (*CheckAuthRsp, error) {
url := fmt.Sprintf(serviceCheckAuthURI, componentAccessToken)
client.R().
return &CheckAuthRsp{}, nil
}
//ServiceListReq 获取用户购买的在有效期内的服务列表
type ServiceListReq struct {
Code string `json:"code"` //code string 是 跳转码(小商店服务市场跳转到第三方url里面会带上code)
}
//Service ..
type Service struct {
ServiceID string `json:"service_id"`
ServiceName string `json:"service_name"`
ExpireTime time.Time `json:"expire_time"`
ServiceType int `json:"service_type"`
}
// ServiceTypeProduct ..
const (
ServiceTypeProduct int = 2 + iota
ServiceTypOrder
ServiceTypLogistics
)
// Exec ..
func (c *ServiceListReq) Exec(accessToken string) ([]*Service, error) {
url := fmt.Sprintf(serviceListURI, accessToken)
fmt.Println(url)
var services []*Service
return services, nil
}
// ServiceOrderListReq 获取用户购买的服务列表
type ServiceOrderListReq struct {
StartCreateTime time.Time `json:"start_create_time"`
EndCreateTime time.Time `json:"end_create_time"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
// ServiceOrder 用户购买服务
type ServiceOrder struct {
ServiceOrderID int `json:"service_order_id"`
ServiceID int `json:"service_id"`
ServiceName string `json:"service_name"`
ExpireTime time.Time `json:"expire_time"`
ServiceType int `json:"service_type"`
SpecificationID string `json:"specification_id"`
TotalPrice float64 `json:"total_price"`
}
//CategoryListReq ..
type CategoryListReq struct {
ParentCatID int `json:"f_cat_id"`
}
// Exec ..
func (c *CategoryListReq) Exec(accessToken string) ([]*Category, error) {
url := fmt.Sprintf(serviceCheckAuthURI, accessToken)
fmt.Println(url)
//cat_list
var catList []*Category
return catList, nil
}
//Category ..
type Category struct {
CatID int `json:"cat_id"`
ParentCatID int `json:"f_cat_id"`
Name string `json:"name"`
}