QueryParamAuth::className(), 'tokenParam' => 'token', 'optional' => ['index'] ] ]); } /** * @api {get} /v1/categorys 列表 * @apiVersion 1.0.0 * @apiName index * @apiGroup Category * * */ public function actionIndex() { $lists = Category::find()->active()->orderBy(['sort' => SORT_ASC])->all(); $lists = ArrayHelper::toArray($lists); $lists = Tree::build($lists); //添加热门推荐 // array_unshift($lists, [ // 'title' => '热门推荐', // 'children' => Cat::find()->hot()->all() // ]); return ['data' => $lists]; } /** * @api {get} /v1/category/id:\d+ 分类详情 * @apiVersion 1.0.0 * @apiName view * @apiGroup Category * */ public function actionView($id) { $model = Category::find()->where(['id' => $id])->one(); return ['data' => $model]; } }