Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
wallet
token
Commits
ba95e997
Commit
ba95e997
authored
Jun 05, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api公告新闻
parent
112e259f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
16 deletions
+38
-16
BaseResponse.php
api/base/BaseResponse.php
+0
-6
main.php
api/config/main.php
+5
-2
NoticeController.php
api/controllers/NoticeController.php
+31
-6
Article.php
common/models/pwallet/Article.php
+1
-1
Notice.php
common/models/pwallet/Notice.php
+1
-1
No files found.
api/base/BaseResponse.php
View file @
ba95e997
...
...
@@ -15,11 +15,6 @@ class BaseResponse extends Response
public
function
send
()
{
//TODO 错误处理
$this
->
data
=
[
'code'
=>
0
,
'msg'
=>
''
,
'data'
=>
$this
->
data
,
];
parent
::
send
();
}
}
\ No newline at end of file
api/config/main.php
View file @
ba95e997
...
...
@@ -25,8 +25,11 @@ return [
'baseUrl'
=>
'/interface'
,
'cookieValidationKey'
=>
'123456'
,
'enableCsrfValidation'
=>
false
,
'parsers'
=>
[
'application/json'
=>
'yii\web\JsonParser'
,
'parsers'
=>
[
'application/json'
=>
[
'class'
=>
'yii\web\JsonParser'
,
'throwException'
=>
false
,
//json格式错误不报错
],
],
],
'response'
=>
[
...
...
api/controllers/NoticeController.php
View file @
ba95e997
...
...
@@ -31,14 +31,38 @@ class NoticeController extends BaseController
$request
=
Yii
::
$app
->
request
;
$page
=
$request
->
post
(
'page'
,
1
);
$limit
=
$request
->
post
(
'limit'
,
10
);
$condition
=
$request
->
post
();
if
(
isset
(
$condition
[
'page'
]))
{
unset
(
$condition
[
'page'
]);
$post
=
$request
->
post
();
$condition
=
[];
$post
=
array_filter
(
$post
,
function
(
$value
,
$key
)
{
if
(
$key
==
'status'
&&
is_numeric
(
$value
))
{
return
true
;
}
if
(
$key
==
'id'
&&
is_numeric
(
$value
))
{
return
true
;
}
return
$value
;
},
ARRAY_FILTER_USE_BOTH
);
if
(
isset
(
$post
[
'id'
]))
{
$condition
[]
=
[
'id'
=>
$post
[
'id'
]];
}
if
(
isset
(
$post
[
'title'
]))
{
$condition
[]
=
[
'like'
,
'title'
,
$post
[
'title'
]];
}
if
(
isset
(
$post
[
'author'
]))
{
$condition
[]
=
[
'author'
=>
$post
[
'author'
]];
}
if
(
isset
(
$
condition
[
'limit
'
]))
{
unset
(
$condition
[
'limit'
])
;
if
(
isset
(
$
post
[
'status
'
]))
{
$condition
[]
=
[
'status'
=>
$post
[
'status'
]]
;
}
$data
=
Notice
::
getList
(
$page
,
$limit
,
$condition
);
if
(
isset
(
$post
[
'create_at'
]))
{
$condition
[]
=
[
'>='
,
'create_at'
,
$post
[
'create_at'
]];
}
if
(
isset
(
$post
[
'update_at'
]))
{
$condition
[]
=
[
'>='
,
'update_at'
,
$post
[
'update_at'
]];
}
$data
=
Notice
::
getList
(
$page
,
$limit
,
$condition
);
Yii
::
$app
->
response
->
data
=
$data
;
}
}
\ No newline at end of file
common/models/pwallet/Article.php
View file @
ba95e997
...
...
@@ -35,7 +35,7 @@ class Article extends BaseActiveRecord
{
$query
=
self
::
find
();
foreach
(
$condition
as
$item
)
{
$query
=
$query
->
and
Filter
Where
(
$item
);
$query
=
$query
->
andWhere
(
$item
);
}
$count
=
$query
->
count
();
if
(
$count
)
{
...
...
common/models/pwallet/Notice.php
View file @
ba95e997
...
...
@@ -22,7 +22,7 @@ class Notice extends BaseActiveRecord
{
$query
=
self
::
find
();
foreach
(
$condition
as
$item
)
{
$query
=
$query
->
and
Filter
Where
(
$item
);
$query
=
$query
->
andWhere
(
$item
);
}
$count
=
$query
->
count
();
if
(
$count
)
{
...
...
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