Commit c305d0a9 by 杨昕

设置预留

parent fd9fc143
Pipeline #13711 passed with stages
in 42 seconds
......@@ -11,6 +11,11 @@ use App\Http\Controllers\Controller;
class MediaController extends Controller
{
private const PREVIEW_DOMAIN = [
'test' => 'preview.t.eoffcn.com',
'master' => 'preview.eoffcn.com'
];
/**
* 媒资列表
* @param Request $request
......@@ -175,8 +180,10 @@ class MediaController extends Controller
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function media_preview(Request $request){
return view('errors.404');
public function media_preview(Request $request,$mediaNum){
$branch = !empty(getenv('branch'))?getenv('branch'):"test";
$url = "http://".self::PREVIEW_DOMAIN[$branch].'/'.$mediaNum;
return redirect($url);
}
/**
......
......@@ -16,7 +16,7 @@ class MediaRoute extends AuthenRoute
parent::map($router,function() use ($router){
$router->resource('media_model','MediaController');
$router->get('media_command','MediaController@media_command');
$router->get('video_preview','MediaController@media_preview');
$router->get('video_preview/{media_num}','MediaController@media_preview');
$router->post('set_media_num','MediaController@setMediaNum');
});
......
......@@ -819,18 +819,14 @@ class MediaModel extends Eloquent
$media_id = "mda-".generateRandomNum(16);
$media = MediaModel::find($media_id);
$i ++;
} while ($i < 3 && !empty($media) );
if ($i == 3){
throw new \Exception('获取媒资编号失败');
}
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $media_id;
}
......@@ -844,7 +840,7 @@ class MediaModel extends Eloquent
try{
$media_id = $request->media_id;
$data = [
'media_num' => substr($media_id,4),
'media_num' => md5(md5($media_id)),
];
$flag = MediaModel::where("_id",$media_id)->update($data);
}catch (\Exception $exception){
......@@ -852,6 +848,4 @@ class MediaModel extends Eloquent
}
return $flag;
}
}
......@@ -82,7 +82,6 @@
<td class="td-manage">
@if(permissionExist("manager_media","media_edit"))
<a title="编辑" href="/web/media_model/{{$media['_id']}}/edit">
<i class="iconfont">&#xe609;</i>
</a>
......@@ -99,7 +98,7 @@
@endif
@if(isset($media["media_num"]))
<a title="视频预览" onclick="x_admin_show('/web/video_preview?media_id={{$media["_id"]}}')" href="javascript:;">
<a title="视频预览" href="/web/video_preview/{{$media['_id']}}">
<i class="iconfont">&#xe79f;</i>
</a>
@else
......@@ -147,8 +146,6 @@
function x_admin_show(url){
window.location.href = url;
// window.open(url);
}
......@@ -194,6 +191,11 @@
});
}
/**
* 设置媒资随机码
* @param row
* @param id
*/
function set_media_num(row,id){
$.confirm({
......
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