Commit 9401382b by 杨昕

更新媒资信息

parent 7ac7df1e
Pipeline #9828 passed with stages
in 34 seconds
......@@ -85,6 +85,37 @@ class MediaController extends Controller
}
/**
* 更新媒资信息
* @param Request $request
* @param $id
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function updatehookMedia(Request $request,$id){
$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::updatehookMedia($request);
return $id;
});
return success($id);
}
/**
* 测试上传文件
* @param Request $request
*/
......
......@@ -65,10 +65,6 @@ class MediaModel extends Eloquent
* 判断媒资ID是否存在
*/
$media_id = $request->media_id;
$media = MediaModel::find($media_id);
if (!empty($media)){
throw new \Exception('媒资已经存在');
}
//hb15011&河北公务员考试试题
/**
......@@ -124,6 +120,34 @@ class MediaModel extends Eloquent
}
/**
* 更新媒资信息
* @param $request
* @param $id
* @return mixed
* @throws DatabaseException
*/
public static function updatehookMedia($request,$id){
try{
$media = MediaModel::find($id);
if (empty($media)){
throw new \Exception("媒资不存在");
}
$flag = MediaModel::where("_id",$id)->update($request->all());
if (!$flag){
throw new \Exception("更新失败");
}
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $flag;
}
/**
* 获取媒资详情
* @param $id
* @return mixed
......
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