convert.go
2.1 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
package bytelib
import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
)
func DomainFieldsToColumnSchemas(fields []*domain.Field) []domain.ColumnSchema {
result := make([]domain.ColumnSchema, 0)
for _, f := range fields {
res := domain.ColumnSchema{
ColumnName: f.Name,
ColumnType: f.SQLType,
ColumnSqlFriendlyName: f.SQLName,
}
if convertFiledSQLType(f.SQLType) {
res.ColumnType = domain.DECIMAL279.ToString()
}
result = append(result, res)
}
return result
}
func ToFieldSchemas(fields []*domain.Field) []FieldSchema {
result := make([]FieldSchema, 0)
for _, f := range fields {
res := FieldSchema{
FieldZhName: f.Name,
FieldEnName: f.SQLName,
FieldType: f.SQLType,
FieldDescription: f.Description,
IsAllowNull: true,
}
if convertFiledSQLType(f.SQLType) {
res.FieldType = domain.DECIMAL279.ToString()
}
result = append(result, res)
}
return result
}
func NewFieldSchema(f domain.TableField) FieldSchema {
var res = FieldSchema{
FieldZhName: f.FieldName,
FieldEnName: f.FieldSqlName,
FieldType: f.FieldSQLType,
FieldDescription: "",
IsAllowNull: true,
}
if convertFiledSQLType(f.FieldSQLType) {
res.FieldType = domain.DECIMAL279.ToString()
}
return res
}
func NewFieldSchemaFromField(f *domain.Field) FieldSchema {
var res = FieldSchema{
FieldZhName: f.Name,
FieldEnName: f.SQLName,
FieldType: f.SQLType,
FieldDescription: "",
IsAllowNull: true,
}
if convertFiledSQLType(f.SQLType) {
res.FieldType = domain.DECIMAL279.ToString()
}
return res
}
func convertFiledSQLType(sqlType string) bool {
if sqlType == domain.Float.ToString() || sqlType == domain.DECIMAL279.ToString() {
return true
}
return false
}
func FieldsToColumnSchemas(fields []*domain.Field) []domain.ColumnSchema {
result := make([]domain.ColumnSchema, 0)
for _, f := range fields {
result = append(result, domain.ColumnSchema{
ColumnName: f.Name,
ColumnType: f.SQLType,
ColumnSqlFriendlyName: f.SQLName,
})
}
return result
}