Skip to content

Commit

Permalink
fixed: #1352 (#1364)
Browse files Browse the repository at this point in the history
  • Loading branch information
SliverHorn committed Mar 2, 2023
1 parent 6784ede commit 372ea91
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/service/system/sys_authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthor
if !errors.Is(global.GVA_DB.Where("parent_id = ?", auth.AuthorityId).First(&system.SysAuthority{}).Error, gorm.ErrRecordNotFound) {
return errors.New("此角色存在子角色不允许删除")
}
db := global.GVA_DB.Preload("SysBaseMenus").Where("authority_id = ?", auth.AuthorityId).First(auth)
db := global.GVA_DB.Preload("SysBaseMenus").Preload("DataAuthorityId").Where("authority_id = ?", auth.AuthorityId).First(auth)
err = db.Unscoped().Delete(auth).Error
if err != nil {
return
Expand All @@ -126,6 +126,12 @@ func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthor
}
// err = db.Association("SysBaseMenus").Delete(&auth)
}
if len(auth.DataAuthorityId) > 0 {
err = global.GVA_DB.Model(auth).Association("DataAuthorityId").Delete(auth.DataAuthorityId)
if err != nil {
return
}
}
err = global.GVA_DB.Delete(&[]system.SysUserAuthority{}, "sys_authority_authority_id = ?", auth.AuthorityId).Error
if err != nil {
return
Expand Down

0 comments on commit 372ea91

Please sign in to comment.