mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-09-21 12:32:25 +00:00
feature:自动化代码支持基础菜单创建
This commit is contained in:
@@ -74,7 +74,7 @@ func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) {
|
||||
apiIds = ids
|
||||
}
|
||||
}
|
||||
if a.AutoCreateApiToSql {
|
||||
if a.AutoCreateMenuToSql {
|
||||
if id, err := autoCodeService.AutoCreateMenu(&a); err != nil {
|
||||
global.GVA_LOG.Error("自动化创建失败!请自行清空垃圾数据!", zap.Error(err))
|
||||
c.Writer.Header().Add("success", "false")
|
||||
|
||||
@@ -389,7 +389,7 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
|
||||
return err
|
||||
}
|
||||
}
|
||||
if autoCode.AutoMoveFile || autoCode.AutoCreateApiToSql {
|
||||
if autoCode.AutoMoveFile || autoCode.AutoCreateApiToSql || autoCode.AutoCreateMenuToSql {
|
||||
if autoCode.TableName != "" {
|
||||
err = AutoCodeHistoryServiceApp.CreateAutoCodeHistory(
|
||||
string(meta),
|
||||
@@ -573,10 +573,11 @@ func (autoCodeService *AutoCodeService) AutoCreateApi(a *system.AutoCodeStruct)
|
||||
|
||||
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
|
||||
err = global.GVA_DB.First(&menu, "name = ?", a.Abbreviation).Error
|
||||
if err == nil {
|
||||
return 0, errors.New("存在相同的菜单路由,请关闭自动创建菜单功能")
|
||||
}
|
||||
menu.ParentId = "0"
|
||||
menu.Name = a.Abbreviation
|
||||
menu.Path = a.Abbreviation
|
||||
menu.Meta.Title = a.Description
|
||||
|
||||
Reference in New Issue
Block a user