@@ -59,7 +59,7 @@ func (authorityService *AuthorityService) CreateAuthority(auth system.SysAuthori
59
59
//@param: copyInfo response.SysAuthorityCopyResponse
60
60
//@return: authority system.SysAuthority, err error
61
61
62
- func (authorityService * AuthorityService ) CopyAuthority (copyInfo response.SysAuthorityCopyResponse ) (authority system.SysAuthority , err error ) {
62
+ func (authorityService * AuthorityService ) CopyAuthority (adminAuthorityID uint , copyInfo response.SysAuthorityCopyResponse ) (authority system.SysAuthority , err error ) {
63
63
var authorityBox system.SysAuthority
64
64
if ! errors .Is (global .GVA_DB .Where ("authority_id = ?" , copyInfo .Authority .AuthorityId ).First (& authorityBox ).Error , gorm .ErrRecordNotFound ) {
65
65
return authority , ErrRoleExistence
@@ -98,7 +98,7 @@ func (authorityService *AuthorityService) CopyAuthority(copyInfo response.SysAut
98
98
}
99
99
}
100
100
paths := CasbinServiceApp .GetPolicyPathByAuthorityId (copyInfo .OldAuthorityId )
101
- err = CasbinServiceApp .UpdateCasbin (copyInfo .Authority .AuthorityId , paths )
101
+ err = CasbinServiceApp .UpdateCasbin (adminAuthorityID , copyInfo .Authority .AuthorityId , paths )
102
102
if err != nil {
103
103
_ = authorityService .DeleteAuthority (& copyInfo .Authority )
104
104
}
@@ -217,6 +217,8 @@ func (authorityService *AuthorityService) GetAuthorityInfoList(authorityID uint)
217
217
//@return: list interface{}, total int64, err error
218
218
219
219
func (authorityService * AuthorityService ) GetStructAuthorityList (authorityID uint ) (list []uint , err error ) {
220
+ var auth system.SysAuthority
221
+ _ = global .GVA_DB .First (& auth , "authority_id = ?" , authorityID ).Error
220
222
var authorities []system.SysAuthority
221
223
err = global .GVA_DB .Preload ("DataAuthorityId" ).Where ("parent_id = ?" , authorityID ).Find (& authorities ).Error
222
224
if len (authorities ) > 0 {
@@ -225,6 +227,9 @@ func (authorityService *AuthorityService) GetStructAuthorityList(authorityID uin
225
227
_ , err = authorityService .GetStructAuthorityList (authorities [k ].AuthorityId )
226
228
}
227
229
}
230
+ if * auth .ParentId == 0 {
231
+ list = append (list , authorityID )
232
+ }
228
233
return list , err
229
234
}
230
235
@@ -245,23 +250,9 @@ func (authorityService *AuthorityService) GetAuthorityInfo(auth system.SysAuthor
245
250
//@param: auth model.SysAuthority
246
251
//@return: error
247
252
248
- func (authorityService * AuthorityService ) SetDataAuthority (auth system.SysAuthority ) error {
249
- var s system.SysAuthority
250
- global .GVA_DB .Preload ("DataAuthorityId" ).First (& s , "authority_id = ?" , auth .AuthorityId )
251
- err := global .GVA_DB .Model (& s ).Association ("DataAuthorityId" ).Replace (& auth .DataAuthorityId )
252
- return err
253
- }
254
-
255
- //@author: [piexlmax](https://github.com/piexlmax)
256
- //@function: SetMenuAuthority
257
- //@description: 菜单与角色绑定
258
- //@param: auth *model.SysAuthority
259
- //@return: error
260
-
261
- func (authorityService * AuthorityService ) SetMenuAuthority (auth * system.SysAuthority ) error {
262
- var s system.SysAuthority
253
+ func (authorityService * AuthorityService ) SetDataAuthority (adminAuthorityID uint , auth system.SysAuthority ) error {
263
254
if global .GVA_CONFIG .System .UseStrictAuth {
264
- authids , err := authorityService .GetStructAuthorityList (auth . AuthorityId )
255
+ authids , err := AuthorityServiceApp .GetStructAuthorityList (adminAuthorityID )
265
256
if err != nil {
266
257
return err
267
258
}
@@ -276,6 +267,20 @@ func (authorityService *AuthorityService) SetMenuAuthority(auth *system.SysAutho
276
267
return errors .New ("您提交的角色ID不合法" )
277
268
}
278
269
}
270
+ var s system.SysAuthority
271
+ global .GVA_DB .Preload ("DataAuthorityId" ).First (& s , "authority_id = ?" , auth .AuthorityId )
272
+ err := global .GVA_DB .Model (& s ).Association ("DataAuthorityId" ).Replace (& auth .DataAuthorityId )
273
+ return err
274
+ }
275
+
276
+ //@author: [piexlmax](https://github.com/piexlmax)
277
+ //@function: SetMenuAuthority
278
+ //@description: 菜单与角色绑定
279
+ //@param: auth *model.SysAuthority
280
+ //@return: error
281
+
282
+ func (authorityService * AuthorityService ) SetMenuAuthority (auth * system.SysAuthority ) error {
283
+ var s system.SysAuthority
279
284
global .GVA_DB .Preload ("SysBaseMenus" ).First (& s , "authority_id = ?" , auth .AuthorityId )
280
285
err := global .GVA_DB .Model (& s ).Association ("SysBaseMenus" ).Replace (& auth .SysBaseMenus )
281
286
return err
0 commit comments