feat: 自动化代码可自行配置mod

This commit is contained in:
pixelmaxQM
2024-10-17 23:15:59 +08:00
parent efac72ecbb
commit a847ad292f
20 changed files with 44 additions and 37 deletions

View File

@@ -3,6 +3,7 @@ package request
import (
"encoding/json"
"fmt"
"github.com/flipped-aurora/gin-vue-admin/server/global"
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
"github.com/pkg/errors"
"go/token"
@@ -28,6 +29,7 @@ type AutoCode struct {
OnlyTemplate bool `json:"onlyTemplate" example:"false"` // 是否只生成模板
IsAdd bool `json:"isAdd" example:"false"` // 是否新增
Fields []*AutoCodeField `json:"fields"`
Module string `json:"-"`
DictTypes []string `json:"-"`
PrimaryField *AutoCodeField `json:"primaryField"`
DataSourceMap map[string]*DataSource `json:"-"`
@@ -111,6 +113,7 @@ func (r *AutoCode) Menu(template string) model.SysBaseMenu {
// Pretreatment 预处理
// Author [SliverHorn](https://github.com/SliverHorn)
func (r *AutoCode) Pretreatment() error {
r.Module = global.GVA_CONFIG.AutoCode.Module
if token.IsKeyword(r.Abbreviation) {
r.Abbreviation = r.Abbreviation + "_"
} // go 关键字处理

View File

@@ -1,6 +1,7 @@
package request
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
)
@@ -9,11 +10,13 @@ type SysAutoCodePackageCreate struct {
Label string `json:"label" example:"展示名"`
Template string `json:"template" example:"模版"`
PackageName string `json:"packageName" example:"包名"`
Module string `json:"-" example:"模块"`
}
func (r *SysAutoCodePackageCreate) AutoCode() AutoCode {
return AutoCode{
Package: r.PackageName,
Module: global.GVA_CONFIG.AutoCode.Module,
}
}
@@ -23,5 +26,6 @@ func (r *SysAutoCodePackageCreate) Create() model.SysAutoCodePackage {
Label: r.Label,
Template: r.Template,
PackageName: r.PackageName,
Module: global.GVA_CONFIG.AutoCode.Module,
}
}

View File

@@ -10,6 +10,7 @@ type SysAutoCodePackage struct {
Label string `json:"label" gorm:"comment:展示名"`
Template string `json:"template" gorm:"comment:模版"`
PackageName string `json:"packageName" gorm:"comment:包名"`
Module string `json:"-" example:"模块"`
}
func (s *SysAutoCodePackage) TableName() string {