-
Notifications
You must be signed in to change notification settings - Fork 0
/
struture.go
453 lines (362 loc) · 11.4 KB
/
struture.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
/*
creatTime: 2020/12/17
creator: JustKeepSilence
github: https://github.com/JustKeepSilence
goVersion: 1.16
*/
package db
import "github.com/JustKeepSilence/gdb/cmap"
/*
The data structure and errors returned by GDB
*/
const (
timeFormatString = "2006-01-02 15:04:05"
)
// structure
type Config struct {
GdbConfigs `json:"gdbConfigs"`
LogConfigs `json:"logConfigs"`
}
type GdbConfigs struct {
Port int64 `json:"port"`
DbPath string `json:"dbPath"`
ItemDbPath string `json:"itemDbPath"`
IP string `json:"ip"`
ApplicationName string `json:"applicationName"`
Authorization bool `json:"authorization"`
Mode string `json:"mode"`
HttpsConfigs `json:"httpsConfigs"`
}
type LogConfigs struct {
LogWriting bool `json:"logWriting"`
Level string `json:"level"`
ExpiredTime int `json:"expiredTime"`
}
type HttpsConfigs struct {
Ca bool `json:"ca"`
SelfSignedCa bool `json:"selfSignedCa"`
CaCertificateName string `json:"caCertificateName"`
ServerCertificateName string `json:"serverCertificateName"`
ServerKeyName string `json:"serverKeyName"`
}
// ResponseData common
type ResponseData struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
type Rows struct {
EffectedRows int `json:"effectedRows"`
}
type Cols struct {
EffectedCols int `json:"effectedCols"`
}
// groups
type AddedGroupInfo struct {
GroupName string `json:"groupName" binding:"required"`
ColumnNames []string `json:"columnNames" binding:"required"`
}
type AddedGroupInfos struct {
GroupInfos []AddedGroupInfo `json:"groupInfos" binding:"required"`
}
type GroupNamesInfo struct {
GroupNames []string `json:"groupNames"`
}
type GroupPropertyInfo struct {
ItemCount string `json:"itemCount"`
ItemColumnNames []string `json:"itemColumnNames"`
}
type queryGroupPropertyInfo struct {
GroupName string `json:"groupName" binding:"required"`
Condition string `json:"condition" binding:"required"`
}
type UpdatedGroupNameInfo struct {
OldGroupName string `json:"oldGroupName" binding:"required"`
NewGroupName string `json:"newGroupName" binding:"required"`
}
type UpdatedGroupNamesInfo struct {
Infos []UpdatedGroupNameInfo `json:"infos" binding:"required"`
}
type UpdatedGroupColumnNamesInfo struct {
GroupName string `json:"groupName" binding:"required"`
OldColumnNames []string `json:"oldColumnNames" binding:"required"`
NewColumnNames []string `json:"newColumnNames" binding:"required"`
}
type DeletedGroupColumnNamesInfo struct {
GroupName string `json:"groupName" binding:"required"`
ColumnNames []string `json:"columnNames" binding:"required"`
}
type AddedGroupColumnsInfo struct {
GroupName string `json:"groupName" binding:"required"`
ColumnNames []string `json:"columnNames" binding:"required"`
DefaultValues []string `json:"defaultValues" binding:"required"`
}
// items
type AddedItemsInfo struct {
GroupName string `json:"groupName" binding:"required"`
ItemValues []map[string]string `json:"itemValues" binding:"required"`
}
type DeletedItemsInfo struct {
GroupName string `json:"groupName"`
Condition string `json:"condition"`
}
type ItemsInfo struct {
GroupName string `json:"groupName" binding:"required"`
Condition string `json:"condition" binding:"required"`
ColumnNames string `json:"columnNames" binding:"required"`
StartRow int `json:"startRow"`
RowCount int `json:"rowCount"`
}
type UpdatedItemsInfo struct {
GroupName string `json:"groupName" binding:"required"`
Condition string `json:"condition" binding:"required"`
Clause string `json:"clause" binding:"required"`
}
type GdbItems struct {
ItemValues []map[string]string `json:"itemValues"`
}
type gdbItemsWithCount struct {
ItemCount int64 `json:"itemCount"`
GdbItems
}
type CheckItemsInfo struct {
GroupName string `json:"groupName"`
ItemNames []string `json:"itemNames"`
}
// data
type ItemValue struct {
GroupName string `json:"GroupName" binding:"required"`
ItemName string `json:"itemName" binding:"required"`
Value interface{} `json:"value" binding:"required"`
}
type HistoricalItemValue struct {
GroupName string `json:"groupName" binding:"required"`
ItemName string `json:"itemName" binding:"required"`
Values []interface{} `json:"values" binding:"required"`
TimeStamps []int `json:"timeStamps" binding:"required"`
}
type batchWriteString struct {
ItemValues []ItemValue `json:"itemValues" binding:"required"`
}
type batchWriteHistoricalString struct {
HistoricalItemValues []HistoricalItemValue `json:"historicalItemValues" binding:"required"`
}
type queryRealTimeDataString struct {
GroupNames []string `json:"groupNames"`
ItemNames []string `json:"itemNames"` // ItemNames
}
type gdbRealTimeData struct {
RealTimeData cmap.ConcurrentMap `json:"realTimeData"`
}
type queryHistoricalDataString struct {
GroupNames []string `json:"groupNames" binding:"required"`
ItemNames []string `json:"itemNames" binding:"required"` // ItemNames
StartTimes []int `json:"startTimes" binding:"required"` // startTime Unix TimeStamp
EndTimes []int `json:"endTimes" binding:"required"` // endTime Unix TimeStamp
Intervals []int `json:"intervals" binding:"required"` // interval
}
type querySpeedHistoryDataString struct {
ItemName string `json:"itemName" binding:"required"`
StartTimes []int `json:"startTimes" binding:"required"` // startTime Unix TimeStamp
EndTimes []int `json:"endTimes" binding:"required"` // endTime Unix TimeStamp
Intervals []int `json:"intervals" binding:"required"` // interval
}
type queryHistoricalDataWithTimeStampString struct {
GroupNames []string `json:"groupNames" binding:"required"`
ItemNames []string `json:"itemNames" binding:"required"` // ItemNames
TimeStamps [][]int `json:"timeStamps" binding:"required"` // time stamp
}
type DeadZone struct {
ItemName string `json:"itemName" binding:"required"`
DeadZoneCount int `json:"deadZoneCount" binding:"required"`
}
type queryHistoricalDataWithConditionString struct {
GroupNames []string `json:"groupNames" binding:"required"`
ItemNames []string `json:"itemNames" binding:"required"` // ItemNames
StartTimes []int `json:"startTimes" binding:"required"` // startTime Unix TimeStamp
EndTimes []int `json:"endTimes" binding:"required"` // endTime Unix TimeStamp
Intervals []int `json:"intervals" binding:"required"` // interval
FilterCondition string `json:"filterCondition" binding:"required"` // filter condition: item["itemNames1"] > 100
DeadZones []DeadZone `json:"deadZones"` // deadZone filter condition
}
type gdbHistoricalData struct {
HistoricalData cmap.ConcurrentMap `json:"historicalData"`
}
type gdbInfoData struct {
Info cmap.ConcurrentMap `json:"info"`
}
// page
type httpsFile struct {
File []int `json:"file" binding:"required"`
FileName string `json:"fileName" binding:"required"`
}
type authInfo struct {
UserName string `json:"userName"`
PassWord string `json:"passWord"`
}
type userToken struct {
Token string `json:"token"`
}
type userName struct {
Name string `json:"name" binding:"required"`
}
type userInfo struct {
UserName string `json:"userName" binding:"required"`
Role []string `json:"role" binding:"required"`
}
type updatedUserInfo struct {
UserName string `json:"userName" binding:"required"`
NewUserName string `json:"newUserName"`
NewPassWord string `json:"newPassWord"`
NewRole string `json:"newRole"`
}
type addedUserInfo struct {
Name string `json:"name" binding:"required"`
Role string `json:"role" binding:"required"`
PassWord string `json:"passWord" binding:"required"`
}
type queryLogsInfo struct {
Level string `json:"level" binding:"required"`
StartTime string `json:"startTime" binding:"required"`
EndTime string `json:"endTime" binding:"required"`
StartRow int `json:"startRow"`
RowCount int `json:"rowCount" binding:"required"`
Name string `json:"name" binding:"required"`
}
type logsInfo struct {
Infos []map[string]string `json:"infos"`
Count int `json:"count"`
}
type logMessage struct {
RequestUrl string `json:"requestUrl"`
RequestMethod string `json:"requestMethod"`
UserAgent string `json:"userAgent"`
RequestBody string `json:"requestBody"`
RemoteAddress string `json:"remoteAddress"`
Message string `json:"message"`
}
// calc
type addedCalcItemInfo struct {
Expression string `json:"expression" binding:"required"`
Flag string `json:"flag"`
Duration string `json:"duration" binding:"required"`
Description string `json:"description" binding:"required"`
}
type calculationResult struct {
Result interface{} `json:"result"`
}
type queryCalcItemsInfo struct {
Condition string `json:"condition"`
}
type calcItemsInfo struct {
Infos []map[string]string `json:"infos"`
}
type updatedCalcInfo struct {
Id string `json:"id"`
Description string `json:"description"`
Expression string `json:"expression"`
Duration string `json:"duration"`
UpdatedTime string
}
type calcId struct {
Id []string `json:"id"`
}
type calcConfig struct {
id int64 // calc item id
f func() error // function to invoke js code
expression string
status bool // whether to calc
duration int64
}
type messageCalcConfig struct {
updatedInfos []updatedInfo
addedInfos []calcConfig
}
type updatedInfo struct {
id string
newStatus bool
newDuration int64
updatedFiled string
f func() error
}
type fileInfo struct {
FileName string `json:"fileName" binding:"required"`
GroupName string `json:"groupName"`
}
type historyFileInfo struct {
GroupName string `json:"groupName" binding:"required"`
FileName string `json:"fileName" binding:"required"`
ItemNames []string `json:"itemNames" binding:"required"`
SheetNames []string `json:"sheetNames" binding:"required"`
}
type deletedLogInfo struct {
Id string `json:"id"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
UserNameCondition string `json:"userNameCondition"`
}
type routesInfo struct {
Name string `json:"name" binding:"required"`
Routes []string `json:"routes" binding:"required"`
}
// errors, some errors imported , some not
type conditionError struct {
ErrorInfo string
}
func (ce conditionError) Error() string {
return ce.ErrorInfo
}
type groupNameError struct {
ErrorInfo string
}
func (ge groupNameError) Error() string {
return ge.ErrorInfo
}
type columnNameError struct {
ErrorInfo string
}
func (cn columnNameError) Error() string {
return cn.ErrorInfo
}
type snError struct {
ErrorInfo string
}
func (se snError) Error() string {
return se.ErrorInfo
}
type itemError struct {
ErrorInfo string
}
func (ie itemError) Error() string {
return ie.ErrorInfo
}
type runTimeError struct {
ErrorInfo string
}
func (rt runTimeError) Error() string {
return rt.ErrorInfo
}
type excelError struct {
ErrorInfo string
}
func (oe excelError) Error() string {
return oe.ErrorInfo
}
type userNameError struct {
ErrorInfo string
}
func (un userNameError) Error() string {
return un.ErrorInfo
}
type connectionDBError struct {
ErrorInfo string
}
func (cd connectionDBError) Error() string {
return cd.ErrorInfo
}
type updateItemError struct {
ErrorInfo string
}
func (ui updateItemError) Error() string {
return ui.ErrorInfo
}