Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
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
b754f16b
authored
Dec 18, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
加缓存
parent
237c0daf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
app/Http/Middleware/CheckLogin.php
app/Http/Middleware/CheckLogin.php
View file @
b754f16b
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Middleware
;
use
App\Model\IntracodeModel
;
use
App\Model\RedisModel
;
use
App\Model\UserInfoModel
;
use
Closure
;
use
DB
;
...
...
@@ -100,12 +101,19 @@ class CheckLogin
public
function
getPerms
()
{
$userId
=
request
()
->
user
->
userId
;
$cacheKey
=
'supplier_perms_'
.
$userId
;
$redis
=
new
RedisModel
();
$cachedPerms
=
$redis
->
get
(
$cacheKey
);
if
(
$cachedPerms
!==
null
)
{
return
json_decode
(
$cachedPerms
,
true
);
}
$permsUrl
=
env
(
'PERM_LIST'
)
.
'/'
.
$userId
.
'/'
.
env
(
'PERM_ID'
)
.
'/'
;
$permsResult
=
json_decode
(
curl
(
$permsUrl
),
true
);
$perms
=
[];
if
(
isset
(
$permsResult
[
'retcode'
])
&&
$permsResult
[
'retcode'
]
===
0
)
{
$perms
=
$permsResult
[
'data'
][
'perms'
];
}
$redis
->
setex
(
$cacheKey
,
5
,
json_encode
(
$perms
));
return
$perms
;
}
}
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