Commit 9535bd0a by 杨昕

Merge branch 'test' into 'master'

Test

See merge request !33
parents b26a81ec 3d477c8b
Pipeline #13831 passed with stages
in 43 seconds
......@@ -258,6 +258,31 @@ function getAdmin(){
return $user;
}
/**
* 控制页面显示
* @param string $keyName
* @param string $subKey
* @return bool
*/
function permissionExist($keyName = "manager_media",$subKey="media_model_list"){
$user = \Illuminate\Support\Facades\Auth::user();
$permissions = $user->permission;
if ($user->name == 'offcn'){
return true;
}
foreach ($permissions as $key => $val) {
if ($val['key_name'] === $keyName) {
$flag = array_search($subKey,array_column($val['son'],'key_name'));
if ($flag !== false){
return true;
}
return false;
}
}
return false;
}
function parse_custom_str($str, $handle = '/')
{
$str = substr($str, strpos($str, $handle) + 1);
......
......@@ -278,5 +278,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);
}
}
......@@ -11,6 +11,11 @@ use App\Http\Controllers\Controller;
class MediaController extends Controller
{
private const PREVIEW_DOMAIN = [
'test' => 'https://xue.t.eoffcn.com/preview/temp/',
'master' => 'https://xue.eoffcn.com/preview/temp/'
];
/**
* 媒资列表
* @param Request $request
......@@ -49,6 +54,7 @@ class MediaController extends Controller
'appid' => $request->appid,
'page_size' => $request->page_size,
'username' => $request->username,
'page' => $request->page,
]);
}
......@@ -169,4 +175,50 @@ class MediaController extends Controller
return view('admin.control');
}
/**
* 视频预览
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function media_preview(Request $request,$mediaNum){
$isFullScreen = $request->fullScreen;
$branch = !empty(getenv('branch'))?getenv('branch'):"test";
$url = self::PREVIEW_DOMAIN[$branch];
if ($isFullScreen){
$url .= "player".'/'.$mediaNum;
}else{
$url .= "play".'/'.$mediaNum;
}
return redirect($url);
}
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function setMediaNum(Request $request){
$res = handler_drive(function () use ($request){
return MediaModel::setMediaNum($request);
});
return success($res);
}
/**
* 清除Cdn缓存
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function clearCdnCache(Request $request,$media_id){
$res = handler_drive(function () use ($request,$media_id){
return MediaModel::clearCdnCache($request,$media_id);
});
return success($res);
}
}
......@@ -25,7 +25,7 @@ class MemberController extends Controller
* users跟新验证
*/
protected $users_update_verify = [
'id' => 'required',
'_id' => 'required',
'name' => 'required',
'status' => ''
];
......@@ -131,7 +131,7 @@ class MemberController extends Controller
throw new \App\Exceptions\FormException('你不能操作别人的');
}
if ($id == getAdmin()->_id) {
if ($id == Auth::user()->_id) {
throw new \App\Exceptions\FormException('你不能操作你自己');
}
......@@ -157,7 +157,7 @@ class MemberController extends Controller
throw new \App\Exceptions\FormException('你不能操作别人的');
}
if ($id == getAdmin()->_id) {
if ($id == Auth::user()->_id) {
throw new \App\Exceptions\FormException('你不能操作你自己');
}
UserModel::updateUserStatus($request);
......
......@@ -39,7 +39,7 @@ class Kernel extends HttpKernel
],
'auth' => [\App\Http\Middleware\Apprialisal::class],
'api' => [
'throttle:60,1',
// 'throttle:60,1',
'bindings',
],
];
......
......@@ -16,6 +16,9 @@ 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/{media_num}','MediaController@media_preview');
$router->post('set_media_num','MediaController@setMediaNum');
$router->get('clear_cdn_cache/{media_id}','MediaController@clearCdnCache');
});
}
......
......@@ -822,20 +822,85 @@ 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;
}
/**
* 设置随机码
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function setMediaNum($request){
try{
$media_id = $request->media_id;
$data = [
'media_num' => md5(md5($media_id)),
];
$flag = MediaModel::where("_id",$media_id)->update($data);
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $flag;
}
return $media_id;
/**
* 根据媒资编号获取媒资随机码
* @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,$media_id){
try{
/**
* 判断媒资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;
}
}
......@@ -15,9 +15,40 @@ class ModuleModel extends Eloquent
if ($user['name'] == 'offcn' ){
$module = file_get_contents(public_path('module.json'));
}else{
$module = file_get_contents(public_path('media_category.json'));
}
if ($user['media_show']){
$module = file_get_contents(public_path('sub_admin.json'));
}else{
$module = file_get_contents(public_path('media_category.json'));
}
$tmp = json_decode($module,true);
$result = [];
/**
* 控制大类显示
*/
foreach ($tmp as $key => &$value){
if ($value['show'] ){
/**
* 控制子类显示
*/
$res = [];
foreach ($value['son'] as $item){
if ($item['have']){
$res[] = $item;
}
}
$value['son'] = $res;
$result[] = $value;
}
}
if (Auth::user()){
Auth::user()->permission = $result;
}
$module = json_encode($result);
}
return json_decode($module,true);
}
......
[{
"id": 2,
"pid": 0,
"name": "用户管理",
"icon": "&#xe697;",
"link": "/member_manager",
"slug": "member.index",
"description": "",
"show": 0,
"sort": 1,
"key_name": "member_manager_block",
"son": [{
"id": 10,
"pid": 2,
"name": "修改密码",
"icon": "",
"link": "",
"slug": "member.password",
"description": "",
"show": 0,
"sort": 25,
"key_name": "member_modify_pwd"
}, {
"id": 9,
"pid": 2,
"name": " 用户列表",
"icon": "",
"link": "/member",
"slug": "member.manager",
"description": "",
"show": 1,
"sort": 25,
"key_name": "member_manager"
}, {
"id": 8,
"pid": 2,
"name": "会员删除",
"icon": "",
"link": "/member/destroy",
"slug": "member.destroy",
"description": "",
"show": 0,
"sort": 25,
"key_name": "member_destroy"
}, {
"id": 7,
"pid": 2,
"name": "会员启用-停用",
"icon": "",
"link": "/member/disable",
"slug": "member.disable",
"description": "",
"show": 0,
"sort": 25,
"key_name": "member_disable"
}, {
"id": 6,
"pid": 2,
"name": "编辑保存",
"icon": "",
"link": "/member/update",
"slug": "member.update",
"description": "",
"show": 0,
"sort": 25,
"key_name": "member_update"
}, {
"id": 5,
"pid": 2,
"name": "会员编辑",
"icon": "",
"link": "/member/edit",
"slug": "member.edit",
"description": "我是会员编辑",
"show": 0,
"sort": 25,
"key_name": "member_edit"
}, {
"id": 4,
"pid": 2,
"name": "添加保存",
"icon": "",
"link": "/member/store",
"slug": "member.store",
"description": "",
"show": 0,
"sort": 25,
"key_name": "member_add"
}, {
"id": 3,
"pid": 2,
"name": "会员添加",
"icon": "",
"link": "/member/create",
"slug": "member.create",
"description": "",
"show": 0,
"sort": 25,
"key_name": "member_create"
}]
}, {
"id": 11,
"pid": 0,
"name": "媒资管理",
"icon": "&#xe60d;",
"link": "/media_manager",
"slug": "manager_manager",
"description": "",
"show": 1,
"sort": 3,
"key_name": "manager_media",
"have":1,
"son": [{
"id": 15,
"pid": 11,
"name": "媒资列表",
"icon": "",
"link": "/media_model",
"slug": "media_model.index",
"description": "",
"show": 1,
"sort": 25,
"key_name": "media_model_list",
"is_show":1,
"have":1
},{
"id": 23,
"pid": 11,
"name": "媒资删除",
"icon": "",
"link": "",
"slug": "media_model.destroy",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_model_destroy",
"is_show":0,
"have":0
}, {
"id": 22,
"pid": 11,
"name": "媒资添加保存",
"icon": "",
"link": "",
"slug": "media_manager.store",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_store",
"have":0
}, {
"id": 21,
"pid": 11,
"name": "媒资修改保存",
"icon": "",
"link": "",
"slug": "media_manager.update",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_update",
"have":0
}, {
"id": 18,
"pid": 11,
"name": "媒资编辑",
"icon": "",
"link": "",
"slug": "media_manager.edit",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_edit",
"have":0
}, {
"id": 17,
"pid": 11,
"name": "媒资添加",
"icon": "",
"link": "/media_manager/create",
"slug": "media_manager.create",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_create",
"have":0
}]
},{
"id": 3,
"pid": 0,
"name": "媒资类别管理",
"icon": "&#xe818;",
"link": "/media_category_manager",
"slug": "media_category_manager",
"description": "",
"show": 0,
"sort": 2,
"key_name": "media_category",
"have":0,
"son": [{
"id": 31,
"pid": 3,
"name": "媒资类别列表",
"icon": "",
"link": "/media_category",
"slug": "media_category.index",
"description": "",
"show": 1,
"sort": 25,
"key_name": "media_list"
},{
"id": 31,
"pid": 3,
"name": "媒资类别删除",
"icon": "",
"link": "",
"slug": "media_category.destroy",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_destroy"
}, {
"id": 33,
"pid": 3,
"name": "媒资类别添加保存",
"icon": "",
"link": "",
"slug": "media_category.store",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_store"
}, {
"id": 34,
"pid": 3,
"name": "媒资类别修改保存",
"icon": "",
"link": "",
"slug": "media_category.update",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_update"
}, {
"id": 35,
"pid": 3,
"name": "媒资类别编辑",
"icon": "",
"link": "",
"slug": "media_category.edit",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_edit"
}, {
"id": 36,
"pid": 3,
"name": "媒资类别添加",
"icon": "",
"link": "/media_category/create",
"slug": "media_category.create",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_create"
}]
},{
"id": 2,
"pid": 0,
"name": "权限管理",
"icon": "&#xe623;",
"link": "/privilege",
"slug": "privilege.index",
"description": "",
"show": 1,
"sort": 4,
"key_name": "privilege",
"son": [],
"have":1
},{
"id": 11,
"pid": 0,
"name": "媒体资源上传",
"icon": "&#xe60d;",
"link": "/media_command",
"slug": "media_command",
"description": "",
"show": 1,
"sort": 2,
"key_name": "media_command",
"son": [],
"have":1
}]
\ No newline at end of file
......@@ -20,7 +20,7 @@
}
}
// loadStyles(baseurl+"/xadmin/extra/toast/css/animate.css");
loadStyles("/xadmin/extra/toast/css/animate.css");
//显示提示信息 toast
$.fn.toast = function(options){
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -6,7 +6,7 @@
<meta name="robots" content="all,follow">
<title>后台管理系统</title>
<link rel="shortcut icon" href="img/test.ico">
<link rel="shortcut icon" >
<script src="{{ asset('xadmin/js/jquery.min.js')}}"></script>
<script src="{{ asset('xadmin/js/jquery.cookie.js')}}"></script>
......
......@@ -152,7 +152,7 @@
console.log("formdata",formdata)
fetch_response('POST',"/web/media_manager", formdata).then(function (res) {
fetch_response('POST',"/web/media_model", formdata).then(function (res) {
if (res.code == 200) {
$('body').toast({
position: 'fixed',
......@@ -161,7 +161,7 @@
top: '50%'
});
setTimeout(function () {
window.location.href = '/web/media_manager';
window.location.href = '/web/media_model';
}, 2000)
} else {
......
......@@ -31,11 +31,11 @@
<!--***** CONTENT *****-->
<div class="row ml20">
<div class="xblock">
@if(permissionExist("manager_media","media_create"))
<button class="btn btn-primary" onclick="x_admin_show('/web/media_model/create')">
添加
</button>
@endif
<form>
<input type="text" name="media_name" class="form-input" placeholder="请输入媒资名称" value="{{$media_name}}" autocomplete="off">
<input type="text" name="username" class="form-input" placeholder="请输入创建人" value="{{$username}}" autocomplete="off">
......@@ -58,6 +58,7 @@
<th>视频类别</th>
<th>视频地址</th>
<th>创建时间</th>
<th>媒资号码</th>
<th>操作</th>
</tr>
</thead>
......@@ -73,18 +74,47 @@
<td style="max-width: 200px;">{{$media['media_url']}}</td>
<td style="max-width: 100px;">{{$media['create_time']}}</td>
@if(isset($media['media_num']))
<td style="max-width: 100px;">{{$media['media_num']}}</td>
@else
<td></td>
@endif
<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>
@endif
{{--<a onclick="x_admin_show('修改密码','/web/password/{{$user->id}}',500,300)" title="修改密码"--}}
{{--href="javascript:;">--}}
{{--<i class="iconfont">&#xe61a;</i>--}}
{{--</a>--}}
<a title="删除" onclick="member_del(this,'{{$media["_id"]}}')" href="javascript:;">
<i class="iconfont">&#xe695;</i>
@if(permissionExist("manager_media","media_model_destroy"))
<a title="删除" onclick="member_del(this,'{{$media["_id"]}}')" href="javascript:;">
<i class="iconfont">&#xe695;</i>
</a>
@endif
@if(isset($media["media_num"]))
<a title="视频预览" href="javascript:;" onclick="preview_video(this,'{{$media["media_num"]}}')">
<i class="iconfont">&#xe79f;</i>
</a>
<a title="全屏预览" href="javascript:;" onclick="preview_video(this,'{{$media["media_num"]}}',1)">
<i class="iconfont">&#xe627;</i>
</a>
@else
<a title="生成媒资号码" onclick="set_media_num(this,'{{$media["_id"]}}')" href="javascript:;">
<i class="iconfont">&#xe61a;</i>
</a>
@endif
<a title="清除cdn缓存" onclick="clear_cdn_cache(this,'{{$media["_id"]}}')" href="javascript:;">
<i class="iconfont">&#xe61c;</i>
</a>
</td>
</tr>
@endforeach
......@@ -124,23 +154,18 @@
function x_admin_show(url){
window.location.href = url;
// window.open(url);
}
function member_del(row,id){
function member_del(row,id){
$.confirm({
// confirmButtonClass: 'btn-info',
// cancelButtonClass: 'btn-info',
cancelButtonClass: 'btn-info',
confirmButtonClass: 'btn-danger',
content:'确认要刪除吗?',
confirmButton:'确认',
cancelButton:'取消',
confirm: function () {
fetch_response('DELETE',"/web/media_model/"+id).then(function (res) {
if (res.code==200) {
......@@ -162,7 +187,56 @@
});
}
})
},
cancel: function () {
$('body').toast({
position:'fixed',
content:'已取消',
duration:1000,
top:'50%'
});
}
});
}
/**
* 设置媒资随机码
* @param row
* @param id
*/
function set_media_num(row,id){
$.confirm({
cancelButtonClass: 'btn-info',
confirmButtonClass: 'btn-danger',
content:'确认要设置媒资编号吗?',
confirmButton:'确认',
cancelButton:'取消',
confirm: function () {
var formData = new FormData();
formData.append('media_id',id);
fetch_response('post',"/web/set_media_num",formData).then(function (res) {
if (res.code==200) {
$('body').toast({
position:'fixed',
content:res.msg,
duration:1000,
top:'50%'
});
setTimeout(function () {
window.location.href='/web/media_model?media_name={{$media_name}}&media_id={{$media_id}}&start_time={{$start_time}}&end_time={{$end_time}}&category_id={{$category_id}}&appid={{$appid}}&page={{$page}}';
},2000)
}else{
$('body').toast({
position:'fixed',
content:res.msg,
duration:1000,
top:'50%'
});
}
})
},
cancel: function () {
$('body').toast({
......@@ -175,6 +249,66 @@
});
}
/**
* 清除CDN缓存
* @param row
* @param id
*/
function clear_cdn_cache(row,id){
$.confirm({
cancelButtonClass: 'btn-info',
confirmButtonClass: 'btn-danger',
content:'确认要强制更新CND缓存吗?',
confirmButton:'确认',
cancelButton:'取消',
confirm: function () {
fetch_response('GET',"/web/clear_cdn_cache/"+id).then(function (res) {
if (res.code==200) {
$('body').toast({
position:'fixed',
content:res.msg,
duration:1000,
top:'50%'
});
setTimeout(function () {
window.location.href='/web/media_model?media_name={{$media_name}}&media_id={{$media_id}}&start_time={{$start_time}}&end_time={{$end_time}}&category_id={{$category_id}}&appid={{$appid}}&page={{$page}}';
},2000)
}else{
$('body').toast({
position:'fixed',
content:res.msg,
duration:1000,
top:'50%'
});
}
})
},
cancel: function () {
$('body').toast({
position:'fixed',
content:'已取消',
duration:1000,
top:'50%'
});
}
});
}
/**
* 视频预览
* @param row
* @param id
*/
function preview_video(row,id,fullScreen){
var href = "/web/video_preview/"+id;
if (fullScreen !== undefined){
href = "/web/video_preview/"+id+"?fullScreen="+fullScreen;
}
window.open(href);
}
// updateConfig(1);
$('#endDate').bind("onclickOnce",function () {
......
......@@ -37,7 +37,7 @@ Route::group(['namespace' => 'Api', 'prefix' => 'v1', 'middleware' => ['auth']],
Route::group(['namespace' => 'Api', 'prefix' => 'user'], function () {
Route::group(['namespace' => 'Api', 'prefix' => 'user','middleware' => ['api']], function () {
Route::post("media_list","MediaController@media_list");
Route::get("play_url/{id}","MediaController@play_url");
......@@ -47,6 +47,8 @@ Route::group(['namespace' => 'Api', 'prefix' => 'user'], function () {
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