Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0b4be6e3
authored
Nov 14, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整权限
parent
290575fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
9 deletions
app/Http/Controllers/PermController.php
config/perm_args.php
app/Http/Controllers/PermController.php
View file @
0b4be6e3
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
use
App\Http\Requests
;
use
App\Http\Requests
;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
DB
;
use
DB
;
use
Illuminate\Support\Facades\Redis
;
class
PermController
extends
Controller
class
PermController
extends
Controller
{
{
...
@@ -21,21 +22,60 @@
...
@@ -21,21 +22,60 @@
if
(
!
$userPerms
)
return
false
;
if
(
!
$userPerms
)
return
false
;
$parse_url
=
parse_url
(
$request
->
url
());
// 页面url
$parse_url
=
parse_url
(
$request
->
url
());
// 页面url
$path
=
$parse_url
[
'path'
];
// path路径
if
(
preg_match
(
'/\/web\//'
,
$path
))
{
if
(
!
isset
(
$parse_url
[
'path'
]))
{
$permId
=
str_replace
(
'/web/'
,
''
,
$path
);
if
(
in_array
(
'apply_access'
,
$userPerms
))
return
true
;
// 访问权限存在,则返回true
}
else
{
}
$permId
=
str_replace
(
'/'
,
''
,
$path
);
}
$key
=
Config
(
'perm_args.perm_menus_data'
);
$redis
=
Redis
::
connection
(
'read'
);
$permId
=
$permId
.
'_check'
;
// 路径查看权限
$menus
=
$redis
->
get
(
$key
);
if
(
!
$menus
)
{
$menuconfig
=
DB
::
table
(
'config'
)
->
where
(
'config_title'
,
'订单系统'
)
->
first
();
if
(
!
$menuconfig
)
return
false
;
$menus
=
json_decode
(
$menuconfig
->
config_data
);
$menu_href
=
[];
$this
->
getAllMenus
(
$menus
,
$menu_href
);
// 获取所有菜单href
$expire
=
Config
(
'perm_args.perm_menus_data_expire'
);
// 缓存两小时
Redis
::
setex
(
$key
,
$expire
,
json_encode
(
$menu_href
));
}
else
{
$menu_href
=
json_decode
(
$menus
);
}
$path
=
$parse_url
[
'path'
];
// path路径
if
(
in_array
(
'apply_access'
,
$userPerms
)
&&
in_array
(
$permId
,
$userPerms
))
return
true
;
// 访问及路径权限存在,则返回true
if
(
in_array
(
$path
,
$menu_href
))
{
if
(
preg_match
(
'/\/web\//'
,
$path
))
{
$permId
=
str_replace
(
'/web/'
,
''
,
$path
);
}
else
{
$permId
=
str_replace
(
'/'
,
''
,
$path
);
}
$permId
=
$permId
.
'_check'
;
// 路径查看权限
if
(
in_array
(
'apply_access'
,
$userPerms
)
&&
in_array
(
$permId
,
$userPerms
))
return
true
;
// 访问及路径权限存在,则返回true
}
else
{
if
(
in_array
(
'apply_access'
,
$userPerms
))
return
true
;
// 访问权限存在,则返回true
}
return
false
;
return
false
;
}
}
// 检查路径是否存在于菜单
public
function
getAllMenus
(
$menus
,
&
$menu_href
)
{
foreach
(
$menus
as
$k
=>
$v
)
{
if
(
count
(
$v
->
childs
)
>
0
)
$this
->
getAllMenus
(
$v
->
childs
,
$menu_href
);
if
(
strlen
(
$v
->
href
)
>
1
)
$menu_href
[]
=
$v
->
href
;
}
}
// 获取系统信息
// 获取系统信息
public
function
getBusinessInfo
()
public
function
getBusinessInfo
()
{
{
...
...
config/perm_args.php
View file @
0b4be6e3
...
@@ -67,4 +67,8 @@ return [
...
@@ -67,4 +67,8 @@ return [
// 自营角色 无法查看联营订单
// 自营角色 无法查看联营订单
'self_roles'
=>
[
6
,
7
,
10
,
11
,
12
],
'self_roles'
=>
[
6
,
7
,
10
,
11
,
12
],
// 菜单key
'perm_menus_data'
=>
'order_menus_href_data'
,
'perm_menus_data_expire'
=>
7200
,
];
];
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