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
6f6ee589
Commit
6f6ee589
authored
Feb 03, 2021
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
根据媒资随机码获取媒资信息
parent
c305d0a9
Pipeline
#13712
passed with stages
in 42 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
0 deletions
+70
-0
MediaController.php
app/Http/Controllers/Api/MediaController.php
+15
-0
MediaModel.php
app/Model/MediaModel.php
+53
-0
api.php
routes/api.php
+2
-0
No files found.
app/Http/Controllers/Api/MediaController.php
View file @
6f6ee589
...
@@ -282,5 +282,20 @@ class MediaController extends Controller
...
@@ -282,5 +282,20 @@ class MediaController extends Controller
}
}
/**
*
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public
function
getMediaInfoByNum
(
Request
$request
){
$data
=
handler_drive
(
function
()
use
(
$request
)
{
return
MediaModel
::
getMediaInfoByNum
(
$request
);
});
return
success
(
$data
);
}
}
}
app/Model/MediaModel.php
View file @
6f6ee589
...
@@ -848,4 +848,57 @@ class MediaModel extends Eloquent
...
@@ -848,4 +848,57 @@ class MediaModel extends Eloquent
}
}
return
$flag
;
return
$flag
;
}
}
/**
* 根据媒资编号获取媒资随机码
* @param $request
* @return mixed
* @throws DatabaseException
*/
public
static
function
getMediaInfoByNum
(
$request
){
try
{
$media
=
MediaModel
::
select
(
'_id'
,
'secret_key'
,
'duration'
,
'media_name'
,
'status'
)
->
where
(
"media_num"
,
$request
->
media_num
)
->
first
();
if
(
empty
(
$media
)){
throw
new
\Exception
(
"媒资信息不存在"
);
}
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$media
;
}
/**
* @param $request
* @return mixed
* @throws DatabaseException
*/
public
static
function
clearCdnCache
(
$request
){
try
{
/**
* 判断媒资ID是否存在
*/
$media_id
=
$request
->
media_id
;
$media
=
MediaModel
::
where
(
"media_num"
,
$request
->
media_num
)
->
first
();
if
(
empty
(
$media
)){
throw
new
\Exception
(
"媒资信息不存在"
);
}
$media_type
=
$media
[
'media_type_id'
];
$mediaCatg
=
MediaCategoryModel
::
where
(
'_id'
,
$media_type
)
->
first
();
if
(
empty
(
$mediaCatg
)){
throw
new
\Exception
(
"媒资类别不存在"
);
}
$call_back
=
$mediaCatg
[
'call_back'
];
$url
=
getRbac
(
$request
,
$call_back
,
$mediaCatg
[
'media_category_id'
]
,
$type
=
'clear_cache'
);
http_request_code
(
$url
,
null
,
'POST'
,[
'mediaId'
=>
$media_id
]);
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$media
;
}
}
}
routes/api.php
View file @
6f6ee589
...
@@ -47,6 +47,8 @@ Route::group(['namespace' => 'Api', 'prefix' => 'user','middleware' => ['api']],
...
@@ -47,6 +47,8 @@ Route::group(['namespace' => 'Api', 'prefix' => 'user','middleware' => ['api']],
Route
::
post
(
'update_status/{id}'
,
'MediaController@updateMediaStatus'
);
Route
::
post
(
'update_status/{id}'
,
'MediaController@updateMediaStatus'
);
Route
::
get
(
'update_datetime'
,
'MediaController@updateDatetime'
);
Route
::
get
(
'update_datetime'
,
'MediaController@updateDatetime'
);
Route
::
get
(
"get_media_by_num"
,
'MediaController@getMediaInfoByNum'
);
//Route::get("media_url_change","MediaController@handleMediaUrl");
//Route::get("media_url_change","MediaController@handleMediaUrl");
...
...
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