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
96d66c68
Commit
96d66c68
authored
Jul 10, 2020
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加异常处理
parent
03421914
Pipeline
#9856
passed with stages
in 33 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
MediaModel.php
app/Model/MediaModel.php
+11
-2
Constant.php
app/Tool/Constant.php
+25
-0
SrsHookValidate.php
app/Tool/SrsHookValidate.php
+2
-0
No files found.
app/Model/MediaModel.php
View file @
96d66c68
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
App\Model
;
namespace
App\Model
;
use
App\Exceptions\DatabaseException
;
use
App\Exceptions\DatabaseException
;
use
App\Tool\Constant
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
MongoDB\Client
;
use
MongoDB\Client
;
...
@@ -35,7 +36,7 @@ class MediaModel extends Eloquent
...
@@ -35,7 +36,7 @@ class MediaModel extends Eloquent
try
{
try
{
$test
=
MediaModel
::
query
()
->
raw
(
function
(
$collection
)
use
(
$request
){
$test
=
MediaModel
::
query
()
->
raw
(
function
(
$collection
)
use
(
$request
){
$aggregate
=
[]
;
$aggregate
[][
'$limit'
]
=
Constant
::
PAGE_NUMBER
??
$request
->
pagesize
;
if
(
isset
(
$request
->
media_id
)){
if
(
isset
(
$request
->
media_id
)){
...
@@ -50,7 +51,8 @@ class MediaModel extends Eloquent
...
@@ -50,7 +51,8 @@ class MediaModel extends Eloquent
$aggregate
[][
'$match'
][
'media_name'
]
=
[
'$regex'
=>
$request
->
media_name
];
$aggregate
[][
'$match'
][
'media_name'
]
=
[
'$regex'
=>
$request
->
media_name
];
}
}
dd
(
$aggregate
);
return
$collection
->
aggregate
(
$aggregate
)
->
toArray
();
return
$collection
->
aggregate
(
$aggregate
)
->
toArray
();
...
@@ -99,6 +101,13 @@ class MediaModel extends Eloquent
...
@@ -99,6 +101,13 @@ class MediaModel extends Eloquent
*/
*/
$media_id
=
$request
->
media_id
;
$media_id
=
$request
->
media_id
;
$media
=
MediaModel
::
where
(
"_id"
,
$media_id
)
->
first
();
if
(
!
empty
(
$media
)){
throw
new
\Exception
(
"媒资编号已被使用"
);
}
//hb15011&河北公务员考试试题
//hb15011&河北公务员考试试题
/**
/**
* 媒资名称是由课程编号与课程名称组成
* 媒资名称是由课程编号与课程名称组成
...
...
app/Tool/Constant.php
0 → 100755
View file @
96d66c68
<?php
namespace
App\Tool
;
/**
* 主节点常量
*/
class
Constant
{
# 接口响应成功
const
RESPONSE_SUCCESS
=
0
;
# 表单验证失败
const
EXCEPTION_FORM_FAIL
=
1
;
# 数据库操作失败
const
EXCEPTION_DATA_FAIL
=
2
;
# 控制器异常
const
EXCEPTION_CTRL_FAIL
=
3
;
# 默认分页数
const
PAGE_NUMBER
=
10
;
# 升序
const
SORT_ASC
=
'asc'
;
# 降序
const
SORT_DESC
=
'desc'
;
}
\ No newline at end of file
app/Tool/SrsHookValidate.php
View file @
96d66c68
...
@@ -39,6 +39,8 @@ class SrsHookValidate {
...
@@ -39,6 +39,8 @@ class SrsHookValidate {
$params
=
$request
->
all
();
$params
=
$request
->
all
();
$request
->
replace
(
self
::
filterField
(
$params
,
array_keys
(
$rules
)));
$request
->
replace
(
self
::
filterField
(
$params
,
array_keys
(
$rules
)));
$validator
=
\Illuminate\Support\Facades\Validator
::
make
(
$request
->
all
(),
$rules
,
$message
);
$validator
=
\Illuminate\Support\Facades\Validator
::
make
(
$request
->
all
(),
$rules
,
$message
);
if
(
$callback
)
{
if
(
$callback
)
{
$validator
->
after
(
function
()
use
(
$callback
,
$validator
,
$request
){
$validator
->
after
(
function
()
use
(
$callback
,
$validator
,
$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