File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthor
114
114
if ! errors .Is (global .GVA_DB .Where ("parent_id = ?" , auth .AuthorityId ).First (& system.SysAuthority {}).Error , gorm .ErrRecordNotFound ) {
115
115
return errors .New ("此角色存在子角色不允许删除" )
116
116
}
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 )
118
118
err = db .Unscoped ().Delete (auth ).Error
119
119
if err != nil {
120
120
return
@@ -126,6 +126,12 @@ func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthor
126
126
}
127
127
// err = db.Association("SysBaseMenus").Delete(&auth)
128
128
}
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
+ }
129
135
err = global .GVA_DB .Delete (& []system.SysUserAuthority {}, "sys_authority_authority_id = ?" , auth .AuthorityId ).Error
130
136
if err != nil {
131
137
return
You can’t perform that action at this time.
0 commit comments