Skip to content

Commit 372ea91

Browse files
authored
1 parent 6784ede commit 372ea91

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

server/service/system/sys_authority.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthor
114114
if !errors.Is(global.GVA_DB.Where("parent_id = ?", auth.AuthorityId).First(&system.SysAuthority{}).Error, gorm.ErrRecordNotFound) {
115115
return errors.New("此角色存在子角色不允许删除")
116116
}
117-
db := global.GVA_DB.Preload("SysBaseMenus").Where("authority_id = ?", auth.AuthorityId).First(auth)
117+
db := global.GVA_DB.Preload("SysBaseMenus").Preload("DataAuthorityId").Where("authority_id = ?", auth.AuthorityId).First(auth)
118118
err = db.Unscoped().Delete(auth).Error
119119
if err != nil {
120120
return
@@ -126,6 +126,12 @@ func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthor
126126
}
127127
// err = db.Association("SysBaseMenus").Delete(&auth)
128128
}
129+
if len(auth.DataAuthorityId) > 0 {
130+
err = global.GVA_DB.Model(auth).Association("DataAuthorityId").Delete(auth.DataAuthorityId)
131+
if err != nil {
132+
return
133+
}
134+
}
129135
err = global.GVA_DB.Delete(&[]system.SysUserAuthority{}, "sys_authority_authority_id = ?", auth.AuthorityId).Error
130136
if err != nil {
131137
return

0 commit comments

Comments
 (0)