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
5f182b73
Commit
5f182b73
authored
Jan 06, 2021
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
第三方媒资编号不能为空
parent
a39008dd
Pipeline
#13104
passed with stages
in 45 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletions
+26
-1
MediaController.php
app/Http/Controllers/Api/MediaController.php
+1
-1
MediaModel.php
app/Model/MediaModel.php
+25
-0
No files found.
app/Http/Controllers/Api/MediaController.php
View file @
5f182b73
...
...
@@ -181,7 +181,7 @@ class MediaController extends Controller
$params
=
array
(
'media_id'
=>
'mda-'
.
generateRandomNum
(
16
),
'media_id'
=>
MediaModel
::
getMediaId
(
),
'media_type'
=>
'5efa9cb5d16f5a214671fd86'
,
//默认,中公网校
'start_time'
=>
$data_time
,
'end_time'
=>
$data_time
,
...
...
app/Model/MediaModel.php
View file @
5f182b73
...
...
@@ -798,7 +798,32 @@ class MediaModel extends Eloquent
}
/**
* @return string
* @throws DatabaseException
*/
public
static
function
getMediaId
(){
try
{
$i
=
0
;
do
{
$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
'mda-'
.
$media_id
;
}
}
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