File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ func (autoApi *AutoCodeApi) PreviewTemp(c *gin.Context) {
37
37
response .FailWithMessage (err .Error (), c )
38
38
return
39
39
}
40
- a .KeyWord () // 处理go关键字
40
+ a .Pretreatment () // 处理go关键字
41
41
a .PackageT = caser .String (a .Package )
42
42
autoCode , err := autoCodeService .PreviewTemp (a )
43
43
if err != nil {
@@ -64,7 +64,7 @@ func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) {
64
64
response .FailWithMessage (err .Error (), c )
65
65
return
66
66
}
67
- a .KeyWord () // 处理go关键字
67
+ a .Pretreatment ()
68
68
var apiIds []uint
69
69
if a .AutoCreateApiToSql {
70
70
if ids , err := autoCodeService .AutoCreateApi (& a ); err != nil {
Original file line number Diff line number Diff line change 4
4
"errors"
5
5
"github.com/flipped-aurora/gin-vue-admin/server/global"
6
6
"go/token"
7
+ "strings"
7
8
)
8
9
9
10
// AutoCodeStruct 初始版本自动化代码工具
@@ -23,6 +24,11 @@ type AutoCodeStruct struct {
23
24
PackageT string `json:"-"`
24
25
}
25
26
27
+ func (a * AutoCodeStruct ) Pretreatment () {
28
+ a .KeyWord ()
29
+ a .SuffixTest ()
30
+ }
31
+
26
32
// KeyWord 是go关键字的处理加上 _ ,防止编译报错
27
33
// Author [SliverHorn](https://github.com/SliverHorn)
28
34
func (a * AutoCodeStruct ) KeyWord () {
@@ -31,6 +37,14 @@ func (a *AutoCodeStruct) KeyWord() {
31
37
}
32
38
}
33
39
40
+ // SuffixTest 处理_test 后缀
41
+ // Author [SliverHorn](https://github.com/SliverHorn)
42
+ func (a * AutoCodeStruct ) SuffixTest () {
43
+ if strings .HasSuffix (a .Package , "test" ) {
44
+ a .Package = a .Package + "_"
45
+ }
46
+ }
47
+
34
48
type Field struct {
35
49
FieldName string `json:"fieldName"` // Field名
36
50
FieldDesc string `json:"fieldDesc"` // 中文名
You can’t perform that action at this time.
0 commit comments