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
29159581
Commit
29159581
authored
Jul 03, 2020
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
d4605eef
Pipeline
#9789
passed with stages
in 32 seconds
Changes
10
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
156 additions
and
29 deletions
+156
-29
Handler.php
app/Exceptions/Handler.php
+7
-0
MediaController.php
app/Http/Controllers/Api/Client/MediaController.php
+30
-4
MediaController.php
app/Http/Controllers/Api/MediaController.php
+52
-0
MediaController.php
app/Http/Controllers/Web/MediaController.php
+10
-1
MediaModel.php
app/Model/MediaModel.php
+44
-20
QiniuModel.php
app/Model/QiniuModel.php
+1
-1
403.png
public/images/403.png
+0
-0
404.png
public/images/404.png
+0
-0
media_list.blade.php
resources/views/admin/media/media_list.blade.php
+1
-3
api.php
routes/api.php
+11
-0
No files found.
app/Exceptions/Handler.php
View file @
29159581
...
...
@@ -62,11 +62,15 @@ class Handler extends ExceptionHandler
&&
(
$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
)
)
{
echo
555
;
die
;
if
(
view
()
->
exists
(
'errors.404'
))
{
return
response
()
->
view
(
'errors.404'
);
}
}
if
(
self
::
handlerException
(
$exception
))
{
# 获取常量类里面的异常常量
$message
=
json_decode
(
$exception
->
getMessage
(),
true
);
...
...
@@ -81,14 +85,17 @@ class Handler extends ExceptionHandler
}
}
if
(
$request
->
is
(
'api/*'
))
{
return
error
(
'服务器请求异常:'
.
$exception
->
getMessage
()
.
"异常信息详情:"
.
$exception
->
getTraceAsString
(),
500
);
}
else
{
if
(
$exception
->
getMessage
()
!=
''
)
{
//print_r($exception->getMessage());
if
(
$exception
->
getMessage
()
==
403
)
{
return
response
()
->
view
(
'errors.403'
);
}
return
response
()
->
view
(
'errors.404'
);
}
#return response()->json(['code'=>403, 'msg'=>'您没有权限']);
...
...
app/Http/Controllers/Api/Client/MediaController.php
View file @
29159581
...
...
@@ -2,12 +2,12 @@
namespace
App\Http\Controllers\Api\Client
;
use
App\Model\MediaModel
;
use
App\Model\QiniuModel
;
use
App\Tool\SrsHookValidate
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
Qiniu\Auth
;
class
MediaController
extends
Controller
{
private
$bucketList
=
[
...
...
@@ -41,17 +41,43 @@ class MediaController extends Controller
$result
=
handler_drive
(
function
()
use
(
$request
)
{
$branch
=
empty
(
getenv
(
'branch'
))
?
'test'
:
getenv
(
'branch'
);
$token
=
QiniuModel
::
uploadToken
(
$this
->
bucketList
[
$branch
]);
SrsHookValidate
::
srsHookCallback
(
$request
,[
'key'
=>
''
]);
$key
=
$request
->
key
??
''
;
$token
=
QiniuModel
::
uploadToken
(
$this
->
bucketList
[
$branch
],
$key
);
return
[
"token"
=>
$token
];
});
return
success
(
$result
);
}
public
function
hookRestoreMedia
(
Request
$request
){
$id
=
handler_drive
(
function
()
use
(
$request
)
{
SrsHookValidate
::
srsHookCallback
(
$request
,[
'media_name'
=>
'required'
,
'media_type'
=>
'required'
,
'media_id'
=>
'required'
,
'access_key'
=>
''
,
'secret_key'
=>
''
,
'media_url'
=>
'required'
,
]);
$id
=
MediaModel
::
hookRestoreMedia
(
$request
);
return
$id
;
});
return
success
(
$id
);
}
public
function
uploadMedia
(
Request
$request
){
}
}
app/Http/Controllers/Api/MediaController.php
0 → 100644
View file @
29159581
<?php
namespace
App\Http\Controllers\Api
;
use
App\Model\QiniuModel
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
Qiniu\Auth
;
class
MediaController
extends
Controller
{
private
$bucketList
=
[
'develop'
=>
'dev-offcncloud'
,
'test'
=>
'test-offcncloud'
,
'master'
=>
'offcncloud'
,
];
/**
* 获取媒资ID
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public
function
index
(
Request
$request
){
$result
=
handler_drive
(
function
()
use
(
$request
)
{
return
[
"mediaID"
=>
'mda-'
.
generateRandomNum
(
16
)];
});
return
success
(
$result
);
}
public
function
mediaIdList
(){
}
}
app/Http/Controllers/Web/MediaController.php
View file @
29159581
...
...
@@ -8,7 +8,7 @@ use App\Http\Controllers\Controller;
class
MediaController
extends
Controller
{
public
static
function
index
(
Request
$request
){
public
function
index
(
Request
$request
){
$medias
=
MediaModel
::
mediaList
(
$request
);
...
...
@@ -23,5 +23,14 @@ class MediaController extends Controller
}
public
function
edit
(
Request
$request
){
}
}
app/Model/MediaModel.php
View file @
29159581
...
...
@@ -24,43 +24,67 @@ class MediaModel extends Eloquent
$where
[
'name'
]
=
$request
->
name
;
}
$medias
=
DB
::
connection
(
'mongodb'
)
->
collection
(
'media'
)
->
where
(
$where
)
->
paginate
(
10
);
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
// MediaModel::insertGetId([
//
// "_id" => 'mda-'.generateRandomNum(16),
// "url" => 'http://www.baidu.com',
// "QR_code"=> 'test',
// 'video_url'=>"http://www.sfdjlsdjflsaj,coanldsfjsalj.sdafljasdofjasp",
// "create_time" => date("Y-m-d H:i:s",time())
//
// ]);
//
// var_dump("fsd");die;
return
$medias
;
}
/**
* 存储媒资数据
* @param $request
* @return mixed
* @throws DatabaseException
*/
public
static
function
hookRestoreMedia
(
$request
){
try
{
/**
* 判断媒资ID是否存在
*/
$media_id
=
$request
->
media_id
;
$media
=
MediaModel
::
find
(
$media_id
);
if
(
$media
){
throw
new
\Exception
(
'媒资已经存在'
);
}
//hb15011&河北公务员考试试题
/**
* 媒资名称是由课程编号与课程名称组成
*/
$media_info
=
explode
(
"&"
,
$request
->
media_name
);
$medias
=
DB
::
connection
(
'mongodb'
)
->
collection
(
'media'
)
->
where
(
$where
)
->
paginate
(
10
);
// foreach ( $medias as &$user){
// $idArr = ($user['_id'])->jsonSerialize();
// $user['_id'] = $idArr['$oid'];
// }
$data
=
[
'_id'
=>
$media_id
,
'media_name'
=>
$request
->
media_name
,
'media_type'
=>
$request
->
media_type
??
'一题一码'
,
'class_id'
=>
$media_info
[
0
],
'class_name'
=>
$media_info
[
1
],
'media_url'
=>
$request
->
media_url
,
'access_key'
=>
$request
->
access_key
,
'secret_key'
=>
$request
->
secret_key
,
'create_time'
=>
date
(
'Y-m-d H:i:s'
,
time
())
];
$id
=
MediaModel
::
insertGetId
(
$data
);
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$medias
;
return
$id
;
}
}
app/Model/QiniuModel.php
View file @
29159581
...
...
@@ -11,7 +11,7 @@ namespace App\Model;
final
class
QiniuModel
{
private
static
$accessKey
=
"5ClMHcAd5KN6oN6SC7ni7uuwOOpaSvoDRMHR_3l8"
;
private
static
$secretKey
=
"
saqgin-1cokqa-gipbI
v"
;
private
static
$secretKey
=
"
xoJZ_3crOqMOsznLU8lbjlNU8pXJwEq5-n5vd3F
v"
;
// public function __construct($accessKey, $secretKey)
// {
...
...
public/images/403.png
0 → 100755
View file @
29159581
141 KB
public/images/404.png
0 → 100755
View file @
29159581
172 KB
resources/views/admin/media/media_list.blade.php
View file @
29159581
...
...
@@ -55,7 +55,6 @@
<th>
序号
</th>
<th>
媒资编号
</th>
<th>
视频地址
</th>
<th>
二维码
</th>
<th>
创建时间
</th>
<th>
操作
</th>
</tr>
...
...
@@ -67,8 +66,7 @@
<tr
class=
"
<?php
if
(
$key
%
2
==
0
)
echo
'table-success'
;
?>
"
>
<td>
{{$key+1}}
</td>
<td
style=
"max-width: 150px;"
>
{{$media['_id']}}
</td>
<td
style=
"max-width: 300px;"
>
{{$media['video_url']}}
</td>
<td>
{{$media['QR_code']}}
</td>
<td
style=
"max-width: 300px;"
>
{{$media['media_url']}}
</td>
<td
style=
"max-width: 100px;"
>
{{$media['create_time']}}
</td>
<td
class=
"td-manage"
>
...
...
routes/api.php
View file @
29159581
...
...
@@ -26,6 +26,16 @@ Route::group(['namespace' => 'Api', 'prefix' => 'v1', 'middleware' => ['auth']],
Route
::
get
(
'media_catg'
,
'Client\MediaCategoryController@index'
);
Route
::
get
(
'generate_media_id'
,
'Client\MediaController@index'
);
Route
::
get
(
'upload_token'
,
'Client\MediaController@getUploadMediaToken'
);
Route
::
post
(
'hook_restore'
,
'Client\MediaController@hookRestoreMedia'
);
});
Route
::
group
([
'namespace'
=>
'Api'
,
'prefix'
=>
'v1'
,
'middleware'
=>
[
'auth'
]],
function
()
{
});
\ No newline at end of file
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