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
6d5d5261
Commit
6d5d5261
authored
Jul 14, 2022
by
杨昕
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'master'
Test See merge request
!44
parents
5437b25e
48a6e2ce
Pipeline
#18896
passed with stages
in 1 minute 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
65 deletions
+15
-65
MediaController.php
app/Http/Controllers/Api/MediaController.php
+0
-14
MediaModel.php
app/Model/MediaModel.php
+15
-51
No files found.
app/Http/Controllers/Api/MediaController.php
View file @
6d5d5261
...
...
@@ -216,32 +216,23 @@ class MediaController extends Controller
*/
public
function
updateMediaStatus
(
Request
$request
,
$media_id
)
{
$id
=
handler_drive
(
function
()
use
(
$request
,
$media_id
)
{
SrsHookValidate
::
srsHookCallback
(
$request
,
[
'status'
=>
''
,
'secret_key'
=>
''
,
'media_url'
=>
''
,
'media_name'
=>
''
,
'description'
=>
''
,
'duration'
=>
''
,
'media_type'
=>
''
,
'shop_id'
=>
''
,
],
function
(
$items
)
{
$request
=
$items
;
if
(
$request
->
status
)
{
if
(
!
$request
->
media_url
)
{
throw
new
FormException
(
"参数缺失"
);
}
}
});
/**
...
...
@@ -252,17 +243,12 @@ class MediaController extends Controller
'access_key'
=>
''
,
'description'
=>
$request
->
description
??
''
,
);
if
(
$request
->
shop_id
==
'100'
)
{
$params
[
'media_type'
]
=
"5f3d073a033f5a336b2b4346"
;
}
$request
->
replace
(
array_merge
(
$request
->
all
(),
$params
));
LogModel
::
addlog
([
'media_id'
=>
$media_id
,
"更新媒资状态"
=>
json_encode
(
$request
->
all
())]);
$id
=
MediaModel
::
updateMediaStatus
(
$request
,
$media_id
);
return
$id
;
});
return
success
(
$id
);
...
...
app/Model/MediaModel.php
View file @
6d5d5261
...
...
@@ -275,7 +275,9 @@ class MediaModel extends Eloquent
//处理封面图片以及分辨率
if
(
$request
->
media_url
!=
"null"
){
LogModel
::
addlog
([
"start处理媒资封面图"
=>
$media_id
,
"数据"
=>
$data
,
"视频地址"
=>
$request
->
media_url
]);
self
::
getScreeShotInfo
(
$media_id
);
LogModel
::
addlog
([
"end处理媒资封面图"
=>
$media_id
,
"数据"
=>
$data
,
"视频地址"
=>
$request
->
media_url
]);
}
LogModel
::
addlog
([
"添加媒资信息"
=>
$data
,
[
'媒资ID为:=> '
.
$id
]]);
}
catch
(
\Exception
$exception
)
{
...
...
@@ -634,7 +636,6 @@ class MediaModel extends Eloquent
public
static
function
updateMediaStatus
(
$request
,
$media_id
)
{
try
{
$media
=
MediaModel
::
where
(
'_id'
,
$media_id
)
->
first
();
if
(
empty
(
$media
))
{
...
...
@@ -642,9 +643,7 @@ class MediaModel extends Eloquent
if
(
empty
(
$mediaCatg
))
{
throw
new
\Exception
(
"媒资类别不存在"
);
}
$create_time
=
new
UTCDateTime
(
time
()
*
1000
);;
$data
=
[
'_id'
=>
$media_id
,
'media_name'
=>
$request
->
media_name
??
""
,
...
...
@@ -661,32 +660,31 @@ class MediaModel extends Eloquent
"username"
=>
"offcn"
,
"mis_uid"
=>
"admin"
];
//处理封面图片以及分辨率
if
(
$request
->
media_url
!=
"null"
&&
$request
->
media_url
){
LogModel
::
addlog
([
"添加媒资信息 start处理媒资封面图"
=>
$media_id
,
"数据"
=>
$data
,
"视频地址"
=>
$request
->
media_url
]);
self
::
getScreeShotInfo
(
$media_id
);
LogModel
::
addlog
([
"添加媒资信息 end处理媒资封面图"
=>
$media_id
,
"数据"
=>
$data
,
"视频地址"
=>
$request
->
media_url
]);
}
$id
=
MediaModel
::
insertGetId
(
$data
);
LogModel
::
addlog
([
"添加媒资信息"
=>
$data
,
[
'媒资ID为:=> '
.
$id
]]);
return
$id
;
}
if
(
$request
->
status
)
{
$data
=
[
'media_url'
=>
$request
->
media_url
??
""
,
'media_name'
=>
$request
->
media_name
??
""
,
'duration'
=>
$request
->
duration
??
"0"
,
'access_key'
=>
$request
->
access_key
??
""
,
'secret_key'
=>
$request
->
secret_key
??
""
,
'status'
=>
$request
->
status
??
''
'status'
=>
$request
->
status
];
LogModel
::
addlog
([
"原media信息为"
=>
json_encode
(
$media
),
"更新为"
=>
json_encode
(
$data
)]);
}
else
{
$data
[
'status'
]
=
"0"
;
}
// if ($request->status == 1){
// LogModel::addlog(["media重新转码"=>json_encode($media)]);
//
...
...
@@ -702,8 +700,13 @@ class MediaModel extends Eloquent
//throw new \Exception("Status更新失败");
}
//处理封面图片以及分辨率
if
(
$request
->
media_url
!=
"null"
&&
$request
->
media_url
){
LogModel
::
addlog
([
"更新视频status start处理媒资封面图"
=>
$media_id
,
"数据"
=>
$data
,
"视频地址"
=>
$request
->
media_url
]);
self
::
getScreeShotInfo
(
$media_id
);
LogModel
::
addlog
([
"更新视频status end处理媒资封面图"
=>
$media_id
,
"数据"
=>
$data
,
"视频地址"
=>
$request
->
media_url
]);
}
LogModel
::
addlog
([
"更新媒资信息Status=>"
.
$media_id
,
$data
]);
}
catch
(
\Exception
$exception
)
{
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
...
...
@@ -815,7 +818,6 @@ class MediaModel extends Eloquent
*/
public
static
function
getMediaId
()
{
try
{
$i
=
0
;
do
{
...
...
@@ -853,44 +855,6 @@ class MediaModel extends Eloquent
return
$flag
;
}
public
static
function
multiplySetMediaNum
(
$request
)
{
try
{
$media_ids
=
$request
->
media_ids
;
//$flag = MediaModel::whereIn("_id",$media_ids)->get($data,['multiple'=>true]);
$medias
=
MediaModel
::
whereIn
(
"_id"
,
$media_ids
)
->
limit
(
self
::
$max_page_size
)
->
get
();
$multiplied
=
collect
(
$medias
)
->
map
(
function
(
$item
,
$key
)
{
return
$item
*
2
;
});
$collection
=
collect
([
1
,
2
,
3
,
4
,
5
]);
$collection
->
contains
(
function
(
$key
,
$value
)
{
return
$value
<=
5
;
//true
});
$media_id
=
$request
->
media_id
;
$data
=
[
'media_num'
=>
md5
(
md5
(
$media_id
)),
];
$flag
=
MediaModel
::
whereIn
(
"_id"
,
$media_id
)
->
update
(
$data
,
[
'multiple'
=>
true
]);
}
catch
(
\Exception
$exception
)
{
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$flag
;
}
/**
* 根据媒资编号获取媒资随机码
* @param $request
...
...
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