| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | 
							- <?php
 
- /**
 
-  * Created by PhpStorm.
 
-  * User:  NODELOG
 
-  * Date: 2017/3/8
 
-  * Time: 下午11:19
 
-  */
 
- namespace api\modules\v1\controllers;
 
- use api\common\controllers\Controller;
 
- use api\modules\v1\models\Comment;
 
- use common\enums\StatusEnum;
 
- use yii\data\ActiveDataProvider;
 
- use yii\web\ServerErrorHttpException;
 
- class CommentController extends Controller
 
- {
 
-     /**
 
-      *
 
-      * @param $entity
 
-      * @param $entity_id
 
-      * @return ActiveDataProvider
 
-      * @throws ServerErrorHttpException
 
-      * @author nodelog
 
-      */
 
-     public function actionIndex($entity, $entity_id)
 
-     {
 
-         $entityList = \common\models\Comment::getEntityList();
 
-         if (!isset($entityList[$entity])) {
 
-             throw new ServerErrorHttpException('空空如也');
 
-         }
 
-         $query = Comment::find()->where(['entity' => $entity, 'entity_id' => $entity_id, 'status' => StatusEnum::STATUS_ON, 'parent_id' => 0]);
 
-         return new ActiveDataProvider([
 
-             'query' => $query,
 
-             'pagination' => [
 
-                 'pageSize' => Comment::PAGE_SIZE,
 
-             ],
 
-             'sort' => [
 
-                 'defaultOrder' => [
 
-                     'created_at' => SORT_ASC,
 
-                 ]
 
-             ]
 
-         ]);
 
-     }
 
- }
 
 
  |