@@ -42,6 +42,9 @@ const SQLServiceFile = "sqls-service.go.tmpl"
42
42
const MySQLDaoFile = "mysql-dao.go.tmpl"
43
43
const SQLModelFile = "sqls-model.go.tmpl"
44
44
45
+ // common file for common utility functions in controllers
46
+ const ControllersCommonFile = "common.go.tmpl"
47
+
45
48
const DaoFile = "dao.go.tmpl"
46
49
const SQLiteDaoFile = "sqlite-dao.go.tmpl"
47
50
const MySQLDBConfigFile = "mysql.go.tmpl"
@@ -472,6 +475,15 @@ func (c *Copier) copyNoSQLDBResourceFiles(resourceName string, filePaths []*stri
472
475
}
473
476
filePaths = append (filePaths , & targetResourceControllerFileName )
474
477
478
+ // copy controller common file to a generated project
479
+ targetResourceControllerCommonFileName := c .NodeDirectoryName + ControllersPath + "/" + ControllersCommonFile
480
+ _ , err = utils .CopyFile (targetResourceControllerCommonFileName , c .TemplatesRootPath + ControllersPath + "/" + ControllersCommonFile )
481
+ if err != nil {
482
+ log .Debugf ("error copying controller utils file: %v" , err )
483
+ return nil , err
484
+ }
485
+ filePaths = append (filePaths , & targetResourceControllerCommonFileName )
486
+
475
487
// copy model files to a generated project
476
488
targetResourceModelFileName := c .NodeDirectoryName + ModelsPath + "/" + resourceName + "-" + strings .Replace (NoSQLModelFile , "nosqls-" , "" , 1 )
477
489
_ , err = utils .CopyFile (targetResourceModelFileName , c .TemplatesRootPath + ModelsPath + "/" + NoSQLModelFile )
@@ -515,6 +527,15 @@ func (c *Copier) copySQLDBResourceFiles(resourceName string, filePaths []*string
515
527
}
516
528
filePaths = append (filePaths , & targetResourceControllerFileName )
517
529
530
+ // copy controller common file to a generated project
531
+ targetResourceControllerCommonFileName := c .NodeDirectoryName + ControllersPath + "/" + ControllersCommonFile
532
+ _ , err = utils .CopyFile (targetResourceControllerCommonFileName , c .TemplatesRootPath + ControllersPath + "/" + ControllersCommonFile )
533
+ if err != nil {
534
+ log .Debugf ("error copying controller utils file: %v" , err )
535
+ return nil , err
536
+ }
537
+ filePaths = append (filePaths , & targetResourceControllerCommonFileName )
538
+
518
539
// copy service files to a generated project
519
540
targetResourceServiceFileName := c .NodeDirectoryName + ServicesPath + "/" + resourceName + "-" + strings .Replace (SQLServiceFile , "sqls-" , "" , 1 )
520
541
_ , err = utils .CopyFile (targetResourceServiceFileName , c .TemplatesRootPath + ServicesPath + "/" + SQLServiceFile )
0 commit comments