Skip to content

Commit 07747f6

Browse files
authored
Merge pull request #1 from zouchangfu/update_license
chmore: Update license
2 parents 62e6aad + 62473fd commit 07747f6

File tree

141 files changed

+246862
-2032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+246862
-2032
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
使用命令安装:
66

77
```
8-
go get github.com/xfali/gobatis-cmd/cmd/gobatis-cmd
8+
go get github.com/acmestack/gobatis-cmd/cmd/gobatis-cmd
99
```
1010

1111
## 使用
@@ -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,
@@ -48,15 +48,15 @@ gobatis-cmd -driver=mysql -host=localhost -port=3306 -user=test -pw=test -db=tes
4848
-path string
4949
保存生成文件的路径
5050
-pkg string
51-
生成文件的包名 (default "xfali/gobatis/default")
51+
生成文件的包名 (default "acmestack/gobatis/default")
5252
-port int
5353
数据库的端口号 (default 3306)
5454
-pw string
5555
数据库的密码
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
@@ -82,16 +82,16 @@ gobatis-cmd -driver=mysql -host=localhost -port=3306 -user=test -pw=test -db=tes
8282
package test
8383
8484
import (
85-
"github.com/xfali/gobatis"
85+
"github.com/acmestack/gobatis"
8686
"time"
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) {
@@ -204,7 +204,7 @@ func (m *TestTable) Delete(sess *gobatis.Session) (int64, error) {
204204
package test
205205
206206
import (
207-
"github.com/xfali/gobatis"
207+
"github.com/acmestack/gobatis"
208208
)
209209
210210
func init() {
@@ -326,7 +326,7 @@ fmt.Println(ret)
326326
```
327327
事务:
328328

329-
使用gobatis的session.Tx() 参考[gobatis](https://github.com/xfali/gobatis)
329+
使用gobatis的session.Tx() 参考[gobatis](https://github.com/acmestack/gobatis)
330330

331331
## 其他
332332

api/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

build/package/.keep

Whitespace-only changes.

cmd/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

cmd/gobatis-cmd/.keep

Whitespace-only changes.

cmd/gobatis-cmd/main.go

Lines changed: 112 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,131 @@
1-
/**
2-
* Copyright (C) 2019, Xiongfa Li.
3-
* All right reserved.
4-
* @author xiongfa.li
5-
* @version V1.0
6-
* Description:
1+
/*
2+
* Copyright (c) 2022, AcmeStack
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
716
*/
817

918
package main
1019

1120
import (
12-
"encoding/json"
13-
"flag"
14-
"fmt"
15-
"github.com/xfali/gobatis-cmd/pkg/config"
16-
"github.com/xfali/gobatis-cmd/pkg/db"
17-
"github.com/xfali/gobatis-cmd/pkg/generator"
18-
"github.com/xfali/gobatis-cmd/pkg/io"
19-
"io/ioutil"
20-
"log"
21-
"os"
22-
"strings"
21+
"encoding/json"
22+
"flag"
23+
"fmt"
24+
"github.com/acmestack/gobatis-cmd/pkg/config"
25+
"github.com/acmestack/gobatis-cmd/pkg/db"
26+
"github.com/acmestack/gobatis-cmd/pkg/generator"
27+
"github.com/acmestack/gobatis-cmd/pkg/io"
28+
"io/ioutil"
29+
"log"
30+
"os"
31+
"strings"
2332
)
2433

2534
func main() {
26-
driver := flag.String("driver", "mysql", "driver of db")
27-
packageName := flag.String("pkg", "xfali.gobatis.default", "Set the package name of .go file")
28-
dbName := flag.String("db", "", "the name of db instance used in model files")
29-
tableName := flag.String("table", "", "the name of table to be generated")
30-
host := flag.String("host", "localhost", "host of db")
31-
port := flag.Int("port", 3306, "port of db ")
32-
username := flag.String("user", "", "user name of db")
33-
pw := flag.String("pw", "", "password of db")
34-
path := flag.String("path", "", "root path to save files")
35-
modelfile := flag.String("model", "", "the name of model file")
36-
tagName := flag.String("tag", "xfield", "the name of field tag,eg: xfield,json xfield,json,yaml")
37-
mapper := flag.String("mapper", "xml", "generate mapper file: xml | template | go")
38-
plugin := flag.String("plugin", "", "path of plugin")
39-
keyword := flag.Bool("keyword", false, "with Keyword escape")
40-
namespace := flag.String("namespace", "", "namespace")
41-
confFile := flag.String("f", "", "config file")
42-
register := flag.Bool("register", false, "add register code")
43-
flag.Parse()
35+
driver := flag.String("driver", "mysql", "driver of db")
36+
packageName := flag.String("pkg", "acmestack.gobatis.default", "Set the package name of .go file")
37+
dbName := flag.String("db", "", "the name of db instance used in model files")
38+
tableName := flag.String("table", "", "the name of table to be generated")
39+
host := flag.String("host", "localhost", "host of db")
40+
port := flag.Int("port", 3306, "port of db ")
41+
username := flag.String("user", "", "user name of db")
42+
pw := flag.String("pw", "", "password of db")
43+
path := flag.String("path", "", "root path to save files")
44+
modelfile := flag.String("model", "", "the name of model file")
45+
tagName := flag.String("tag", "column", "the name of field tag,eg: column,json column,json,yaml")
46+
mapper := flag.String("mapper", "xml", "generate mapper file: xml | template | go")
47+
plugin := flag.String("plugin", "", "path of plugin")
48+
keyword := flag.Bool("keyword", false, "with Keyword escape")
49+
namespace := flag.String("namespace", "", "namespace")
50+
confFile := flag.String("f", "", "config file")
51+
register := flag.Bool("register", false, "add register code")
52+
flag.Parse()
4453

45-
conf := config.FileConfig{}
46-
if *confFile != "" {
47-
err := loadFromFile(&conf, *confFile)
48-
if err != nil {
49-
fmt.Println(err)
50-
os.Exit(1)
51-
}
52-
conf.Path = formatPath(conf.Path)
53-
} else {
54-
conf.Driver = *driver
55-
conf.Path = formatPath(*path)
56-
conf.PackageName = *packageName
57-
conf.Namespace = *namespace
58-
conf.ModelFile = *modelfile
59-
conf.TagName = *tagName
60-
conf.MapperFile = *mapper
61-
conf.Plugin = *plugin
62-
conf.Keyword = *keyword
63-
conf.Register = *register
64-
conf.TableName = *tableName
65-
conf.DBName = *dbName
66-
conf.Host = *host
67-
conf.Port = *port
68-
conf.User = *username
69-
conf.Password = *pw
70-
}
54+
conf := config.FileConfig{}
55+
if *confFile != "" {
56+
err := loadFromFile(&conf, *confFile)
57+
if err != nil {
58+
fmt.Println(err)
59+
os.Exit(1)
60+
}
61+
conf.Path = formatPath(conf.Path)
62+
} else {
63+
conf.Driver = *driver
64+
conf.Path = formatPath(*path)
65+
conf.PackageName = *packageName
66+
conf.Namespace = *namespace
67+
conf.ModelFile = *modelfile
68+
conf.TagName = *tagName
69+
conf.MapperFile = *mapper
70+
conf.Plugin = *plugin
71+
conf.Keyword = *keyword
72+
conf.Register = *register
73+
conf.TableName = *tableName
74+
conf.DBName = *dbName
75+
conf.Host = *host
76+
conf.Port = *port
77+
conf.User = *username
78+
conf.Password = *pw
79+
}
7180

72-
dbDriver := db.GetDriver(conf.Driver)
73-
if dbDriver == nil {
74-
log.Print("not support driver: ", conf.Driver)
75-
os.Exit(-1)
76-
}
81+
dbDriver := db.GetDriver(conf.Driver)
82+
if dbDriver == nil {
83+
log.Print("not support driver: ", conf.Driver)
84+
os.Exit(-1)
85+
}
7786

78-
err := dbDriver.Open(conf.Driver, db.GenDBInfo(conf.Driver, conf.DBName, conf.User, conf.Password, conf.Host, conf.Port))
79-
if err != nil {
80-
log.Print(err)
81-
os.Exit(-1)
82-
}
83-
defer dbDriver.Close()
87+
err := dbDriver.Open(conf.Driver, db.GenDBInfo(conf.Driver, conf.DBName, conf.User, conf.Password, conf.Host, conf.Port))
88+
if err != nil {
89+
log.Print(err)
90+
os.Exit(-1)
91+
}
92+
defer dbDriver.Close()
8493

85-
if conf.TableName == "" {
86-
tables, err2 := dbDriver.QueryTableNames(conf.DBName)
87-
if err2 != nil {
88-
log.Print(err2)
89-
os.Exit(-2)
90-
}
91-
for _, v := range tables {
92-
generator.GenOneTable(conf.Config, dbDriver, conf.DBName, v)
93-
}
94-
} else {
95-
generator.GenOneTable(conf.Config, dbDriver, conf.DBName, conf.TableName)
96-
}
97-
os.Exit(0)
94+
if conf.TableName == "" {
95+
tables, err2 := dbDriver.QueryTableNames(conf.DBName)
96+
if err2 != nil {
97+
log.Print(err2)
98+
os.Exit(-2)
99+
}
100+
for _, v := range tables {
101+
generator.GenOneTable(conf.Config, dbDriver, conf.DBName, v)
102+
}
103+
} else {
104+
generator.GenOneTable(conf.Config, dbDriver, conf.DBName, conf.TableName)
105+
}
106+
os.Exit(0)
98107
}
99108

100109
func loadFromFile(conf *config.FileConfig, path string) error {
101-
b, err := ioutil.ReadFile(path)
102-
if err != nil {
103-
return err
104-
}
105-
fmt.Printf("config file: %s\n", string(b))
106-
return json.Unmarshal(b, conf)
110+
b, err := ioutil.ReadFile(path)
111+
if err != nil {
112+
return err
113+
}
114+
fmt.Printf("config file: %s\n", string(b))
115+
return json.Unmarshal(b, conf)
107116
}
108117

109118
func formatPath(path string) string {
110-
root := strings.TrimSpace(path)
111-
if root == "" {
112-
root = "./"
113-
} else {
114-
if !io.IsPathExists(path) {
115-
io.Mkdir(path)
116-
}
117-
if root[len(root)-1:] != "/" {
118-
root = root + "/"
119-
}
120-
}
121-
return root
119+
root := strings.TrimSpace(path)
120+
if root == "" {
121+
root = "./"
122+
} else {
123+
if !io.IsPathExists(path) {
124+
io.Mkdir(path)
125+
}
126+
if root[len(root)-1:] != "/" {
127+
root = root + "/"
128+
}
129+
}
130+
return root
122131
}

configs/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

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,

0 commit comments

Comments
 (0)