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
99bded47
Commit
99bded47
authored
Feb 03, 2021
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
清除CDN缓存
parent
6f6ee589
Pipeline
#13713
passed with stages
in 41 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
3 deletions
+66
-3
MediaController.php
app/Http/Controllers/Web/MediaController.php
+13
-0
MediaRoute.php
app/Http/Routes/Web/MediaRoute.php
+1
-1
MediaModel.php
app/Model/MediaModel.php
+1
-2
media_list.blade.php
resources/views/admin/media/media_list.blade.php
+51
-0
No files found.
app/Http/Controllers/Web/MediaController.php
View file @
99bded47
...
@@ -199,4 +199,17 @@ class MediaController extends Controller
...
@@ -199,4 +199,17 @@ class MediaController extends Controller
return
success
(
$res
);
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
);
}
}
}
app/Http/Routes/Web/MediaRoute.php
View file @
99bded47
...
@@ -18,7 +18,7 @@ class MediaRoute extends AuthenRoute
...
@@ -18,7 +18,7 @@ class MediaRoute extends AuthenRoute
$router
->
get
(
'media_command'
,
'MediaController@media_command'
);
$router
->
get
(
'media_command'
,
'MediaController@media_command'
);
$router
->
get
(
'video_preview/{media_num}'
,
'MediaController@media_preview'
);
$router
->
get
(
'video_preview/{media_num}'
,
'MediaController@media_preview'
);
$router
->
post
(
'set_media_num'
,
'MediaController@setMediaNum'
);
$router
->
post
(
'set_media_num'
,
'MediaController@setMediaNum'
);
$router
->
get
(
'clear_cdn_cache/{media_id}'
,
'MediaController@clearCdnCache'
);
});
});
}
}
...
...
app/Model/MediaModel.php
View file @
99bded47
...
@@ -872,13 +872,12 @@ class MediaModel extends Eloquent
...
@@ -872,13 +872,12 @@ class MediaModel extends Eloquent
* @return mixed
* @return mixed
* @throws DatabaseException
* @throws DatabaseException
*/
*/
public
static
function
clearCdnCache
(
$request
){
public
static
function
clearCdnCache
(
$request
,
$media_id
){
try
{
try
{
/**
/**
* 判断媒资ID是否存在
* 判断媒资ID是否存在
*/
*/
$media_id
=
$request
->
media_id
;
$media
=
MediaModel
::
where
(
"media_num"
,
$request
->
media_num
)
->
first
();
$media
=
MediaModel
::
where
(
"media_num"
,
$request
->
media_num
)
->
first
();
if
(
empty
(
$media
)){
if
(
empty
(
$media
)){
throw
new
\Exception
(
"媒资信息不存在"
);
throw
new
\Exception
(
"媒资信息不存在"
);
...
...
resources/views/admin/media/media_list.blade.php
View file @
99bded47
...
@@ -107,6 +107,10 @@
...
@@ -107,6 +107,10 @@
</a>
</a>
@endif
@endif
<a
title=
"清除cdn缓存"
onclick=
"clear_cdn_cache(this,'{{$media["
_id
"]}}')"
href=
"javascript:;"
>
<i
class=
"iconfont"
>

</i>
</a>
</td>
</td>
</tr>
</tr>
@endforeach
@endforeach
...
@@ -241,6 +245,53 @@
...
@@ -241,6 +245,53 @@
});
});
}
}
/**
* 清除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%'
});
}
});
}
// updateConfig(1);
// updateConfig(1);
$
(
'#endDate'
).
bind
(
"onclickOnce"
,
function
()
{
$
(
'#endDate'
).
bind
(
"onclickOnce"
,
function
()
{
...
...
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