Skip to content

Commit

Permalink
fixed:适配pgsql编辑菜单触发 more than once的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelmaxQm committed Apr 22, 2024
1 parent c07317a commit 56f4d22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/service/system/sys_base_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (baseMenuService *BaseMenuService) UpdateBaseMenu(menu system.SysBaseMenu)
upDateMap["sort"] = menu.Sort

err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
db := tx.Where("id = ?", menu.ID).Find(&oldMenu)
tx.Where("id = ?", menu.ID).Find(&oldMenu)
if oldMenu.Name != menu.Name {
if !errors.Is(tx.Where("id <> ? AND name = ?", menu.ID, menu.Name).First(&system.SysBaseMenu{}).Error, gorm.ErrRecordNotFound) {
global.GVA_LOG.Debug("存在相同name修改失败")
Expand Down Expand Up @@ -114,7 +114,7 @@ func (baseMenuService *BaseMenuService) UpdateBaseMenu(menu system.SysBaseMenu)
}
}

txErr = db.Updates(upDateMap).Error
txErr = tx.Model(&oldMenu).Updates(upDateMap).Error
if txErr != nil {
global.GVA_LOG.Debug(txErr.Error())
return txErr
Expand Down

0 comments on commit 56f4d22

Please sign in to comment.