@@ -49,65 +49,65 @@ var (
4949)
5050
5151func 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+ }
8484
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+ }
111111}
112112
113113type injectionMeta struct {
@@ -224,7 +224,7 @@ func makeDictTypes(autoCode *system.AutoCodeStruct) {
224224func (autoCodeService * AutoCodeService ) CreateTemp (autoCode system.AutoCodeStruct , ids ... uint ) (err error ) {
225225 makeDictTypes (& autoCode )
226226 // 增加判断: 重复创建struct
227- if autoCode .AutoMoveFile && AutoCodeHistoryServiceApp .Repeat (autoCode .StructName ) {
227+ if autoCode .AutoMoveFile && AutoCodeHistoryServiceApp .Repeat (autoCode .StructName , autoCode . Package ) {
228228 return RepeatErr
229229 }
230230 dataList , fileList , needMkdir , err := autoCodeService .getNeedList (& autoCode )
@@ -312,6 +312,7 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
312312 injectionCodeMeta .String (),
313313 autoCode .TableName ,
314314 idBf .String (),
315+ autoCode .Package ,
315316 )
316317 } else {
317318 err = AutoCodeHistoryServiceApp .CreateAutoCodeHistory (
@@ -322,6 +323,7 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
322323 injectionCodeMeta .String (),
323324 autoCode .StructName ,
324325 idBf .String (),
326+ autoCode .Package ,
325327 )
326328 }
327329 }
@@ -565,7 +567,7 @@ func (autoCodeService *AutoCodeService) GetPackage() (pkgList []system.SysAutoCo
565567 return pkgList , err
566568}
567569
568- func (AutoCodeService * AutoCodeService ) DelPackage (a system.SysAutoCode ) error {
570+ func (AutoCodeService * AutoCodeService ) DelPackage (a system.SysAutoCode ) error {
569571 return global .GVA_DB .Delete (a ).Error
570572}
571573
@@ -787,4 +789,3 @@ func ImportReference(filepath, importCode, structName, packageName, groupName st
787789 // 写回数据
788790 return ioutil .WriteFile (filepath , buffer .Bytes (), 0o600 )
789791}
790-
0 commit comments