Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
media-resource
Overview
Overview
Details
Activity
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
杨昕
media-resource
Commits
482a3c3e
Commit
482a3c3e
authored
Aug 20, 2020
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口天appid参数
parent
58876bf4
Pipeline
#10766
passed with stages
in 41 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
103 deletions
+18
-103
functions.php
app/Helpers/functions.php
+4
-4
UsersController.php
app/Http/Controllers/Api/Client/UsersController.php
+0
-80
PrivilegeController.php
app/Http/Controllers/Web/PrivilegeController.php
+2
-1
MediaCategoryModel.php
app/Model/MediaCategoryModel.php
+8
-9
UserModel.php
app/Model/UserModel.php
+1
-1
index.blade.php
resources/views/admin/index.blade.php
+3
-8
No files found.
app/Helpers/functions.php
View file @
482a3c3e
...
...
@@ -314,12 +314,12 @@ function generateRandomNum( $len = 32, $md5 = true ) {
* 获取rbac统一验权
* @return string
*/
function
getRbac
(
$request
,
$url
=
'api/ram'
,
$
category_
id
=
''
,
$type
=
'base'
){
function
getRbac
(
$request
,
$url
=
'api/ram'
,
$
app
id
=
''
,
$type
=
'base'
){
if
(
$
category_
id
){
$appid
=
$
category_
id
;
if
(
$
app
id
){
$appid
=
$
app
id
;
}
else
{
$appid
=
$request
->
category_
id
??
""
;
$appid
=
$request
->
app
id
??
""
;
}
$mis_uid
=
$request
->
mis_uid
;
...
...
app/Http/Controllers/Api/Client/UsersController.php
View file @
482a3c3e
...
...
@@ -52,84 +52,4 @@ class UsersController extends Controller
}
/**
* 获取用户业务信息
* @param $request
* @param $params
* @return mixed
* @throws ControllerException
*/
private
function
getUserPrivilege
(
$request
,
$params
){
$request
->
replace
(
array_merge
(
$request
->
all
(),
$params
));
$catgList
=
MediaCategoryModel
::
get
()
->
toArray
();
$tmp
=
[];
foreach
(
$catgList
as
$key
=>
$catg
){
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'category_id'
=>
$catg
[
'media_category_id'
]]));
$url
=
getRbac
(
$request
,
'api/open/check'
,
$catg
[
'media_category_id'
]);
$data
[
'appid'
]
=
$catg
[
'media_category_id'
];
$data
[
'uid'
]
=
$request
->
mis_uid
;
$data
[
'tree'
]
=
1
;
$result
=
http_request_code
(
$url
,
null
,
'GET'
,
$data
);
$privilege
=
json_decode
(
$result
,
true
);
if
(
!
empty
(
$privilege
[
'data'
])){
array_push
(
$tmp
,
$catg
);
}
}
if
(
empty
(
$tmp
)){
LogModel
::
addlog
([
"暂无业务权限,请联系管理员"
,
$request
->
all
()]);
throw
new
ControllerException
(
'暂无业务权限,请联系管理员'
,
403
);
}
return
$tmp
;
}
/**
* 生成UUID标识并检测UUID是否重复
*/
private
function
generateToken
(
$len
=
32
,
$md5
=
true
)
{
# Seed random number generator
# Only needed for PHP versions prior to 4.2
mt_srand
(
(
double
)
microtime
()
*
1000000
);
# Array of characters, adjust as desired
$chars
=
array
(
'Q'
,
'@'
,
'8'
,
'y'
,
'%'
,
'^'
,
'5'
,
'Z'
,
'('
,
'G'
,
'_'
,
'O'
,
'`'
,
'S'
,
'-'
,
'N'
,
'<'
,
'D'
,
'{'
,
'}'
,
'['
,
']'
,
'h'
,
';'
,
'W'
,
'.'
,
'/'
,
'|'
,
':'
,
'1'
,
'E'
,
'L'
,
'4'
,
'&'
,
'6'
,
'7'
,
'#'
,
'9'
,
'a'
,
'A'
,
'b'
,
'B'
,
'~'
,
'C'
,
'd'
,
'>'
,
'e'
,
'2'
,
'f'
,
'P'
,
'g'
,
')'
,
'?'
,
'H'
,
'i'
,
'X'
,
'U'
,
'J'
,
'k'
,
'r'
,
'l'
,
'3'
,
't'
,
'M'
,
'n'
,
'='
,
'o'
,
'+'
,
'p'
,
'F'
,
'q'
,
'!'
,
'K'
,
'R'
,
's'
,
'c'
,
'm'
,
'T'
,
'v'
,
'j'
,
'u'
,
'V'
,
'w'
,
','
,
'x'
,
'I'
,
'$'
,
'Y'
,
'z'
,
'*'
);
# Array indice friendly number of chars;
$numChars
=
count
(
$chars
)
-
1
;
$token
=
''
;
# Create random token at the specified length
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
$token
.=
$chars
[
mt_rand
(
0
,
$numChars
)
];
# Should token be run through md5?
if
(
$md5
)
{
# Number of 32 char chunks
$chunks
=
ceil
(
strlen
(
$token
)
/
32
);
$md5token
=
''
;
# Run each chunk through md5
for
(
$i
=
1
;
$i
<=
$chunks
;
$i
++
)
$md5token
.=
md5
(
substr
(
$token
,
$i
*
32
-
32
,
32
)
);
# Trim the token
$token
=
substr
(
$md5token
,
0
,
$len
);
}
return
$token
;
}
}
app/Http/Controllers/Web/PrivilegeController.php
View file @
482a3c3e
...
...
@@ -20,10 +20,11 @@ class PrivilegeController extends Controller
{
$url
=
getRbac
(
$request
,
'api/open/check'
);
$data
[
'appid'
]
=
$request
->
category_
id
;
$data
[
'appid'
]
=
$request
->
app
id
;
$data
[
'uid'
]
=
Auth
::
user
()
->
mis_uid
;
$data
[
'tree'
]
=
1
;
$result
=
http_request_code
(
$url
,
null
,
'GET'
,
...
...
app/Model/MediaCategoryModel.php
View file @
482a3c3e
...
...
@@ -28,15 +28,9 @@ class MediaCategoryModel extends Eloquent
public
static
function
catgList
(
$request
){
try
{
$catgList
=
MediaCategoryModel
::
get
()
->
toArray
();
$ids
=
array_column
(
$catgList
,
"media_category_id"
);
/**
* 获取用户业务线及对应业务线的权限
*/
$url
=
getRbac
(
$request
,
'api/open/getPlatform'
,
'ec8747abc5dbe8288e64f327a76ac517'
);
$result
=
http_request_code
(
$url
,
array
(
...
...
@@ -56,11 +50,16 @@ class MediaCategoryModel extends Eloquent
}
$catgs
=
$catgs
[
'data'
];
$catgList
=
MediaCategoryModel
::
get
()
->
toArray
();
$appids
=
array_column
(
$catgs
[
'data'
],
"appid"
);
$tmp
=
[];
foreach
(
$catgs
as
$key
=>
$catg
){
if
(
in_array
(
$catg
[
'appid'
],
$ids
)){
foreach
(
$catgList
as
$catg
){
if
(
in_array
(
$catg
[
'media_category_id'
],
$appids
)){
array_push
(
$tmp
,
$catg
);
}
}
...
...
app/Model/UserModel.php
View file @
482a3c3e
...
...
@@ -352,7 +352,7 @@ class UserModel extends Authenticatable
$tmp
=
[];
foreach
(
$catgList
as
$key
=>
$catg
){
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'
category_
id'
=>
$catg
[
'media_category_id'
]]));
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'
app
id'
=>
$catg
[
'media_category_id'
]]));
$url
=
getRbac
(
$request
,
'api/open/check'
,
$catg
[
'media_category_id'
]);
...
...
resources/views/admin/index.blade.php
View file @
482a3c3e
...
...
@@ -78,7 +78,7 @@
<div
class=
"row"
id=
"report4"
>
@foreach($catgs as $catg)
<div
class=
"col-md-4"
onclick=
"important_task('/web/privilege','{{$catg["
app
id
"]}}')"
>
<div
class=
"col-md-4"
onclick=
"important_task('/web/privilege','{{$catg["
_id
"]}}','{{$
catg
["
media_category_
id
"]}}')"
>
<div
class=
"card text-center social-bottom sb-in"
>
<i
class=
"fa fa-instagram"
></i>
{{--
<div>
500 +
</div>
--}}
...
...
@@ -115,15 +115,10 @@
<!--Core Javascript -->
<script>
function
important_task
(
url
,
category_id
){
function
important_task
(
url
,
category_id
,
appid
){
$
.
cookie
(
'media_category_id'
,
category_id
)
window
.
location
.
href
=
url
+
'?category_id='
+
category_id
;
window
.
location
.
href
=
url
+
'?category_id='
+
category_id
+
'&appid='
+
appid
;
}
// var mainContent = document.getElementById('mainContent');
// mainContent.src = "http://baidu.com.cn"//嵌套网址
</script>
...
...
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