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
e59ca656
Commit
e59ca656
authored
Jul 07, 2022
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
7eb5e36c
Pipeline
#18777
passed with stages
in 1 minute 12 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
55 deletions
+5
-55
MediaController.php
app/Http/Controllers/Api/MediaController.php
+1
-1
MediaModel.php
app/Model/MediaModel.php
+4
-54
No files found.
app/Http/Controllers/Api/MediaController.php
View file @
e59ca656
...
@@ -375,7 +375,7 @@ class MediaController extends Controller
...
@@ -375,7 +375,7 @@ class MediaController extends Controller
'end_time.date'
=>
'结束时间格式错误'
,
'end_time.date'
=>
'结束时间格式错误'
,
'end_time.after_or_equal'
=>
'结束时间不能小于开始时间'
'end_time.after_or_equal'
=>
'结束时间不能小于开始时间'
]);
]);
return
MediaModel
::
runScreenShotMedia
List
(
$request
);
return
MediaModel
::
runScreenShotMedia
(
$request
);
});
});
return
success
(
$data
);
return
success
(
$data
);
}
}
...
...
app/Model/MediaModel.php
View file @
e59ca656
...
@@ -1138,19 +1138,9 @@ class MediaModel extends Eloquent
...
@@ -1138,19 +1138,9 @@ class MediaModel extends Eloquent
* @return mixed
* @return mixed
* @throws DatabaseException
* @throws DatabaseException
*/
*/
public
static
function
runScreenShotMedia
List
(
$request
)
public
static
function
runScreenShotMedia
(
$request
)
{
{
try
{
try
{
$medias
=
MediaModel
::
query
()
->
raw
(
function
(
$collection
)
use
(
$request
)
{
$limit
=
(
isset
(
$request
->
page_size
)
?
(
int
)(
$request
->
page_size
)
:
Constant
::
PAGE_NUMBER
);
if
(
$limit
>
self
::
$max_page_size
)
{
$limit
=
self
::
$max_page_size
;
}
$page
=
$request
->
page
??
1
;
$aggregate
=
[];
$match
=
[
$match
=
[
'status'
=>
"1"
,
'status'
=>
"1"
,
"screen_shot"
=>
null
"screen_shot"
=>
null
...
@@ -1170,53 +1160,13 @@ class MediaModel extends Eloquent
...
@@ -1170,53 +1160,13 @@ class MediaModel extends Eloquent
$match
[
'end_time'
]
=
[
'$lt'
=>
$end_time
];
$match
[
'end_time'
]
=
[
'$lt'
=>
$end_time
];
}
}
$aggregate
[][
'$match'
]
=
$match
;
$media
=
MediaModel
::
where
(
$match
)
->
first
();
$count
=
MediaModel
::
where
(
$match
)
->
count
();
$skip
=
((
empty
(
$request
->
page
)
?
1
:
$request
->
page
)
-
1
)
*
$limit
;
$aggregate
[][
'$skip'
]
=
$skip
;
$aggregate
[][
'$limit'
]
=
$limit
;
$tmp_arr
=
$collection
->
aggregate
(
$aggregate
)
->
toArray
();
$tmp_arr
=
collect
(
$tmp_arr
);
/**
* 将mongoDate 转化为普通时间
*/
foreach
(
$tmp_arr
as
$media
)
{
$tz
=
new
\DateTimeZone
(
"Asia/Shanghai"
);
if
(
is_object
(
$media
[
'start_time'
]))
{
$start_time
=
$media
[
'start_time'
]
->
toDateTime
();
$start_time
->
setTimezone
(
$tz
);
$start_time
=
$start_time
->
format
(
"Y-m-d H:i:s"
);
$media
[
'start_time'
]
=
$start_time
;
}
if
(
is_object
(
$media
[
'end_time'
]))
{
$end_time
=
$media
[
'end_time'
]
->
toDateTime
();
$end_time
->
setTimezone
(
$tz
);
$media
[
'end_time'
]
=
$end_time
->
format
(
'Y-m-d H:i:s'
);
}
if
(
is_object
(
$media
[
'create_time'
]))
{
$create_time
=
$media
[
'create_time'
]
->
toDateTime
();
$create_time
->
setTimezone
(
$tz
);
$media
[
'create_time'
]
=
$create_time
->
format
(
'Y-m-d H:i:s'
);
}
//处理封面图片以及分辨率
self
::
getScreeShotInfo
(
$media
[
"_id"
]);
self
::
getScreeShotInfo
(
$media
[
"_id"
]);
sleep
(
1
);
sleep
(
10
);
}
return
new
LengthAwarePaginator
(
$tmp_arr
,
$count
,
$limit
,
$page
,
[
'path'
=>
Paginator
::
resolveCurrentPath
(),
'pageName'
=>
'page'
,
]);
});
}
catch
(
\Exception
$exception
)
{
}
catch
(
\Exception
$exception
)
{
throw
new
DatabaseException
(
$exception
->
getMessage
());
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
}
return
$media
s
;
return
$media
;
}
}
}
}
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