Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
newShopBack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
newshop
newShopBack
Commits
fc4fb56c
Commit
fc4fb56c
authored
Dec 12, 2019
by
孙磊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
角色权限信息调整
Signed-off-by:
sunlei
<
sunlei@romens.cn
>
parent
8550b4bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
15 deletions
+36
-15
AuthorityNodeController.php
backend/controllers/v1/authority/AuthorityNodeController.php
+36
-15
No files found.
backend/controllers/v1/authority/AuthorityNodeController.php
View file @
fc4fb56c
...
...
@@ -346,10 +346,29 @@ class AuthorityNodeController extends BaseController
*/
public
function
actionRoleAuthorities
()
{
//获取登陆用户的权限信息
$rbac
=
new
ShopRbacUser
();
$nodeModel
=
new
ShopRbacNode
();
$model
=
new
ShopRbacRole
();
$roleAcessModel
=
new
ShopRbacRoleAccess
();
$nodeModel
=
new
ShopRbacNode
();
//用户输入数据赋值到模型属性
//获取登陆用户节点信息
$userGuid
=
Yii
::
$app
->
user
->
identity
->
GUID
;
$userinfo
=
$rbac
->
getRbacUserInfo
(
$userGuid
);
$cur_role_id
=
$userinfo
[
'ROLE_ID'
];
$cur_auth_all
=
$roleAcessModel
->
getRoleAuthorities
(
$cur_role_id
);
//获取登陆用户节点ID
$cur_role_nodes
=
array
();
foreach
(
$cur_auth_all
as
$k
=>
$v
)
{
$cur_role_nodes
[]
=
$v
[
'NODE_ID'
];
}
if
(
$cur_role_nodes
)
{
$cur_role_authorities
=
$nodeModel
->
getRoleAuthrities
(
$cur_role_nodes
);
//调整节点关系
$cur_role_authorities
=
$this
->
getTree
(
$cur_role_authorities
);
}
else
{
$cur_role_authorities
=
''
;
}
//每个角色拥有的节点信息获取
$params
=
Yii
::
$app
->
request
->
queryParams
;
$id
=
$model
->
ID
=
$params
[
'ID'
];
$name
=
$model
->
NAME
=
$params
[
'NAME'
];
...
...
@@ -357,24 +376,26 @@ class AuthorityNodeController extends BaseController
//获取角色的权限
$info
=
$roleAcessModel
->
getRoleAuthorities
(
$id
);
if
(
!
$info
)
{
throw
new
BadRequestHttpException
(
'没有找到角色的权限信息'
);
// throw new BadRequestHttpException('没有找到角色的权限信息');
return
$roleHasAuthInfo
=
''
;
}
//获取节点ID
$role
_nodes
=
array
();
$role
HasAuthID
=
array
();
foreach
(
$info
as
$k
=>
$v
)
{
$role_nodes
[]
=
$v
[
'NODE_ID'
];
}
//获取角色拥有的权限节点信息
if
(
$role_nodes
)
{
$role_authorities
=
$nodeModel
->
getRoleAuthrities
(
$role_nodes
);
//调整节点关系
$role_authorities
=
$this
->
getTree
(
$role_authorities
);
$roleHasAuthID
[]
=
$v
[
'NODE_ID'
];
}
if
(
!
$role_authorities
)
{
throw
new
BadRequestHttpException
(
'没有找到角色的权限节点信息'
);
if
(
$roleHasAuthID
)
{
$roleHasAuthInfo
=
implode
(
','
,
$roleHasAuthID
);
}
else
{
$roleHasAuthInfo
=
''
;
}
$role_authorities
[
0
][
'ROLE_NAME'
]
=
$name
;
return
$role_authorities
;
//拼装数组
$roleNodeInfo
=
array
(
'cur_role_nodes'
=>
$cur_role_authorities
,
'every_role_node_ids'
=>
$roleHasAuthInfo
,
'every_role_name'
=>
$name
);
return
$roleNodeInfo
;
}
else
{
//验证失败:$errors 是一个包含错误信息的数组
Yii
::
$app
->
response
->
statusCode
=
422
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment