request->getPlatformId(); $page = Yii::$app->request->get('page', 1); if (false == $platform_id) { $msg = '参数错误'; $code = -1; $data = null; goto doEnd; } $query = CoinBannerItem::find() ->select('id, banner_url, image_url, title') ->where(['platform_id' => $platform_id]) ->asArray(); $banner_model = $query->offset(($page - 1) * 10)->limit(10)->asArray()->all(); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => '10']); $data = [ 'list' => $banner_model, 'page' => [ 'pageCount' => $pages->pageCount, 'pageSize' => 10, 'currentPage' => $page, ] ]; doEnd : return ['code' => $code, 'msg' => $msg, 'data' => $data]; } }