feature:自动创建基本菜单
This commit is contained in:
@@ -253,7 +253,7 @@ func makeDictTypes(autoCode *system.AutoCodeStruct) {
|
||||
// @param: model.AutoCodeStruct
|
||||
// @return: err error
|
||||
|
||||
func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruct, ids ...uint) (err error) {
|
||||
func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruct, menuID uint, ids ...uint) (err error) {
|
||||
makeDictTypes(&autoCode)
|
||||
for i := range autoCode.Fields {
|
||||
if autoCode.Fields[i].FieldType == "time.Time" {
|
||||
@@ -401,6 +401,7 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
|
||||
idBf.String(),
|
||||
autoCode.Package,
|
||||
autoCode.BusinessDB,
|
||||
menuID,
|
||||
)
|
||||
} else {
|
||||
err = AutoCodeHistoryServiceApp.CreateAutoCodeHistory(
|
||||
@@ -413,6 +414,7 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
|
||||
idBf.String(),
|
||||
autoCode.Package,
|
||||
autoCode.BusinessDB,
|
||||
menuID,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -569,6 +571,20 @@ func (autoCodeService *AutoCodeService) AutoCreateApi(a *system.AutoCodeStruct)
|
||||
return ids, err
|
||||
}
|
||||
|
||||
func (autoCodeService *AutoCodeService) AutoCreateMenu(a *system.AutoCodeStruct) (id uint, err error) {
|
||||
var menu system.SysBaseMenu
|
||||
err = global.GVA_DB.First(&menu, "name = ?", menu.Name).Error
|
||||
if err == nil {
|
||||
return 0, errors.New("存在相同的菜单路由,请关闭自动创建菜单功能")
|
||||
}
|
||||
menu.Name = a.Abbreviation
|
||||
menu.Path = a.Abbreviation
|
||||
menu.Meta.Title = a.Description
|
||||
menu.Component = fmt.Sprintf("view/%s/%s.vue", a.PackageName, a.PackageName)
|
||||
err = global.GVA_DB.Create(&menu).Error
|
||||
return menu.ID, err
|
||||
}
|
||||
|
||||
func (autoCodeService *AutoCodeService) getNeedList(autoCode *system.AutoCodeStruct) (dataList []tplData, fileList []string, needMkdir []string, err error) {
|
||||
// 去除所有空格
|
||||
utils.TrimSpace(autoCode)
|
||||
|
||||
@@ -30,7 +30,7 @@ var AutoCodeHistoryServiceApp = new(AutoCodeHistoryService)
|
||||
// RouterPath : RouterPath@RouterString;RouterPath2@RouterString2
|
||||
// Author [SliverHorn](https://github.com/SliverHorn)
|
||||
// Author [songzhibin97](https://github.com/songzhibin97)
|
||||
func (autoCodeHistoryService *AutoCodeHistoryService) CreateAutoCodeHistory(meta, structName, structCNName, autoCodePath string, injectionMeta string, tableName string, apiIds string, Package string, BusinessDB string) error {
|
||||
func (autoCodeHistoryService *AutoCodeHistoryService) CreateAutoCodeHistory(meta, structName, structCNName, autoCodePath string, injectionMeta string, tableName string, apiIds string, Package string, BusinessDB string, menuID uint) error {
|
||||
return global.GVA_DB.Create(&system.SysAutoCodeHistory{
|
||||
Package: Package,
|
||||
RequestMeta: meta,
|
||||
@@ -81,9 +81,17 @@ func (autoCodeHistoryService *AutoCodeHistoryService) RollBack(info *systemReq.R
|
||||
ids.Ids = append(ids.Ids, id)
|
||||
}
|
||||
err := ApiServiceApp.DeleteApisByIds(ids)
|
||||
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("ClearTag DeleteApiByIds:", zap.Error(err))
|
||||
}
|
||||
|
||||
err = BaseMenuServiceApp.DeleteBaseMenu(int(md.MenuID))
|
||||
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("ClearTag DeleteBaseMenu:", zap.Error(err))
|
||||
}
|
||||
|
||||
// 删除表
|
||||
if info.DeleteTable {
|
||||
if err = AutoCodeServiceApp.DropTable(md.BusinessDB, md.TableName); err != nil {
|
||||
|
||||
@@ -16,6 +16,8 @@ type BaseMenuService struct{}
|
||||
//@param: id float64
|
||||
//@return: err error
|
||||
|
||||
var BaseMenuServiceApp = new(BaseMenuService)
|
||||
|
||||
func (baseMenuService *BaseMenuService) DeleteBaseMenu(id int) (err error) {
|
||||
err = global.GVA_DB.Preload("MenuBtn").Preload("Parameters").Where("parent_id = ?", id).First(&system.SysBaseMenu{}).Error
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user