@@ -18,9 +18,9 @@ type ParseTable struct {
18
18
PrimaryType string // 主键的类型,如:uint32, sql.NullString等
19
19
Imports []string // 需要import的包
20
20
SelectFields string // sql查询中的select fields
21
+ Msg string // 表结构的说明
21
22
Fields []ParseField
22
-
23
- QueryBy QueryBy // QueryBy函数,例如QueryById等
23
+ QueryBy QueryBy // QueryBy函数,例如QueryById等
24
24
}
25
25
26
26
// 字段的定义
@@ -46,6 +46,7 @@ func ParseTablesStruct(tables []Table, packageName string, modelsConf *JsonConf)
46
46
// 配置的预处理
47
47
var modelsConfMap = map [string ]map [string ]bool {} // 第一个下标是表名,第二个下标是字段名
48
48
var queryByConf = map [string ]string {} // 下标是表名,值是字段名,例如id。
49
+ var tableConfMsg = map [string ]string {} // 表的注释(在json文件中的)
49
50
if len (modelsConf .Tables ) > 0 {
50
51
for _ , tb := range modelsConf .Tables {
51
52
modelsConfMap [tb .Name ] = map [string ]bool {}
@@ -56,6 +57,8 @@ func ParseTablesStruct(tables []Table, packageName string, modelsConf *JsonConf)
56
57
if tb .QueryBy != "" {
57
58
queryByConf [tb .Name ] = tb .QueryBy
58
59
}
60
+
61
+ tableConfMsg [tb .Name ] = tb .Msg
59
62
}
60
63
}
61
64
@@ -66,6 +69,7 @@ func ParseTablesStruct(tables []Table, packageName string, modelsConf *JsonConf)
66
69
67
70
ptable := ParseTable {
68
71
Name : table .Name ,
72
+ Msg : tableConfMsg [table .Name ],
69
73
PackageName : packageName ,
70
74
}
71
75
ptable .Fields , ptable .Imports , ptable .PrimaryType = ParseFieldsStruct (table .Fields , modelsConfMap [table .Name ])
0 commit comments