-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathapi.go
164 lines (141 loc) · 3.94 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
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
package models
import (
"time"
)
//==============================================================================
// api models
//==============================================================================
const (
CodeOK = 0
CodeBadPermission = 1
CodeBadData = 2
CodeNoAuth = 3
CodeNoPermission = 4
CodeServerInternal = 5
CodeNoData = 6
CodeExpire = 7
RoleSuper = 0
RoleAdmin = 1
RoleNormal = 2
RoleGuest = 3
GODNS_RFI_KEY = "GODNSLOG"
GODNS_RFI_VALUE = "694ef536e5d0245f203a1bcf8cbf3294" // md5sum($GODNS_RFI_KEY)
)
type LoginRequest struct {
Email string `json:"email"`
Username string `json:"username"`
Password string `json:"password"`
}
type LoginResponse struct {
Islogin bool `json:"isLogin"`
Token string `json:"token"`
//TODO:
Username string `json:"username"`
RoleId string `json:"roleId"`
Lang string `json:"lang"`
}
type Role struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Permissions []Permission `json:"permissions"`
}
type PermissionActionSet struct {
Action string `json:"action"`
Description string `json:"description"`
DefaultCheck bool `json:"defaultCheck"`
}
type Permission struct {
RoleId int `json:"roleId"`
PermissionId string `json:"permissionId"`
PermissionName string `json:"permissionName"`
ActionEntitySet []PermissionActionSet `json:"ActionEntitySet"`
}
type UserInfo struct {
Id int64 `json:"id"`
Name string `json:"username"`
Email string `json:"email"`
Avatar string `json:"avatar"`
Language string `json:"lang"`
Role Role `json:"role"`
Utime time.Time `json:"utime"`
}
type UserRequest struct {
Id int64 `json:"id"`
Name string `json:"username"`
Email string `json:"email"`
Password string `json:"password"`
Role int `json:"role"`
Language string `json:"lang"`
}
type DnsRecordResp struct {
Pagination
Data []DnsRecord `json:"data"`
}
type HttpRecordResp struct {
Pagination
Data []HttpRecord `json:"data"`
}
type UserListResp struct {
Pagination
Data []UserInfo `json:"data"`
}
type AppSetting struct {
Callback string `json:"callback"`
CleanHour int64 `json:"cleanHour"`
Rebind []string `json:"rebind"`
}
type DeleteRecordRequest struct {
Ids []int64 `json:"ids"`
}
type AppSecurity struct {
Token string `json:"token"`
DnsAddr string `json:"dns_addr"`
HttpAddr string `json:"http_addr"`
}
type AppSecuritySet struct {
Password string `json:"password"`
}
type DnsRecord struct {
Id int64 `json:"id,omitempty"`
Uid int64 `json:"-"`
Callback string `json:"-"`
Var string `json:"-"`
Domain string `json:"domain"`
Ip string `json:"addr"`
Ctime time.Time `json:"ctime"`
}
type HttpRecord struct {
Id int64 `json:"id,omitempty"`
Uid int64 `json:"-"`
Callback string `json:"-"`
Path string `json:"path"`
Ip string `json:"addr"`
Method string `json:"method"`
Data string `json:"data"`
Ctype string `json:"ctype"`
Ua string `json:"ua"`
Ctime time.Time `json:"ctime"`
}
// commone response
type CR struct {
Message string `json:"message"`
Code int `json:"code"`
Error error `json:"error,omitempty"`
Timestamp int64 `json:"timestemp"`
Result interface{} `json:"result,omitempty"`
}
type Pagination struct {
PageNo int `json:"pageNo"`
PageSize int `json:"pageSize"`
TotalCount int `json:"totalCount"`
TotalPage int `json:"totalPage"`
}
type Resolve struct {
Id int64 `json:"id,omitempty"`
Host string `json:"host"` //host record, eg. www
Type string `json:"type"` //record type, eg. CNAME/A/MX/TXT/SRV/NS.
Value string `json:"value"`
Ttl uint32 `json:"ttl"`
Utimestamp int64 `json:"timestamp"`
}