Skip to content

Commit 05d560c

Browse files
author
piexlmax
committed
修复拷贝角色的错误提示
1 parent a8caeb7 commit 05d560c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

server/service/system/sys_authority.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ func (authorityService *AuthorityService) CopyAuthority(copyInfo response.SysAut
6464
if err != nil {
6565
return
6666
}
67-
for i := range btns {
68-
btns[i].AuthorityId = copyInfo.Authority.AuthorityId
69-
}
70-
71-
err = global.GVA_DB.Create(&btns).Error
67+
if len(btns) > 0 {
68+
for i := range btns {
69+
btns[i].AuthorityId = copyInfo.Authority.AuthorityId
70+
}
71+
err = global.GVA_DB.Create(&btns).Error
7272

73-
if err != nil {
74-
return
73+
if err != nil {
74+
return
75+
}
7576
}
76-
7777
paths := CasbinServiceApp.GetPolicyPathByAuthorityId(copyInfo.OldAuthorityId)
7878
err = CasbinServiceApp.UpdateCasbin(copyInfo.Authority.AuthorityId, paths)
7979
if err != nil {

0 commit comments

Comments
 (0)