Skip to content

Commit 62473fd

Browse files
committed
reactor: modify tableName and tag name
1 parent 7fe625d commit 62473fd

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ gobatis-cmd -f configs/gobatis-conf.json
2020
"package": "test",
2121
"namespace": "test",
2222
"modelFile": "test_model.go",
23-
"tagName": "xfield",
23+
"tagName": "column",
2424
"mapperFile": "xml",
2525
"plugin": "",
2626
"keyword": false,
@@ -56,7 +56,7 @@ gobatis-cmd -driver=mysql -host=localhost -port=3306 -user=test -pw=test -db=tes
5656
-table string
5757
指定生成的table名称
5858
-tag string
59-
生成Model的tag名称,多tag用逗号分隔,如"json,xml" (default "xfield")
59+
生成Model的tag名称,多tag用逗号分隔,如"json,xml" (default "column")
6060
-user string
6161
数据库的用户名
6262
-mapper string
@@ -87,11 +87,11 @@ import (
8787
)
8888
8989
type TestTable struct {
90-
//TableName gobatis.ModelName `test_table`
91-
Id int `xfield:"id"`
92-
Username string `xfield:"username"`
93-
Password string `xfield:"password"`
94-
Createtime time.Time `xfield:"createtime"`
90+
//TableName gobatis.TableName `test_table`
91+
Id int `column:"id"`
92+
Username string `column:"username"`
93+
Password string `column:"password"`
94+
Createtime time.Time `column:"createtime"`
9595
}
9696
9797
func (m *TestTable) Select(sess *gobatis.Session) ([]TestTable, error) {

cmd/gobatis-cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
pw := flag.String("pw", "", "password of db")
4343
path := flag.String("path", "", "root path to save files")
4444
modelfile := flag.String("model", "", "the name of model file")
45-
tagName := flag.String("tag", "xfield", "the name of field tag,eg: xfield,json xfield,json,yaml")
45+
tagName := flag.String("tag", "column", "the name of field tag,eg: column,json column,json,yaml")
4646
mapper := flag.String("mapper", "xml", "generate mapper file: xml | template | go")
4747
plugin := flag.String("plugin", "", "path of plugin")
4848
keyword := flag.Bool("keyword", false, "with Keyword escape")

configs/gobatis-conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"package": "test",
55
"namespace": "test",
66
"modelFile": "test_model.go",
7-
"tagName": "xfield",
7+
"tagName": "column",
88
"mapperFile": "xml",
99
"plugin": "",
1010
"keyword": false,

pkg/generator/gen_model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func GenModel(config config.Config, tableName string, model []common.ModelInfo)
8888
builder.WriteString(common.Newline())
8989

9090
builder.WriteString(common.ColumnSpace())
91-
builder.WriteString(fmt.Sprintf("//TableName gobatis.ModelName `%s`", tableName))
91+
builder.WriteString(fmt.Sprintf("//TableName gobatis.TableName `%s`", tableName))
9292
builder.WriteString(common.Newline())
9393

9494
for _, info := range model {
@@ -160,7 +160,7 @@ func GenModel(config config.Config, tableName string, model []common.ModelInfo)
160160
}
161161

162162
const (
163-
defaultTag = "xfield"
163+
defaultTag = "column"
164164
)
165165

166166
func writeTag(b *strings.Builder, tagName, columnName string) string {

test/cmd_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestMode(t *testing.T) {
8383
config := config.Config{
8484
PackageName: "test_package",
8585
Path: "c:/tmp/",
86-
TagName: "xfield",
86+
TagName: "column",
8787
MapperFile: "xml",
8888
ModelFile: "model.go",
8989
}
@@ -95,7 +95,7 @@ func TestMode(t *testing.T) {
9595
config := config.Config{
9696
PackageName: "test_package",
9797
Path: "c:/tmp/",
98-
TagName: "xfield,json",
98+
TagName: "column,json",
9999
MapperFile: "xml",
100100
ModelFile: "model.go",
101101
}
@@ -107,7 +107,7 @@ func TestMode(t *testing.T) {
107107
config := config.Config{
108108
PackageName: "test_package",
109109
Path: "c:/tmp/",
110-
TagName: "xfield,json,",
110+
TagName: "column,json,",
111111
MapperFile: "xml",
112112
ModelFile: "model.go",
113113
}
@@ -131,7 +131,7 @@ func TestMode(t *testing.T) {
131131
config := config.Config{
132132
PackageName: "test_package",
133133
Path: "c:/tmp/",
134-
TagName: "xfield,json,xml",
134+
TagName: "column,json,xml",
135135
MapperFile: "xml",
136136
ModelFile: "model.go",
137137
}
@@ -145,7 +145,7 @@ func TestXml(t *testing.T) {
145145
config := config.Config{
146146
PackageName: "test_package",
147147
Path: "c:/tmp/",
148-
TagName: "xfield",
148+
TagName: "column",
149149
MapperFile: "xml",
150150
}
151151
generator.GenXml(config, "test_table", *createModeInfo())
@@ -155,7 +155,7 @@ func TestXml(t *testing.T) {
155155
config := config.Config{
156156
PackageName: "test_package",
157157
Path: "c:/tmp/",
158-
TagName: "xfield",
158+
TagName: "column",
159159
MapperFile: "xml",
160160
Driver: "mysql",
161161
Keyword: true,
@@ -167,7 +167,7 @@ func TestXml(t *testing.T) {
167167
config := config.Config{
168168
PackageName: "test_package",
169169
Path: "c:/tmp/",
170-
TagName: "xfield",
170+
TagName: "column",
171171
MapperFile: "xml",
172172
Driver: "postgres",
173173
Keyword: true,
@@ -179,7 +179,7 @@ func TestXml(t *testing.T) {
179179
config := config.Config{
180180
PackageName: "test_package",
181181
Path: "c:/tmp/",
182-
TagName: "xfield",
182+
TagName: "column",
183183
MapperFile: "xml",
184184
Driver: "mssql",
185185
Keyword: true,
@@ -193,7 +193,7 @@ func TestTemplate(t *testing.T) {
193193
config := config.Config{
194194
PackageName: "test_package",
195195
Path: "c:/tmp/",
196-
TagName: "xfield",
196+
TagName: "column",
197197
MapperFile: "template",
198198
}
199199
generator.GenTemplate(config, "test_table", *createModeInfo())
@@ -203,7 +203,7 @@ func TestTemplate(t *testing.T) {
203203
config := config.Config{
204204
PackageName: "test_package",
205205
Path: "c:/tmp/",
206-
TagName: "xfield",
206+
TagName: "column",
207207
MapperFile: "template",
208208
Driver: "mysql",
209209
Keyword: true,
@@ -215,7 +215,7 @@ func TestTemplate(t *testing.T) {
215215
config := config.Config{
216216
PackageName: "test_package",
217217
Path: "c:/tmp/",
218-
TagName: "xfield",
218+
TagName: "column",
219219
MapperFile: "template",
220220
Driver: "postgres",
221221
Keyword: true,
@@ -227,7 +227,7 @@ func TestTemplate(t *testing.T) {
227227
config := config.Config{
228228
PackageName: "test_package",
229229
Path: "c:/tmp/",
230-
TagName: "xfield",
230+
TagName: "column",
231231
MapperFile: "template",
232232
Driver: "mssql",
233233
Keyword: true,
@@ -240,7 +240,7 @@ func TestProxy(t *testing.T) {
240240
config := config.Config{
241241
PackageName: "test_package",
242242
Path: "c:/tmp/",
243-
TagName: "xfield",
243+
TagName: "column",
244244
MapperFile: "xml",
245245
}
246246

@@ -251,7 +251,7 @@ func TestV2Proxy(t *testing.T) {
251251
config := config.Config{
252252
PackageName: "test_package",
253253
Path: "c:/tmp/",
254-
TagName: "xfield",
254+
TagName: "column",
255255
MapperFile: "xml",
256256
}
257257

@@ -262,7 +262,7 @@ func TestAll1(t *testing.T) {
262262
config := config.Config{
263263
PackageName: "test_package",
264264
Path: "c:/tmp/",
265-
TagName: "xfield",
265+
TagName: "column",
266266
MapperFile: "xml",
267267
//ModelFile: "model.go",
268268
}
@@ -276,7 +276,7 @@ func TestAll2(t *testing.T) {
276276
config := config.Config{
277277
PackageName: "test_package",
278278
Path: "c:/tmp/",
279-
TagName: "xfield",
279+
TagName: "column",
280280
MapperFile: "go",
281281
//ModelFile: "model.go",
282282
}
@@ -290,7 +290,7 @@ func TestAll3(t *testing.T) {
290290
config := config.Config{
291291
PackageName: "test_package",
292292
Path: "c:/tmp/",
293-
TagName: "xfield",
293+
TagName: "column",
294294
MapperFile: "xml",
295295
//ModelFile: "model.go",
296296
Plugin: "c:/tmp/webplugin.exe",
@@ -306,7 +306,7 @@ func TestPlugin(t *testing.T) {
306306
config := config.Config{
307307
PackageName: "test_package",
308308
Path: "c:/tmp/",
309-
TagName: "xfield",
309+
TagName: "column",
310310
MapperFile: "xml",
311311
Plugin: "c:/tmp/webplugin.exe",
312312
//ModelFile: "model.go",

test/sqlite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestSqliteGenAll(t *testing.T) {
8888
config := config.Config{
8989
PackageName: "mapper",
9090
Path: "c:/tmp/",
91-
TagName: "xfield",
91+
TagName: "column",
9292
MapperFile: "xml",
9393
//ModelFile: "model.go",
9494
}

0 commit comments

Comments
 (0)