添加代码生成中route和gorm的自动注入
This commit is contained in:
@@ -134,6 +134,18 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
initializeGormFilePath := filepath.Join(global.GVA_CONFIG.AutoCode.Root,
|
||||
global.GVA_CONFIG.AutoCode.Server, global.GVA_CONFIG.AutoCode.SInitialize, "gorm.go")
|
||||
initializeRouterFilePath := filepath.Join(global.GVA_CONFIG.AutoCode.Root,
|
||||
global.GVA_CONFIG.AutoCode.Server, global.GVA_CONFIG.AutoCode.SInitialize, "router.go")
|
||||
err = utils.AutoInjectionCode(initializeGormFilePath, "MysqlTables", "model."+autoCode.StructName+"{},")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = utils.AutoInjectionCode(initializeRouterFilePath, "Routers", "router.Init"+autoCode.StructName+"Router(PrivateGroup)")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return errors.New("创建代码成功并移动文件成功")
|
||||
} else { // 打包
|
||||
if err := utils.ZipFiles("./ginvueadmin.zip", fileList, ".", "."); err != nil {
|
||||
|
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
//@author: [songzhibin97](https://github.com/songzhibin97)
|
||||
@@ -154,5 +155,6 @@ func InitDB(conf request.InitDB) error {
|
||||
_ = writeConfig(global.GVA_VP, baseSetting)
|
||||
return err
|
||||
}
|
||||
global.GVA_CONFIG.AutoCode.Root, _ = filepath.Abs("..")
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user