Skip to content

Commit

Permalink
Merge branch 'fixed_menu'
Browse files Browse the repository at this point in the history
# Conflicts:
#	server/service/system/sys_base_menu.go
#	web/src/view/superAdmin/menu/menu.vue
  • Loading branch information
pixelmaxQm committed Apr 11, 2024
2 parents e3f8b8a + eebddba commit 8ecec6a
Show file tree
Hide file tree
Showing 2 changed files with 338 additions and 219 deletions.
26 changes: 12 additions & 14 deletions server/service/system/sys_base_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,37 @@ type BaseMenuService struct{}
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
err = global.GVA_DB.First(&system.SysBaseMenu{}, "parent_id = ?", id).Error
if err != nil {
global.GVA_DB.Transaction(func(tx *gorm.DB) error {
var menu system.SysBaseMenu
err = global.GVA_DB.Preload("SysAuthoritys").Where("id = ?", id).First(&menu).Error
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {

err = tx.Delete(&system.SysBaseMenu{}, "id = ?", id).Error
if err != nil {
return err
}
global.GVA_DB.Delete((&menu))
err = global.GVA_DB.Delete(&system.SysBaseMenuParameter{}, "sys_base_menu_id = ?", id).Error

err = tx.Delete(&system.SysBaseMenuParameter{}, "sys_base_menu_id = ?", id).Error
if err != nil {
return err
}
err = global.GVA_DB.Delete(&system.SysBaseMenuBtn{}, "sys_base_menu_id = ?", id).Error

err = tx.Delete(&system.SysBaseMenuBtn{}, "sys_base_menu_id = ?", id).Error
if err != nil {
return err
}
err = global.GVA_DB.Delete(&system.SysAuthorityBtn{}, "sys_menu_id = ?", id).Error
err = tx.Delete(&system.SysAuthorityBtn{}, "sys_menu_id = ?", id).Error
if err != nil {
return err
}
if len(menu.SysAuthoritys) > 0 {
err = global.GVA_DB.Model(&menu).Association("SysAuthoritys").Delete(&menu.SysAuthoritys)
}

err = tx.Delete(&system.SysAuthorityMenu{}, "sys_base_menu_id = ?", id).Error
if err != nil {
return err
}
return nil
})
} else {
return errors.New("此菜单存在子菜单不可删除")
}
return err
return errors.New("此菜单存在子菜单不可删除")
}

//@author: [piexlmax](https://github.com/piexlmax)
Expand Down
Loading

0 comments on commit 8ecec6a

Please sign in to comment.