enums.go
12.5 KB
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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
package domain
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
)
var (
ErrorNotFound = fmt.Errorf("没有此资源")
)
var (
GenerateMainTable OperationType = "GenerateMainTable" // 主表生成
SpiltMainTable OperationType = "SpiltMainTable" //主表拆分
AppendData OperationType = "AppendData" //数据追加
EditSubTable OperationType = "EditSubTable" //分表编辑
CopyTable OperationType = "CopyTable" //表复制
RowEdit OperationType = "RowEdit" // 编辑记录
DeleteTable OperationType = "DeleteTable" // 表删除
FileUpload OperationType = "FileUpload" // 文件上传
FileVerify OperationType = "FileVerify" // 文件校验
ExcelTableEdit OperationType = "ExcelTableEdit" // 文档表格编辑
CreateSchema OperationType = "CreateSchema" // 新增方案
CreateSubProcess OperationType = "CreateSubProcess" // 新增子过程
AddSetCondition OperationType = "AddSetCondition" // 新增条件判断
EditSetCondition OperationType = "EditSetCondition" // 编辑条件判断
DeleteSetCondition OperationType = "DeleteSetCondition" // 删除条件判断
AddSelectCondition OperationType = "AddSelectCondition" // 新增拆分规则
EditSelectCondition OperationType = "EditSelectCondition" // 编辑拆分规则
DeleteSelectCondition OperationType = "DeleteSelectCondition" // 删除拆分规则
CopyQuerySet OperationType = "CopyQuerySet" // 复制
RenameQuerySet OperationType = "RenameQuerySet" // 重命名
DeleteQuerySet OperationType = "DeleteQuerySet" // 删除
CreateFormula OperationType = "CreateFormula" // 新增公式
DeleteFormula OperationType = "DeleteFormula" // 删除公式
EditCalculateItem OperationType = "EditCalculateItem" // 编辑公式
EditCalculateTable OperationType = "EditCalculateTable" // 编辑计算表
EditCalculateSet OperationType = "EditCalculateSet" // 编辑计算集
UnKnown OperationType = "UnKnown" // 未知
)
var OperationTypeMap = map[string]string{
GenerateMainTable.ToString(): "主表生成",
SpiltMainTable.ToString(): "主表拆分",
AppendData.ToString(): "数据追加",
EditSubTable.ToString(): "分表编辑",
CopyTable.ToString(): "表复制",
RowEdit.ToString(): "编辑记录",
DeleteTable.ToString(): "表删除",
FileUpload.ToString(): "文件上传",
FileVerify.ToString(): "文件校验",
ExcelTableEdit.ToString(): "文档表格编辑",
CreateSchema.ToString(): "新增方案",
CreateSubProcess.ToString(): "新增子过程",
AddSetCondition.ToString(): "新增条件判断",
EditSetCondition.ToString(): "编辑条件判断",
DeleteSetCondition.ToString(): "删除条件判断",
AddSelectCondition.ToString(): "新增拆分规则",
EditSelectCondition.ToString(): "编辑拆分规则",
DeleteSelectCondition.ToString(): "删除拆分规则",
CopyQuerySet.ToString(): "复制",
RenameQuerySet.ToString(): "重命名",
DeleteQuerySet.ToString(): "删除",
CreateFormula.ToString(): "新增公式",
DeleteFormula.ToString(): "删除公式",
EditCalculateItem.ToString(): "编辑公式",
EditCalculateTable.ToString(): "编辑计算表",
EditCalculateSet.ToString(): "编辑计算集",
}
var (
VerifiedStepLog LogType = "VerifiedStepLog"
CommonLog LogType = "CommonLog"
QuerySetLog LogType = "QuerySetLog"
FormulaLog LogType = "FormulaLog"
)
var (
PKField int = 1 // 主键字段
MainTableField int = 2 // 主表字段
ManualField int = 3 // 手动添加
)
var (
MainTable TableType = "MainTable"
SideTable TableType = "SideTable"
SubTable TableType = "SubTable"
ExcelTable TableType = "ExcelTable"
TemporaryTable TableType = "TemporaryTable"
)
var (
SourceFile FileType = "SourceFile"
VerifiedFile FileType = "VerifiedFile"
TemporaryFile FileType = "TemporaryFile"
)
var ObjectTypeMap = map[string]string{
MainTable.ToString(): "主表",
SideTable.ToString(): "副表",
SubTable.ToString(): "分表",
SourceFile.ToString(): "源文件",
VerifiedFile.ToString(): "校验文件",
ObjectDBTable: "业务表",
SchemaTable.ToString(): "方案",
SubProcessTable.ToString(): "子过程",
CalculateItem.ToString(): "计算项",
CalculateTable.ToString(): "计算表",
CalculateSet.ToString(): "计算集",
}
var (
XLS = ".xls"
XLSX = ".xlsx"
)
var (
String SQLType = "STRING"
Int SQLType = "INT"
BigInt SQLType = "BIGINT"
Float SQLType = "FLOAT"
DECIMALV2 SQLType = "DECIMAL(35,15)" //"DECIMALV2"
DECIMAL279 SQLType = "DECIMAL(35,15)"
Date SQLType = "DATE"
Datetime SQLType = "DATETIME"
)
var SQLTypeMap = map[string]string{
String.ToString(): "文本",
Int.ToString(): "整数",
BigInt.ToString(): "整数",
Float.ToString(): "小数",
DECIMALV2.ToString(): "小数",
Date.ToString(): "日期",
Datetime.ToString(): "日期时间",
}
type FileType string
func (t FileType) ToString() string {
return string(t)
}
type LogType string
func (t LogType) ToString() string {
return string(t)
}
type TableType string
func (t TableType) ToString() string {
return string(t)
}
func (t TableType) TableStatusEditable() bool {
return t == SchemaTable || t == CalculateItem || t == CalculateTable || t == CalculateSet
}
func (t TableType) TableHasGroup() bool {
return t == SchemaTable || t == SubProcessTable || t == CalculateItem || t == CalculateTable || t == CalculateSet
}
type ObjectType TableType
type OperationType string
func (t OperationType) ToString() string {
return string(t)
}
type SQLType string
func (t SQLType) ToString() string {
return string(t)
}
func (t SQLType) IsString() bool {
if t == String {
return true
}
if t == Date {
return true
}
if t == Datetime {
return true
}
return false
}
func EnumsDescription(m map[string]string, key string) string {
if v, ok := m[key]; ok {
return v
}
return ""
}
func DownloadUrl(filename string) string {
return fmt.Sprintf("%v/%v/%v", constant.METADATA_BASTION_HOST, "static", filename)
}
var DBTables = map[int]*Table{
DBTableTableOperateLog.ToInt(): &Table{
TableId: 1,
TableType: ObjectDBTable,
Name: "日志信息",
SQLName: "metadata.logs",
DataFieldIndex: 6,
PK: &Field{
Index: 0,
Name: "日志ID",
SQLName: "log_id",
SQLType: Int.ToString(),
Flag: PKField,
},
DataFields: []*Field{
{
Index: 1,
Name: "数据表表名/文件名",
SQLName: "object_name",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 2,
Name: "类型",
SQLName: "object_type",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 3,
Name: "操作类型",
SQLName: "operation_type",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 4,
Name: "日志内容",
SQLName: "content",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 5,
Name: "操作时间",
SQLName: "log_time", //"created_at",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 6,
Name: "操作人",
SQLName: "operator_name",
SQLType: String.ToString(),
Flag: MainTableField,
},
},
},
DBTableQuerySetLog.ToInt(): &Table{
TableId: 2,
TableType: ObjectDBTable,
Name: "日志信息",
SQLName: "metadata.logs",
DataFieldIndex: 6,
PK: &Field{
Index: 0,
Name: "日志ID",
SQLName: "log_id",
SQLType: Int.ToString(),
Flag: PKField,
},
DataFields: []*Field{
{
Index: 1,
Name: "方案/子过程",
SQLName: "object_name",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 2,
Name: "类型",
SQLName: "object_type",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 3,
Name: "操作类型",
SQLName: "operation_type",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 4,
Name: "日志内容",
SQLName: "content",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 5,
Name: "操作时间",
SQLName: "log_time", //"created_at",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 6,
Name: "操作人",
SQLName: "operator_name",
SQLType: String.ToString(),
Flag: MainTableField,
},
},
},
DBTableFormulaLog.ToInt(): &Table{
TableId: 3,
TableType: ObjectDBTable,
Name: "日志信息",
SQLName: "metadata.logs",
DataFieldIndex: 6,
PK: &Field{
Index: 0,
Name: "日志ID",
SQLName: "log_id",
SQLType: Int.ToString(),
Flag: PKField,
},
DataFields: []*Field{
{
Index: 1,
Name: "公式名称",
SQLName: "object_name",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 2,
Name: "类型",
SQLName: "object_type",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 3,
Name: "操作类型",
SQLName: "operation_type",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 4,
Name: "日志内容",
SQLName: "content",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 5,
Name: "操作时间",
SQLName: "log_time", //"created_at",
SQLType: String.ToString(),
Flag: MainTableField,
},
{
Index: 6,
Name: "操作人",
SQLName: "operator_name",
SQLType: String.ToString(),
Flag: MainTableField,
},
},
},
}
type DBTable int
func (t DBTable) ToInt() int {
return int(t)
}
const (
DBTableTableOperateLog DBTable = 1
DBTableQuerySetLog DBTable = 2
DBTableFormulaLog DBTable = 3
)
const (
ObjectFile = "File"
ObjectMetaTable = "MetaTable"
ObjectDBTable = "DBTable"
)
type LogLevel string
const (
LevelInfo LogLevel = "info"
LevelError LogLevel = "error"
LevelWarn LogLevel = "warn"
)
func (t LogLevel) ToString() string {
return string(t)
}
const (
DefaultPkField = "id"
)
type Action struct {
// 操作名
Desc string `json:"desc"`
Name string `json:"name"`
}
const (
RemoveColumn = "remove-column"
CopyColumn = "copy-column"
RenameColumn = "rename-column"
ReplaceColumn = "replace-column"
ConvertColumnType = "convert-column-type"
FormatColumn = "format-column"
SplitColumn = "split-column"
ExtractColumn = "extract-column"
)
var MapActionCommon = map[string]Action{
// 常规
RemoveColumn: {
Desc: "删除列", Name: RemoveColumn,
},
CopyColumn: {
Desc: "复制列", Name: CopyColumn,
},
RenameColumn: {
Desc: "重命名", Name: RenameColumn,
},
ConvertColumnType: {
Desc: "数据类型更改", Name: ConvertColumnType,
},
}
var MapActionFormat = map[string]Action{
// 格式
"upper": {
Desc: "大写", Name: "upper",
},
"lower": {
Desc: "小写", Name: "lower",
},
"capitalize": {
Desc: "首字母大写", Name: "capitalize",
},
"f4": {
Desc: "删除列", Name: "cc",
},
"strip": {
Desc: "休整", Name: "strip",
},
}
var MapActionReplaceColumn = map[string]Action{
"add-prefix": {
Desc: "添加前缀", Name: "add-prefix",
},
"add-postfix": {
Desc: "添加后缀", Name: "add-postfix",
},
"remove-prefix": {
Desc: "去除前缀", Name: "remove-prefix",
},
"remove-postfix": {
Desc: "去除后缀", Name: "remove-postfix",
},
"remove-chars": {
Desc: "去除固定字符", Name: "remove-chars",
},
"replace": {
Desc: "替换值", Name: "replace",
},
"clean": {
Desc: "清除", Name: "clean",
},
}
var MapActionSplitColumn = map[string]Action{
"separator": {
Desc: "按按分隔符拆分", Name: "separator",
},
"char-length": {
Desc: "按字符数拆分", Name: "char-length",
},
}
var MapActionExtractColumn = map[string]Action{
"by-date": {
Desc: "按日期提取", Name: "by-date",
},
"by-number": {
Desc: "按数值提取", Name: "by-number",
},
}
const (
StatusOn = 1
StatusOff = 2
)
const (
ModuleAll = ModuleDigitalCenter | ModuleQuerySetCenter | ModuleCalculateCenter
ModuleDigitalCenter = 1
ModuleQuerySetCenter = 2
ModuleCalculateCenter = 4
)