Commit 6f6ee589 by 杨昕

根据媒资随机码获取媒资信息

parent c305d0a9
Pipeline #13712 passed with stages
in 42 seconds
......@@ -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);
}
}
......@@ -848,4 +848,57 @@ class MediaModel extends Eloquent
}
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;
}
}
......@@ -47,6 +47,8 @@ Route::group(['namespace' => 'Api', 'prefix' => 'user','middleware' => ['api']],
Route::post('update_status/{id}', 'MediaController@updateMediaStatus');
Route::get('update_datetime', 'MediaController@updateDatetime');
Route::get("get_media_by_num",'MediaController@getMediaInfoByNum');
//Route::get("media_url_change","MediaController@handleMediaUrl");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment