File tree Expand file tree Collapse file tree 5 files changed +66
-17
lines changed Expand file tree Collapse file tree 5 files changed +66
-17
lines changed Original file line number Diff line number Diff line change @@ -13,24 +13,36 @@ gobatis-plus -i github.com/xfali/gobatis-plus/example -o tmp
13
13
## Package
14
14
1 . Add doc.go to enable gobatis in package
15
15
```
16
- // gobatis:enable
16
+ // + gobatis:enable
17
17
package example
18
18
```
19
19
2 . add your code
20
20
```
21
- // gobatis:data
21
+ // + gobatis:data:tablename=tbl_user
22
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"`
23
+ // +gobatis:tableid:value=user_id,idType=auto
24
+ UserId int64
25
+
26
+ // +gobatis:tablefield:value=user_name
27
+ UserName string
28
+
29
+ // +gobatis:tablefield:value=status
30
+ // +gobatis:tablelogic:value=0,delval=1
31
+ Status int8
32
+
33
+ // +gobatis:tablefield:value=create_time,fill=insert
34
+ CreateTime time.Time
35
+
36
+ // +gobatis:tablefield:value=rec_var
37
+ // +gobatis:version
38
+ RecVersion uint64
28
39
}
29
40
30
- // gobatis:mapper
41
+ // + gobatis:mapper
31
42
type UserMapper interface {
32
- // gobatis:select="select * from "
33
-
34
- Insert(vo ...UserDo) (err error)
43
+ mapper.BaseMapper[UserDo]
44
+
45
+ // +gobatis:select="select * from tbl_user where id = #{UserDo.UserId}"
46
+ Select(user UserDo) (users []UserDo, err error)
35
47
}
36
48
```
Original file line number Diff line number Diff line change 5
5
6
6
package example
7
7
8
- import "time"
8
+ import (
9
+ "github.com/xfali/gobatis-plus/pkg/mapper"
10
+ "time"
11
+ )
9
12
10
- // +gobatis:data
13
+ // +gobatis:data:tablename=tbl_user
11
14
type UserDo struct {
12
15
// +gobatis:tableid:value=user_id,idType=auto
13
16
UserId int64
@@ -29,8 +32,8 @@ type UserDo struct {
29
32
30
33
// +gobatis:mapper
31
34
type UserMapper interface {
32
- // +gobatis:select="select * from tbl_user where id = #{UserDo.UserId}"
33
- Select (vo UserDo ) ([]UserDo , error )
35
+ mapper.BaseMapper [UserDo ]
34
36
35
- Insert (vo ... UserDo ) (err error )
37
+ // +gobatis:select="select * from tbl_user where id = #{UserDo.UserId}"
38
+ Select (user UserDo ) (users []UserDo , err error )
36
39
}
Original file line number Diff line number Diff line change 1
1
module github.com/xfali/gobatis-plus
2
2
3
- go 1.16
3
+ go 1.18
4
4
5
5
require (
6
6
github.com/spf13/pflag v1.0.5
Original file line number Diff line number Diff line change
1
+ // Copyright (C) 2022, Xiongfa Li.
2
+ // All right reserved.
3
+ // @author xiongfa.li
4
+ // @version V1.0
5
+ // Description:
6
+
7
+ package mapper
8
+
9
+ type BaseMapper [T any ] interface {
10
+ Insert (entity T ) int64
11
+
12
+ InsertBatch (entities ... T ) (int64 , int64 )
13
+
14
+ DeleteById (id any ) int64
15
+
16
+ DeleteBatchIds (ids []any ) int64
17
+
18
+ UpdateById (entity T ) int64
19
+
20
+ SelectById (id any ) T
21
+
22
+ SelectBatchIds (ids []any ) []T
23
+
24
+ SelectOne (entity T ) T
25
+
26
+ SelectCount (entity T ) int64
27
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (C) 2022, Xiongfa Li.
2
+ // All right reserved.
3
+ // @author xiongfa.li
4
+ // @version V1.0
5
+ // Description:
6
+
7
+ package mapper
You can’t perform that action at this time.
0 commit comments