-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdomain.go
179 lines (159 loc) · 7.21 KB
/
domain.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
* Copyright icp-filing Author(https://houseme.github.io/icp-filing/). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* You can obtain one at https://github.com/houseme/icp-filing.
*/
package filling
import (
"encoding/json"
"strconv"
)
// QueryRequest query request
type QueryRequest struct {
PageNum string `json:"pageNum"`
PageSize string `json:"pageSize"`
UnitName string `json:"unitName" description:"unit name"`
Link string `json:"link,omitempty" description:"link"`
ServiceType int `json:"serviceType" description:"serviceType:1 网站,6 APP,7 小程序,8 快应用"`
}
// String return query request string
func (r *QueryRequest) String() string {
return `{"pageNum": "` + r.PageNum + `", "pageSize": "` + r.PageSize + `", "unitName": "` + r.UnitName + `","link": "` + r.Link + `", "serviceType": ` + strconv.Itoa(r.ServiceType) + `}`
}
// QueryResponse query response
type QueryResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Success bool `json:"success"`
Params *QueryParams `json:"params"`
}
// String return query response string
func (r *QueryResponse) String() string {
return `{"code": ` + strconv.Itoa(r.Code) + `, "msg": "` + r.Msg + `", "success": ` + strconv.FormatBool(r.Success) + `, "params": ` + r.Params.String() + `}`
}
// AuthParams auth params
type AuthParams struct {
Business string `json:"bussiness"`
Expire int64 `json:"expire"`
Refresh string `json:"refresh"`
}
// QueryParams query params
type QueryParams struct {
EndRow int `json:"endRow"`
FirstPage int `json:"firstPage"`
HasNextPage bool `json:"hasNextPage"`
HasPreviousPage bool `json:"hasPreviousPage"`
IsFirstPage bool `json:"isFirstPage"`
IsLastPage bool `json:"isLastPage"`
LastPage int `json:"lastPage"`
List []*DomainInfo `json:"list"`
NavigatePages int `json:"navigatePages"`
NavigatePageNums []int `json:"navigatepageNums"`
NextPage int `json:"nextPage"`
PageNum int `json:"pageNum"`
PageSize int `json:"pageSize"`
Pages int `json:"pages"`
PrePage int `json:"prePage"`
Size int `json:"size"`
StartRow int `json:"startRow"`
Total int `json:"total"`
}
// String return query params string
func (r *QueryParams) String() string {
return `{"endRow": ` + strconv.Itoa(r.EndRow) + `, "firstPage": ` + strconv.Itoa(r.FirstPage) + `, "hasNextPage": ` + strconv.FormatBool(r.HasNextPage) + `, "hasPreviousPage": ` + strconv.FormatBool(r.HasPreviousPage) + `, "isFirstPage": ` + strconv.FormatBool(r.IsFirstPage) + `, "isLastPage": ` + strconv.FormatBool(r.IsLastPage) + `, "lastPage": ` + strconv.Itoa(r.LastPage) + `, "list": ` + r.ParamsListString() + `, "navigatePages": ` + strconv.Itoa(r.NavigatePages) + `, "navigatepageNums": ` + r.NavigatePageNumsString() + `, "nextPage": ` + strconv.Itoa(r.NextPage) + `, "pageNum": ` + strconv.Itoa(r.PageNum) + `, "pageSize": ` + strconv.Itoa(r.PageSize) + `, "pages": ` + strconv.Itoa(r.Pages) + `, "prePage": ` + strconv.Itoa(r.PrePage) + `, "size": ` + strconv.Itoa(r.Size) + `, "startRow": ` + strconv.Itoa(r.StartRow) + `, "total": ` + strconv.Itoa(r.Total) + `}`
}
// NavigatePageNumsString Navigate Page Nums String
func (r *QueryParams) NavigatePageNumsString() string {
if r.NavigatePageNums == nil || len(r.NavigatePageNums) < 1 {
return ""
}
output, err := json.Marshal(r.NavigatePageNums)
if err != nil {
return ""
}
return string(output)
}
// ParamsListString return params list to string
func (r *QueryParams) ParamsListString() string {
if r.List == nil || len(r.List) < 1 {
return ""
}
output, err := json.Marshal(r.List)
if err != nil {
return ""
}
return string(output)
}
// DomainInfo domain info
type DomainInfo struct {
ContentTypeName string `json:"contentTypeName"`
Domain string `json:"domain"`
DomainID int64 `json:"domainId"`
HomeURL string `json:"homeUrl"`
LeaderName string `json:"leaderName"`
LimitAccess string `json:"limitAccess"`
MainID int64 `json:"mainId"`
MainLicence string `json:"mainLicence"`
NatureName string `json:"natureName"`
ServiceID int64 `json:"serviceId"`
ServiceLicence string `json:"serviceLicence"`
ServiceName string `json:"serviceName"`
UnitName string `json:"unitName"`
UpdateRecordTime string `json:"updateRecordTime"`
}
// String return domain info string
func (r *DomainInfo) String() string {
return `{"contentTypeName": "` + r.ContentTypeName + `", "domain": "` + r.Domain + `", "domainId": ` + strconv.FormatInt(r.DomainID, 10) + `, "homeUrl": "` + r.HomeURL + `", "leaderName": "` + r.LeaderName + `", "limitAccess": "` + r.LimitAccess + `", "mainId": ` + strconv.FormatInt(r.MainID, 10) + `, "mainLicence": "` + r.MainLicence + `", "natureName": "` + r.NatureName + `", "serviceId": ` + strconv.FormatInt(r.ServiceID, 10) + `, "serviceLicence": "` + r.ServiceLicence + `", "serviceName": "` + r.ServiceName + `", "unitName": "` + r.UnitName + `", "updateRecordTime": "` + r.UpdateRecordTime + `}`
}
// AuthorizeRequest authorize request
type AuthorizeRequest struct {
AuthKey string `json:"authKey"`
Timestamp string `json:"timeStamp"`
}
// String return authorizes request string
func (r *AuthorizeRequest) String() string {
return `{"authKey": "` + r.AuthKey + `", "timeStamp": "` + r.Timestamp + `"}`
}
// AuthorizeResponse authorize response
type AuthorizeResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Success bool `json:"success"`
Params *AuthParams `json:"params"`
}
// QueryResp is a struct for icp data
type QueryResp struct {
IcpNumber string `json:"icp_number"`
IcpName string `json:"icp_name"`
Attr string `json:"attr"`
Date string `json:"date"`
}
// ParamInput request params
type ParamInput struct {
AuthorizeRequest *AuthorizeRequest
QueryRequest *QueryRequest
Path string
ContentType string
}
// String request params string
func (r *ParamInput) String() string {
if r.QueryRequest == nil {
return `{"authorizeRequest": ` + r.AuthorizeRequest.String() + `, "path": "` + r.Path + `", "contentType": "` + r.ContentType + `"}`
}
if r.AuthorizeRequest == nil {
return `{"queryRequest": ` + r.QueryRequest.String() + `, "path": "` + r.Path + `", "contentType": "` + r.ContentType + `"}`
}
return `{"authorizeRequest": ` + r.AuthorizeRequest.String() + `, "queryRequest": ` + r.QueryRequest.String() + `, "path": "` + r.Path + `", "contentType": "` + r.ContentType + `"}`
}