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
07c319fc
Commit
07c319fc
authored
Apr 09, 2021
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
349d0e0a
Pipeline
#14160
passed with stages
in 5 minutes 7 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
16 deletions
+29
-16
MediaController.php
app/Http/Controllers/Api/MediaController.php
+4
-2
MediaCategoryModel.php
app/Model/MediaCategoryModel.php
+22
-0
MediaModel.php
app/Model/MediaModel.php
+3
-14
No files found.
app/Http/Controllers/Api/MediaController.php
View file @
07c319fc
...
...
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use
App\Exceptions\FormException
;
use
App\Model\LogModel
;
use
App\Model\MediaCategoryModel
;
use
App\Model\MediaModel
;
use
App\Model\QiniuModel
;
use
App\Tool\Constant
;
...
...
@@ -190,9 +191,10 @@ class MediaController extends Controller
);
//shop_id为100时,代表的是北大学堂的视频
if
(
$request
->
shop_id
==
'100'
){
$params
[
'media_type'
]
=
"5f3d073a033f5a336b2b4346"
;
$catg
=
MediaCategoryModel
::
getCategoryByName
(
"北大学堂"
);
$params
[
'media_type'
]
=
$catg
[
'_id'
];
}
$request
->
replace
(
array_merge
(
$request
->
all
(),
$params
));
...
...
app/Model/MediaCategoryModel.php
View file @
07c319fc
...
...
@@ -200,4 +200,26 @@ class MediaCategoryModel extends Eloquent
return
$flag
;
}
/**
* 根据媒资名称,获取媒资信息。
* @param $name
* @return mixed
* @throws DatabaseException
*/
public
static
function
getCategoryByName
(
$name
){
try
{
$catg
=
MediaCategoryModel
::
where
(
"name"
,
$name
)
->
first
();
if
(
empty
(
$catg
)){
throw
new
\Exception
(
"店铺不存在"
);
}
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$catg
;
}
}
app/Model/MediaModel.php
View file @
07c319fc
...
...
@@ -177,19 +177,18 @@ class MediaModel extends Eloquent
throw
new
\Exception
(
"媒资类别不存在"
);
}
//replace 不为空的时候代表做视频替换操作,1.需要清空CDN缓存,2.将原来的视频保存至回收站,3.更新视频信息
if
(
$request
->
replace
){
$recycleId
=
RecycleModel
::
addRecycle
(
$media_id
);
$call_back
=
$mediaCatg
[
'call_back'
];
#清空CND缓存
$url
=
getRbac
(
$request
,
$call_back
,
$mediaCatg
[
'media_category_id'
]
,
$type
=
'clear_cache'
);
http_request_code
(
$url
,
null
,
'POST'
,[
'mediaId'
=>
$media_id
]);
#更新视频信息
self
::
updatehookMedia
(
$request
,
$media_id
);
if
(
!
$recycleId
){
throw
new
\Exception
(
'回收站保存失败'
);
}
...
...
@@ -221,16 +220,6 @@ class MediaModel extends Eloquent
$end_time
=
new
UTCDateTime
(
strtotime
(
$request
->
end_time
)
*
1000
);
$create_time
=
new
UTCDateTime
(
time
()
*
1000
);;
// $start_time = $request->start_time;
// $end_time = $request->end_time;
// $create_time = date('Y-m-d H:i:s',time());
// if ($request->shop_id=='100'){
// $mediaCatg = MediaCategoryModel::where('_id','5f3d073a033f5a336b2b4346')->first();
// }
/**
* 处理文件名称,确认是否包含"&"符合
...
...
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