Commit a4f58681 authored by rlgy's avatar rlgy

api公告新闻

parent ba95e997
<?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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment