@@ -49,65 +49,65 @@ var (
49
49
)
50
50
51
51
func Init (Package string ) {
52
- injectionPaths = []injectionMeta {
53
- {
54
- path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
55
- global .GVA_CONFIG .AutoCode .Server , global .GVA_CONFIG .AutoCode .SInitialize , "gorm.go" ),
56
- funcName : "MysqlTables" ,
57
- structNameF : Package + ".%s{}," ,
58
- },
59
- {
60
- path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
61
- global .GVA_CONFIG .AutoCode .Server , global .GVA_CONFIG .AutoCode .SInitialize , "router.go" ),
62
- funcName : "Routers" ,
63
- structNameF : Package + "Router.Init%sRouter(PrivateGroup)" ,
64
- },
65
- {
66
- path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
67
- global .GVA_CONFIG .AutoCode .Server , fmt .Sprintf (global .GVA_CONFIG .AutoCode .SApi , Package ), "enter.go" ),
68
- funcName : "ApiGroup" ,
69
- structNameF : "%sApi" ,
70
- },
71
- {
72
- path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
73
- global .GVA_CONFIG .AutoCode .Server , fmt .Sprintf (global .GVA_CONFIG .AutoCode .SRouter , Package ), "enter.go" ),
74
- funcName : "RouterGroup" ,
75
- structNameF : "%sRouter" ,
76
- },
77
- {
78
- path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
79
- global .GVA_CONFIG .AutoCode .Server , fmt .Sprintf (global .GVA_CONFIG .AutoCode .SService , Package ), "enter.go" ),
80
- funcName : "ServiceGroup" ,
81
- structNameF : "%sService" ,
82
- },
83
- }
52
+ injectionPaths = []injectionMeta {
53
+ {
54
+ path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
55
+ global .GVA_CONFIG .AutoCode .Server , global .GVA_CONFIG .AutoCode .SInitialize , "gorm.go" ),
56
+ funcName : "MysqlTables" ,
57
+ structNameF : Package + ".%s{}," ,
58
+ },
59
+ {
60
+ path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
61
+ global .GVA_CONFIG .AutoCode .Server , global .GVA_CONFIG .AutoCode .SInitialize , "router.go" ),
62
+ funcName : "Routers" ,
63
+ structNameF : Package + "Router.Init%sRouter(PrivateGroup)" ,
64
+ },
65
+ {
66
+ path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
67
+ global .GVA_CONFIG .AutoCode .Server , fmt .Sprintf (global .GVA_CONFIG .AutoCode .SApi , Package ), "enter.go" ),
68
+ funcName : "ApiGroup" ,
69
+ structNameF : "%sApi" ,
70
+ },
71
+ {
72
+ path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
73
+ global .GVA_CONFIG .AutoCode .Server , fmt .Sprintf (global .GVA_CONFIG .AutoCode .SRouter , Package ), "enter.go" ),
74
+ funcName : "RouterGroup" ,
75
+ structNameF : "%sRouter" ,
76
+ },
77
+ {
78
+ path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
79
+ global .GVA_CONFIG .AutoCode .Server , fmt .Sprintf (global .GVA_CONFIG .AutoCode .SService , Package ), "enter.go" ),
80
+ funcName : "ServiceGroup" ,
81
+ structNameF : "%sService" ,
82
+ },
83
+ }
84
84
85
- packageInjectionMap = map [string ]astInjectionMeta {
86
- packageServiceName : {
87
- path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
88
- global .GVA_CONFIG .AutoCode .Server , "service" , "enter.go" ),
89
- importCodeF : "github.com/flipped-aurora/gin-vue-admin/server/%s/%s" ,
90
- packageNameF : "%s" ,
91
- groupName : "ServiceGroup" ,
92
- structNameF : "%sServiceGroup" ,
93
- },
94
- packageRouterName : {
95
- path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
96
- global .GVA_CONFIG .AutoCode .Server , "router" , "enter.go" ),
97
- importCodeF : "github.com/flipped-aurora/gin-vue-admin/server/%s/%s" ,
98
- packageNameF : "%s" ,
99
- groupName : "RouterGroup" ,
100
- structNameF : "%s" ,
101
- },
102
- packageAPIName : {
103
- path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
104
- global .GVA_CONFIG .AutoCode .Server , "api/v1" , "enter.go" ),
105
- importCodeF : "github.com/flipped-aurora/gin-vue-admin/server/%s/%s" ,
106
- packageNameF : "%s" ,
107
- groupName : "ApiGroup" ,
108
- structNameF : "%sApiGroup" ,
109
- },
110
- }
85
+ packageInjectionMap = map [string ]astInjectionMeta {
86
+ packageServiceName : {
87
+ path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
88
+ global .GVA_CONFIG .AutoCode .Server , "service" , "enter.go" ),
89
+ importCodeF : "github.com/flipped-aurora/gin-vue-admin/server/%s/%s" ,
90
+ packageNameF : "%s" ,
91
+ groupName : "ServiceGroup" ,
92
+ structNameF : "%sServiceGroup" ,
93
+ },
94
+ packageRouterName : {
95
+ path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
96
+ global .GVA_CONFIG .AutoCode .Server , "router" , "enter.go" ),
97
+ importCodeF : "github.com/flipped-aurora/gin-vue-admin/server/%s/%s" ,
98
+ packageNameF : "%s" ,
99
+ groupName : "RouterGroup" ,
100
+ structNameF : "%s" ,
101
+ },
102
+ packageAPIName : {
103
+ path : filepath .Join (global .GVA_CONFIG .AutoCode .Root ,
104
+ global .GVA_CONFIG .AutoCode .Server , "api/v1" , "enter.go" ),
105
+ importCodeF : "github.com/flipped-aurora/gin-vue-admin/server/%s/%s" ,
106
+ packageNameF : "%s" ,
107
+ groupName : "ApiGroup" ,
108
+ structNameF : "%sApiGroup" ,
109
+ },
110
+ }
111
111
}
112
112
113
113
type injectionMeta struct {
@@ -224,7 +224,7 @@ func makeDictTypes(autoCode *system.AutoCodeStruct) {
224
224
func (autoCodeService * AutoCodeService ) CreateTemp (autoCode system.AutoCodeStruct , ids ... uint ) (err error ) {
225
225
makeDictTypes (& autoCode )
226
226
// 增加判断: 重复创建struct
227
- if autoCode .AutoMoveFile && AutoCodeHistoryServiceApp .Repeat (autoCode .StructName ) {
227
+ if autoCode .AutoMoveFile && AutoCodeHistoryServiceApp .Repeat (autoCode .StructName , autoCode . Package ) {
228
228
return RepeatErr
229
229
}
230
230
dataList , fileList , needMkdir , err := autoCodeService .getNeedList (& autoCode )
@@ -312,6 +312,7 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
312
312
injectionCodeMeta .String (),
313
313
autoCode .TableName ,
314
314
idBf .String (),
315
+ autoCode .Package ,
315
316
)
316
317
} else {
317
318
err = AutoCodeHistoryServiceApp .CreateAutoCodeHistory (
@@ -322,6 +323,7 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
322
323
injectionCodeMeta .String (),
323
324
autoCode .StructName ,
324
325
idBf .String (),
326
+ autoCode .Package ,
325
327
)
326
328
}
327
329
}
@@ -565,7 +567,7 @@ func (autoCodeService *AutoCodeService) GetPackage() (pkgList []system.SysAutoCo
565
567
return pkgList , err
566
568
}
567
569
568
- func (AutoCodeService * AutoCodeService ) DelPackage (a system.SysAutoCode ) error {
570
+ func (AutoCodeService * AutoCodeService ) DelPackage (a system.SysAutoCode ) error {
569
571
return global .GVA_DB .Delete (a ).Error
570
572
}
571
573
@@ -787,4 +789,3 @@ func ImportReference(filepath, importCode, structName, packageName, groupName st
787
789
// 写回数据
788
790
return ioutil .WriteFile (filepath , buffer .Bytes (), 0o600 )
789
791
}
790
-
0 commit comments