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
a4f58681
Commit
a4f58681
authored
Jun 05, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api公告新闻
parent
ba95e997
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
ArticleController.php
api/controllers/ArticleController.php
+58
-0
No files found.
api/controllers/ArticleController.php
0 → 100644
View file @
a4f58681
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-5
* Time: 下午5:47
*/
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\models\pwallet\Article
;
class
ArticleController
extends
BaseController
{
/**
* 返回新闻列表
*/
public
function
actionList
()
{
$request
=
Yii
::
$app
->
request
;
$page
=
$request
->
post
(
'page'
,
1
);
$limit
=
$request
->
post
(
'limit'
,
10
);
$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
[
'status'
]))
{
$condition
[]
=
[
'status'
=>
$post
[
'status'
]];
}
if
(
isset
(
$post
[
'create_at'
]))
{
$condition
[]
=
[
'>='
,
'create_at'
,
$post
[
'create_at'
]];
}
if
(
isset
(
$post
[
'update_at'
]))
{
$condition
[]
=
[
'>='
,
'update_at'
,
$post
[
'update_at'
]];
}
$data
=
Article
::
getList
(
$page
,
$limit
,
$condition
);
Yii
::
$app
->
response
->
data
=
$data
;
}
}
\ No newline at end of file
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