123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- 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
- {
-
- 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,
- ]
- ]
- ]);
- }
- }
|