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
44bd8ce9
Commit
44bd8ce9
authored
May 20, 2021
by
杨昕
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'master'
Test See merge request
!37
parents
831471fd
bb2f471b
Pipeline
#14731
canceled with stages
in 41 seconds
Changes
14
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
187 additions
and
177 deletions
+187
-177
Handler.php
app/Exceptions/Handler.php
+33
-16
functions.php
app/Helpers/functions.php
+5
-7
MediaController.php
app/Http/Controllers/Api/Client/MediaController.php
+2
-0
MediaController.php
app/Http/Controllers/Api/MediaController.php
+9
-2
LoginController.php
app/Http/Controllers/Web/LoginController.php
+27
-10
MediaCategoryController.php
app/Http/Controllers/Web/MediaCategoryController.php
+2
-1
MediaController.php
app/Http/Controllers/Web/MediaController.php
+1
-0
ApiMiddleware.php
app/Http/Middleware/ApiMiddleware.php
+42
-14
MediaCategoryModel.php
app/Model/MediaCategoryModel.php
+23
-0
MediaModel.php
app/Model/MediaModel.php
+15
-36
UserModel.php
app/Model/UserModel.php
+19
-19
media_category.json
public/media_category.json
+0
-12
list.blade.php
resources/views/admin/media_category/list.blade.php
+2
-54
web.php
routes/web.php
+7
-6
No files found.
app/Exceptions/Handler.php
View file @
44bd8ce9
...
...
@@ -6,6 +6,8 @@ use Exception;
use
App\Tool\ToolFunc
;
use
Illuminate\Auth\AuthenticationException
;
use
Illuminate\Foundation\Exceptions\Handler
as
ExceptionHandler
;
use
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
;
use
Symfony\Component\Routing\Exception\MethodNotAllowedException
;
class
Handler
extends
ExceptionHandler
{
...
...
@@ -61,36 +63,45 @@ class Handler extends ExceptionHandler
// var_dump($exception->getLine());
#
检测当前请求是否是api路由
#
处理api请求404异常
if
(
stripos
(
$path
,
'api/'
)
===
0
&&
(
$exception
instanceof
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
)
)
{
return
error
(
'resources not found'
,
\Symfony\Component\HttpFoundation\Response
::
HTTP_NOT_FOUND
);
}
if
(
(
(
stripos
(
$path
,
'web/'
)
===
0
&&
strrpos
(
$path
,
'.php'
)
!==
false
)
||
(
stripos
(
$path
,
'web/'
)
===
0
&&
strrpos
(
$path
,
'.html'
)
!==
false
)
)
&&
(
$exception
instanceof
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
)
)
{
#处理web请求404异常
if
(
stripos
(
$path
,
'web/'
)
===
0
&&
(
$exception
instanceof
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
)
)
{
if
(
view
()
->
exists
(
'errors.404'
))
{
return
response
()
->
view
(
'errors.404'
);
}
}
/**
* 处理自定义异常
*/
if
(
self
::
handlerException
(
$exception
))
{
# 获取常量类里面的异常常量
$message
=
json_decode
(
$exception
->
getMessage
(),
true
);
return
error
(
...
$message
);
}
else
if
(
$exception
instanceof
AuthenticationException
)
{
return
error
(
$exception
->
getMessage
(),
\Symfony\Component\HttpFoundation\Response
::
HTTP_UNAUTHORIZED
);
}
else
if
(
$exception
instanceof
\Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
)
{
return
error
(
'请求方法不被允许'
,
\Symfony\Component\HttpFoundation\Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
else
if
(
$exception
instanceof
\Symfony\Component\HttpKernel\Exception\HttpException
)
{
if
(
$exception
->
getMessage
()
==
'Too Many Attempts.'
)
{
return
error
(
'请求接口过于频繁'
,
429
);
}
}
else
if
(
$exception
instanceof
\RedisException
){
return
error
(
'redis连接异常'
);
}
if
(
$request
->
is
(
'api/*'
))
{
if
(
$request
->
is
(
'api/*'
)
)
{
/**
* Api异常处理模块
*/
if
(
$exception
instanceof
AuthenticationException
)
{
return
error
(
$exception
->
getMessage
(),
\Symfony\Component\HttpFoundation\Response
::
HTTP_UNAUTHORIZED
);
}
else
if
(
$exception
instanceof
\Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
)
{
return
error
(
'请求方法不被允许'
,
\Symfony\Component\HttpFoundation\Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
else
if
(
$exception
instanceof
\Symfony\Component\HttpKernel\Exception\HttpException
)
{
if
(
$exception
->
getMessage
()
==
'Too Many Attempts.'
)
{
return
error
(
'请求接口过于频繁'
,
429
);
}
}
else
if
(
$exception
instanceof
\RedisException
){
return
error
(
'redis连接异常'
);
}
return
error
(
'服务器请求异常:'
.
$exception
->
getMessage
()
.
"异常信息详情:"
.
$exception
->
getTraceAsString
(),
500
);
}
else
{
...
...
@@ -99,11 +110,17 @@ class Handler extends ExceptionHandler
if
(
$exception
->
getMessage
()
==
403
)
{
return
response
()
->
view
(
'errors.403'
);
}
//return response()->view('errors.404');
}
else
if
(
$exception
instanceof
\Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
){
return
response
()
->
view
(
'errors.403'
);
}
else
{
return
response
()
->
view
(
'errors.404'
);
}
//return error($exception->getMessage());
#return response()->json(['code'=>403, 'msg'=>'您没有权限']);
}
return
parent
::
render
(
$request
,
$exception
);
return
parent
::
render
(
$request
,
$exception
);
}
}
app/Helpers/functions.php
View file @
44bd8ce9
...
...
@@ -345,14 +345,10 @@ function generateRandomNum( $len = 32, $md5 = true ) {
function
getRbac
(
$request
,
$url
=
'api/ram'
,
$appid
=
''
,
$type
=
'base'
){
if
(
$appid
){
$appid
=
$appid
;
}
else
{
if
(
!
$appid
){
$appid
=
$request
->
appid
??
""
;
}
$mis_uid
=
$request
->
mis_uid
;
//https://api.eoffcn.com/demo/get?t=xx&sign=xx&ak=xx
//其中sign=md5(ak=$ak&t=时间戳&sk=$sk)
...
...
@@ -367,13 +363,14 @@ function getRbac($request,$url='api/ram',$appid = '' ,$type='base'){
$sign
=
md5
(
'ak='
.
$rbac_ak
.
'&t='
.
$time
.
'&sk='
.
$rbac_sk
);
switch
(
$type
){
#获取用户业务权限
case
'base'
:
$mis_uid
=
$request
->
mis_uid
;
$rbac_url
=
$rbac
.
'/rbac/'
.
$url
.
'?t='
.
$time
.
'&sign='
.
$sign
.
'&ak='
.
$rbac_ak
.
'&appid='
.
$appid
.
'&uid='
.
$mis_uid
;
break
;
case
'mis_user'
:
//获取mis员工基本信息
$staffNo
=
$request
->
username
;
$staffNo
=
$request
->
staffNo
;
//员工工号
$rbac_url
=
$rbac
.
'/rbac/'
.
$url
.
'?t='
.
$time
.
'&sign='
.
$sign
.
'&ak='
.
$rbac_ak
.
'&staffNo='
.
$staffNo
;
break
;
#清除CND缓存
...
...
@@ -391,6 +388,7 @@ function getRbac($request,$url='api/ram',$appid = '' ,$type='base'){
break
;
default
:
$mis_uid
=
$request
->
mis_uid
;
$rbac_url
=
$rbac
.
'/rbac/'
.
$url
.
'?t='
.
$time
.
'&sign='
.
$sign
.
'&ak='
.
$rbac_ak
.
'&appid='
.
$appid
.
'&uid='
.
$mis_uid
;
}
...
...
app/Http/Controllers/Api/Client/MediaController.php
View file @
44bd8ce9
...
...
@@ -120,6 +120,8 @@ class MediaController extends Controller
'end_time.after_or_equal'
=>
'结束时间不能小于开始时间'
]);
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'status'
=>
"1"
]));
$id
=
MediaModel
::
hookRestoreMedia
(
$request
);
...
...
app/Http/Controllers/Api/MediaController.php
View file @
44bd8ce9
...
...
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use
App\Exceptions\FormException
;
use
App\Model\LogModel
;
use
App\Model\MediaCategoryModel
;
use
App\Model\MediaModel
;
use
App\Model\QiniuModel
;
use
App\Tool\Constant
;
...
...
@@ -186,9 +187,10 @@ class MediaController extends Controller
);
//shop_id为100时,代表的是北大学堂的视频
if
(
$request
->
shop_id
==
'100'
){
$params
[
'media_type'
]
=
"5f3d073a033f5a336b2b4346"
;
$catg
=
MediaCategoryModel
::
getCategoryByName
(
"北大学堂"
);
$params
[
'media_type'
]
=
$catg
[
'_id'
];
}
$request
->
replace
(
array_merge
(
$request
->
all
(),
$params
));
...
...
@@ -293,6 +295,11 @@ class MediaController extends Controller
}
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public
function
getMediaForeverM3u8
(
Request
$request
){
$data
=
handler_drive
(
function
()
use
(
$request
)
{
...
...
app/Http/Controllers/Web/LoginController.php
View file @
44bd8ce9
...
...
@@ -32,6 +32,7 @@ class LoginController extends Controller
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
* @throws ControllerException
*/
public
function
login
(
Request
$request
)
{
...
...
@@ -47,24 +48,40 @@ class LoginController extends Controller
throw
new
ControllerException
(
400
,
'昵称必须填写'
);
}
$len
=
strlen
(
$request
->
username
);
if
(
$len
<
5
){
throw
new
\Exception
(
'用户名称长度不能小于5个字符'
);
}
/**
* 用户名称是有四部分组成,姓名-新账号-旧账号-mis_uid
*/
* 用户名称是有三部分组成,姓名-新账号-旧账号
* user用户名称有两种类型的账号,早期账号用户名称只有员工旧账户,二期项目用户名称由三部分组成
**/
$user
=
UserModel
::
where
(
'name'
,
'regexp'
,
'/^.*?'
.
$request
->
username
.
'/'
)
->
first
();
if
(
!
empty
(
$user
)){
//1.处理二期之后新用户名称
$temp
=
explode
(
"-"
,
$user
[
"name"
]);
if
(
count
(
$temp
)
>
1
){
if
(
!
in_array
(
$request
->
username
,
array_slice
(
$temp
,
1
))){
throw
new
\Exception
(
"用户名或者密码有误"
);
}
}
else
{
if
(
$request
->
username
!=
$user
->
name
){
throw
new
\Exception
(
"用户名或者密码有误"
);
}
}
if
(
md5
(
$request
->
password
)
!=
$user
->
password
){
throw
new
\Exception
(
'用户名或者密码有误'
);
}
//为了媒资新旧账号统一,需要以员工mis编号作为用户唯一标识符
if
(
!
$user
->
mis_uid
){
/**
* 获取mis用户信息
*/
$userInfo
=
UserModel
::
getMisInfo
(
$request
);
$request
->
replace
(
array_merge
(
$request
->
all
(),[
"staffNo"
=>
$request
->
username
]));
#获取mis用户信息
$userInfo
=
UserModel
::
getMisInfo
(
$request
);
$userid
=
$userInfo
[
'userId'
];
$flag
=
UserModel
::
where
(
"_id"
,
$user
->
_id
)
->
update
([
'mis_uid'
=>
$userid
]);
...
...
@@ -72,12 +89,12 @@ class LoginController extends Controller
LogModel
::
addlog
([
'更新用户mis_uid失败'
=>
json_encode
([
'mis_uid'
=>
$userid
])]);
throw
new
\Exception
(
"更新用户mis_uid失败"
);
}
}
}
else
{
//新用户第一次登录,直接往媒资注册
$request
->
replace
(
array_merge
(
$request
->
all
(),[
"staffNo"
=>
$request
->
username
]));
$userInfo
=
UserModel
::
getMisInfo
(
$request
);
$mis_uid
=
$userInfo
[
"userId"
];
...
...
@@ -89,7 +106,7 @@ class LoginController extends Controller
}
$data_arr
=
[
'name'
=>
$userInfo
[
'nickName'
],
'name'
=>
$userInfo
[
'nickName'
],
//包含了三部分数据,姓名-新账号-旧账号
'password'
=>
md5
(
$request
->
password
),
'organization_id'
=>
0
,
'status'
=>
0
,
...
...
app/Http/Controllers/Web/MediaCategoryController.php
View file @
44bd8ce9
...
...
@@ -110,7 +110,8 @@ class MediaCategoryController extends Controller
$id
=
$request
->
id
;
SrsHookValidate
::
srsHookCallback
(
$request
,[
'status'
=>
''
,
'status'
=>
''
,
'id'
=>
''
]);
MediaCategoryModel
::
disable
(
$request
,
$id
);
...
...
app/Http/Controllers/Web/MediaController.php
View file @
44bd8ce9
...
...
@@ -143,6 +143,7 @@ class MediaController extends Controller
'start_time'
=>
$data_time
,
'end_time'
=>
$data_time
,
'create_time'
=>
$data_time
,
'status'
=>
"1"
,
);
$request
->
replace
(
array_merge
(
$request
->
all
(),
$params
));
...
...
app/Http/Middleware/ApiMiddleware.php
View file @
44bd8ce9
...
...
@@ -3,7 +3,10 @@
namespace
App\Http\Middleware
;
use
App\Exceptions\ControllerException
;
use
App\Exceptions\DatabaseException
;
use
App\Model\LogModel
;
use
App\Model\MediaCategoryModel
;
use
App\Model\UserModel
;
use
Closure
;
use
Illuminate\Http\Response
;
use
Illuminate\Support\Facades\Auth
;
...
...
@@ -12,11 +15,10 @@ use Illuminate\Support\Facades\Redirect;
class
ApiMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
* @param $request
* @param Closure $next
* @return \Illuminate\Http\RedirectResponse|mixed
* @throws \Exception
*/
public
function
handle
(
$request
,
Closure
$next
)
{
...
...
@@ -32,25 +34,51 @@ class ApiMiddleware
}
$ajax
=
$request
->
ajax
();
$user
=
Auth
::
user
();
if
(
empty
(
$user
)){
if
(
$ajax
){
return
error
(
Response
::
HTTP_UNAUTHORIZED
);
}
return
Redirect
::
to
(
"web/logout"
);
}
if
(
$request
->
category_id
){
$mediaCatg
=
MediaCategoryModel
::
where
(
"_id"
,
$request
->
category_id
)
->
first
();
if
(
empty
(
$mediaCatg
)){
return
error
(
"类别不存在"
);
}
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'catetory_name'
=>
$mediaCatg
->
name
]));
}
if
(
isset
(
$user
->
mis_uid
)){
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'mis_uid'
=>
$user
->
mis_uid
]));
}
if
(
empty
(
$user
->
name
)){
if
(
$ajax
){
throw
new
ControllerException
(
Response
::
HTTP_UNAUTHORIZED
);
if
(
$user
->
mis_uid
){
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'mis_uid'
=>
$user
->
mis_uid
,
]));
}
else
{
$username
=
$user
->
name
;
$staffNo
=
substr
(
$username
,
strrpos
(
$username
,
"-"
));
$request
->
replace
(
array_merge
(
$request
->
all
(),[
"staffNo"
=>
$staffNo
]));
/**
* 获取mis用户信息
*/
$userInfo
=
UserModel
::
getMisInfo
(
$request
);
$userid
=
$userInfo
[
'userId'
];
$flag
=
UserModel
::
where
(
"_id"
,
$user
->
_id
)
->
update
([
'mis_uid'
=>
$userid
]);
if
(
!
$flag
){
LogModel
::
addlog
([
'更新用户mis_uid失败'
=>
json_encode
([
'mis_uid'
=>
$userid
])]);
return
error
(
"更新用户mis_uid失败"
);
}
return
Redirect
::
to
(
"web/logout"
);
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'mis_uid'
=>
$user
->
mis_uid
]));
}
return
$next
(
$request
);
...
...
app/Model/MediaCategoryModel.php
View file @
44bd8ce9
...
...
@@ -113,6 +113,7 @@ class MediaCategoryModel extends Eloquent
'media_category_id'
=>
$request
->
media_category_id
??
''
,
'description'
=>
$request
->
description
??
''
,
'create_time'
=>
$create_time
,
"call_back"
=>
$request
->
call_back
??
"media/cleanCache"
];
$mediaCatg
=
MediaCategoryModel
::
where
(
'name'
,
$request
->
name
)
->
first
();
...
...
@@ -200,4 +201,26 @@ class MediaCategoryModel extends Eloquent
return
$flag
;
}
/**
* 根据媒资名称,获取媒资信息。
* @param $name
* @return mixed
* @throws DatabaseException
*/
public
static
function
getCategoryByName
(
$name
){
try
{
$catg
=
MediaCategoryModel
::
where
(
"name"
,
$name
)
->
first
();
if
(
empty
(
$catg
)){
throw
new
\Exception
(
"店铺不存在"
);
}
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$catg
;
}
}
app/Model/MediaModel.php
View file @
44bd8ce9
...
...
@@ -63,8 +63,8 @@ class MediaModel extends Eloquent
}
$match
=
[
'status'
=>
[
"
\$
in"
=>
[
null
,
"1"
]]
,
"media_url"
=>
[
"
\$
ne"
=>
'null'
]
'status'
=>
"1"
,
//
"media_url" => ["\$ne" => 'null']
];
if
(
isset
(
$request
->
media_id
)
&&
!
empty
(
$request
->
media_id
)){
...
...
@@ -96,28 +96,14 @@ class MediaModel extends Eloquent
if
(
isset
(
$request
->
end_time
)
&&
!
empty
(
$request
->
end_time
)){
$end_time
=
new
UTCDateTime
(
strtotime
(
$request
->
end_time
)
*
1000
);;
$match
[
'
$match'
][
'
end_time'
]
=
[
'$lt'
=>
$end_time
];
$match
[
'end_time'
]
=
[
'$lt'
=>
$end_time
];
}
$aggregate
[][
'$match'
]
=
$match
;
$aggregate1
=
$aggregate
;
$aggregate
[][
'$sort'
]
=
[
'start_time'
=>
$sort
];
$aggregate1
[][
'$group'
]
=
[
'_id'
=>
array
(),
//更具性别进行分组
'count'
=>
array
(
'$sum'
=>
1
)
];
$count
=
$collection
->
aggregate
(
$aggregate1
)
->
toArray
();
if
(
isset
(
$count
[
0
])){
$count
=
$count
[
0
][
'count'
];
}
else
{
$count
=
0
;
}
$count
=
MediaModel
::
where
(
$match
)
->
count
();
$skip
=
((
empty
(
$request
->
page
)
?
1
:
$request
->
page
)
-
1
)
*
$limit
;
...
...
@@ -192,19 +178,18 @@ class MediaModel extends Eloquent
throw
new
\Exception
(
"媒资类别不存在"
);
}
//replace 不为空的时候代表做视频替换操作,1.需要清空CDN缓存,2.将原来的视频保存至回收站,3.更新视频信息
if
(
$request
->
replace
){
$recycleId
=
RecycleModel
::
addRecycle
(
$media_id
);
$call_back
=
$mediaCatg
[
'call_back'
];
#清空CND缓存
$url
=
getRbac
(
$request
,
$call_back
,
$mediaCatg
[
'media_category_id'
]
,
$type
=
'clear_cache'
);
http_request_code
(
$url
,
null
,
'POST'
,[
'mediaId'
=>
$media_id
]);
#更新视频信息
self
::
updatehookMedia
(
$request
,
$media_id
);
if
(
!
$recycleId
){
throw
new
\Exception
(
'回收站保存失败'
);
}
...
...
@@ -236,16 +221,6 @@ class MediaModel extends Eloquent
$end_time
=
new
UTCDateTime
(
strtotime
(
$request
->
end_time
)
*
1000
);
$create_time
=
new
UTCDateTime
(
time
()
*
1000
);;
// $start_time = $request->start_time;
// $end_time = $request->end_time;
// $create_time = date('Y-m-d H:i:s',time());
// if ($request->shop_id=='100'){
// $mediaCatg = MediaCategoryModel::where('_id','5f3d073a033f5a336b2b4346')->first();
// }
/**
* 处理文件名称,确认是否包含"&"符合
...
...
@@ -264,11 +239,13 @@ class MediaModel extends Eloquent
'secret_key'
=>
$request
->
secret_key
,
'create_time'
=>
$create_time
,
'description'
=>
$request
->
description
,
'username'
=>
$request
->
token_username
,
//员工工号
'username'
=>
$request
->
token_username
,
'user_id'
=>
$request
->
token_user_id
,
'mis_uid'
=>
$request
->
mis_uid
,
//员工工号
'start_time'
=>
$start_time
,
'end_time'
=>
$end_time
,
'duration'
=>
$request
->
duration
??
"0"
'duration'
=>
$request
->
duration
??
"0"
,
'status'
=>
$request
->
status
??
"0"
,
];
}
else
{
...
...
@@ -285,11 +262,13 @@ class MediaModel extends Eloquent
'secret_key'
=>
$request
->
secret_key
,
'create_time'
=>
$create_time
,
'description'
=>
$request
->
description
,
'username'
=>
$request
->
token_username
,
//员工工号
'username'
=>
$request
->
token_username
,
'user_id'
=>
$request
->
token_user_id
,
'mis_uid'
=>
$request
->
mis_uid
,
//员工工号
'start_time'
=>
$start_time
,
'end_time'
=>
$end_time
,
'duration'
=>
$request
->
duration
??
"0"
'duration'
=>
$request
->
duration
??
"0"
,
'status'
=>
$request
->
status
??
"0"
,
];
}
...
...
app/Model/UserModel.php
View file @
44bd8ce9
...
...
@@ -212,18 +212,20 @@ class UserModel extends Authenticatable
try
{
$password
=
strtolower
(
$request
->
password
);
$username
=
$request
->
username
;
$password
=
$request
->
password
;
$len
=
strlen
(
$username
);
if
(
$len
<
5
){
throw
new
\Exception
(
'用户名称长度不能小于5个字符'
);
}
/**
* 陈腾飞-ctf37800-ctf88614
-89043
* 用户名称是有
四部分组成,姓名-新账号-旧账号-mis_uid
* 陈腾飞-ctf37800-ctf88614
* 用户名称是有
三部分组成,姓名-新账号-旧账号
*/
$user
=
UserModel
::
where
(
'name'
,
'regexp'
,
'/^.*?'
.
$username
.
'/'
)
->
first
();
if
(
empty
(
$user
)
||
!
isset
(
$user
[
'mis_uid'
])){
if
(
empty
(
$user
)
||
!
isset
(
$user
[
'mis_uid'
])
||
$user
[
'mis_uid'
]
==
""
){
/**
* 获取mis用户基本信息
*/
...
...
@@ -233,8 +235,7 @@ class UserModel extends Authenticatable
// $data['type'] = 6;
// $data['username'] = $staffNo;
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'mis_uid'
=>
'000000'
]));
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'staffNo'
=>
$username
]));
$url
=
getRbac
(
$request
,
"api/mis/userinfo"
,
''
,
'mis_user'
);
$result
=
http_request_code
(
$url
,
...
...
@@ -243,21 +244,18 @@ class UserModel extends Authenticatable
);
$userInfo
=
json_decode
(
$result
,
true
);
if
(
empty
(
$userInfo
[
'data'
])){
LogModel
::
addlog
([
"获取用户信息失败"
,
$request
->
all
()]);
throw
new
\Exception
(
"获取用户信息失败"
);
if
(
$userInfo
[
'data'
][
"userId"
]
==
""
){
LogModel
::
addlog
([
"用户不存在"
,
$request
->
all
()]);
throw
new
\Exception
(
"用户不存在"
);
}
$userInfo
=
$userInfo
[
'data'
];
$userid
=
$userInfo
[
'userId'
];
//$result = self::getUserPrivilege($request,['mis_uid'=>$userid]);
if
(
empty
(
$user
)){
//杨帆-yf18512-yf60144-8086
$data_arr
=
[
'name'
=>
$userInfo
[
'nickName'
],
...
...
@@ -304,6 +302,7 @@ class UserModel extends Authenticatable
}
$result
=
self
::
getUserPrivilege
(
$request
,[
'mis_uid'
=>
$userid
]);
if
(
empty
(
$result
)){
LogModel
::
addlog
([
"暂无业务权限,请联系管理员"
,
$request
->
all
()]);
throw
new
\Exception
(
'暂无业务权限,请联系管理员'
,
403
);
...
...
@@ -345,14 +344,15 @@ class UserModel extends Authenticatable
$request
->
replace
(
array_merge
(
$request
->
all
(),
$params
));
$catgList
=
MediaCategoryModel
::
get
()
->
toArray
();
$catgList
=
MediaCategoryModel
::
where
(
"status"
,
0
)
->
get
()
->
toArray
();
$tmp
=
[];
foreach
(
$catgList
as
$key
=>
$catg
){
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'appid'
=>
$catg
[
'media_category_id'
]]));
$url
=
getRbac
(
$request
,
'api/open/check'
,
$catg
[
'media_category_id'
]
);
$url
=
getRbac
(
$request
,
'api/open/check'
);
$data
[
'appid'
]
=
$catg
[
'media_category_id'
];
$data
[
'uid'
]
=
$request
->
mis_uid
;
...
...
@@ -398,8 +398,8 @@ class UserModel extends Authenticatable
$data = sign($staffNo);
$data['type'] = 6;
$data['username'] = $staffNo;*/
$request
->
replace
(
array_merge
(
$request
->
all
(),[
'mis_uid'
=>
'000000'
]));
//第三方接口要求mis_uid是必填字段,第一次获取的时候默认传值000000
//
$request->replace(array_merge($request->all(),['mis_uid'=>'000000']));
$url
=
getRbac
(
$request
,
"api/mis/userinfo"
,
''
,
'mis_user'
);
...
...
@@ -410,7 +410,7 @@ class UserModel extends Authenticatable
$userInfo
=
json_decode
(
$result
,
true
);
if
(
empty
(
$userInfo
[
'data'
][
'userId'
])
){
if
(
!
$userInfo
[
'data'
][
'userId'
]
){
LogModel
::
addlog
([
"用户不存在"
,
$request
->
all
()]);
throw
new
\Exception
(
"用户不存在"
);
}
...
...
public/media_category.json
View file @
44bd8ce9
[{
"id"
:
2
,
"pid"
:
0
,
"name"
:
"权限管理"
,
"icon"
:
""
,
"link"
:
"/privilege"
,
"slug"
:
"privilege.index"
,
"description"
:
""
,
"show"
:
1
,
"sort"
:
1
,
"key_name"
:
"privilege"
,
"son"
:
[]
},
{
"id"
:
11
,
"pid"
:
0
,
"name"
:
"媒体资源上传"
,
...
...
resources/views/admin/media_category/list.blade.php
View file @
44bd8ce9
...
...
@@ -73,13 +73,9 @@
<a
title=
"编辑"
href=
"/web/media_category/{{$media_category['_id']}}/edit"
>
<i
class=
"iconfont"
>

</i>
</a>
{{--
<a
onclick=
"x_admin_show('修改密码','/web/password/{{$user->id}}',500,300)"
title=
"修改密码"
--
}}
{{
--href=
"javascript:;"
>
--}}
{{--
<i
class=
"iconfont"
>

</i>
--}}
{{--
<a
title=
"删除"
onclick=
"member_del(this,'{{$media_category["
_id
"]}}')"
href=
"javascript:;"
>
--}}
{{--
<i
class=
"iconfont"
>

</i>
--}}
{{--
</a>
--}}
<a
title=
"删除"
onclick=
"member_del(this,'{{$media_category["
_id
"]}}')"
href=
"javascript:;"
>
<i
class=
"iconfont"
>

</i>
</a>
</td>
</tr>
@endforeach
...
...
@@ -121,54 +117,6 @@
window
.
location
.
href
=
url
;
}
function
member_del
(
row
,
id
){
$
.
confirm
({
// confirmButtonClass: 'btn-info',
// cancelButtonClass: 'btn-info',
cancelButtonClass
:
'btn-info'
,
confirmButtonClass
:
'btn-danger'
,
content
:
'确认要刪除吗?'
,
confirmButton
:
'确认'
,
cancelButton
:
'取消'
,
confirm
:
function
()
{
fetch_response
(
'DELETE'
,
"/web/media_category/"
+
id
).
then
(
function
(
res
)
{
if
(
res
.
code
==
200
)
{
$
(
'body'
).
toast
({
position
:
'fixed'
,
content
:
res
.
msg
,
duration
:
1000
,
top
:
'50%'
});
setTimeout
(
function
()
{
window
.
location
.
href
=
'/web/media_category'
;
},
2000
)
}
else
{
$
(
'body'
).
toast
({
position
:
'fixed'
,
content
:
res
.
msg
,
duration
:
1000
,
top
:
'50%'
});
}
})
},
cancel
:
function
()
{
$
(
'body'
).
toast
({
position
:
'fixed'
,
content
:
'已取消'
,
duration
:
1000
,
top
:
'50%'
});
}
});
}
function
member_stop
(
obj
,
id
){
var
status
=
$
(
obj
).
attr
(
'status'
);
...
...
routes/web.php
View file @
44bd8ce9
...
...
@@ -17,11 +17,6 @@ use Illuminate\Support\Facades\Redirect;
// #Route::resource('member','MemberController');
//
//});
#跟目录跳转
Route
::
get
(
'/'
,
function
(){
return
Redirect
::
to
(
'web/login'
);
});
Route
::
group
([
'prefix'
=>
'web'
,
'middleware'
=>
[],
'namespace'
=>
'Web'
],
function
(){
#后台首页
...
...
@@ -32,7 +27,13 @@ Route::group(['prefix' => 'web','middleware'=>[],'namespace'=>'Web'],function(){
#根目录跳转
Route
::
get
(
'/'
,
function
()
{
return
Redirect
::
to
(
'web/login'
);
$user
=
\Illuminate\Support\Facades\Auth
::
user
();
if
(
empty
(
$user
)){
return
Redirect
::
to
(
'web/login'
);
}
return
Redirect
::
to
(
"/web/admin"
);
});
Route
::
get
(
'/web'
,
function
()
{
return
Redirect
::
to
(
'web/login'
);
...
...
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