Skip to content

Commit 67dced0

Browse files
committed
add example
1 parent 190d4e3 commit 67dced0

File tree

4 files changed

+54
-7
lines changed

4 files changed

+54
-7
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# gobatis-plus
2+
3+
4+
## Usage
5+
```
6+
gobatis-plus -i {YOUR_PACKAGE_DIR} -o {OUTPUT_DIR}
7+
```
8+
example:
9+
```
10+
gobatis-plus -i github.com/xfali/gobatis-plus/example -o tmp
11+
```
12+
13+
## Package
14+
1. Add doc.go to enable gobatis in package
15+
```
16+
// gobatis:enable
17+
package example
18+
```
19+
2. add your code
20+
```
21+
// gobatis:data
22+
type UserDo struct {
23+
UserId int64 `tableId:"user_id,idType=auto"`
24+
UserName string `tableField:"user_name"`
25+
Status int8 `tableField:"status" tableLogic:"0,delval=1"`
26+
CreateTime time.Time `tableField:"create_time,fill=insert"`
27+
RecVersion uint64 `tableRecVer:"rec_var"`
28+
}
29+
30+
// gobatis:mapper
31+
type UserMapper interface {
32+
// gobatis:select="select * from "
33+
34+
Insert(vo ...UserDo) (err error)
35+
}
36+
```

cmd/gobatis-plus/customargs/args.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type gobatisArgs struct {
1818
func NewDefault() (*args.GeneratorArgs, *gobatisArgs) {
1919
args := args.Default().WithoutDefaultFlagParsing()
2020
cusArgs := &gobatisArgs{
21-
Prefix: "gobatis",
21+
Prefix: "+gobatis:",
2222
}
2323
args.CustomArgs = cusArgs
2424
args.OutputFileBaseName = "zz_generated"

example/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// +gobatis:enable
2+
package example

example/example.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@
55

66
package example
77

8-
// gobatis:enable
9-
type TestDo struct {
8+
import "time"
109

10+
// +gobatis:data
11+
type UserDo struct {
12+
//
13+
UserId int64 `tableId:"user_id,idType=auto"`
14+
UserName string `tableField:"user_name"`
15+
Status int8 `tableField:"status" tableLogic:"0,delval=1"`
16+
CreateTime time.Time `tableField:"create_time,fill=insert"`
17+
RecVersion uint64 `tableRecVer:"rec_var"`
1118
}
1219

13-
// gobatis:mapper
14-
type TestMapper interface {
15-
Insert()
16-
}
20+
// +gobatis:mapper
21+
type UserMapper interface {
22+
// +gobatis:select="select * from "
23+
24+
Insert(vo ...UserDo) (err error)
25+
}

0 commit comments

Comments
 (0)