初始化仓库
This commit is contained in:
74
member/modules/v1/controllers/InfoController.php
Normal file
74
member/modules/v1/controllers/InfoController.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace member\modules\v1\controllers;
|
||||
|
||||
use common\core\BaseAppController;
|
||||
use common\models\Categories;
|
||||
use common\models\DoctorArticle;
|
||||
use yii\db\Exception;
|
||||
|
||||
/**
|
||||
* @doc-module 咨询
|
||||
*/
|
||||
class InfoController extends BaseAppController
|
||||
{
|
||||
/**
|
||||
* @doc-name 分类列表
|
||||
* @doc-return mixed @Categories{*} 分类列表
|
||||
*/
|
||||
public function actionCategories()
|
||||
{
|
||||
$get = \Yii::$app->request->get();
|
||||
$Categories = Categories::find();
|
||||
|
||||
$this->field = [
|
||||
Categories::class => [
|
||||
'id', 'name', 'pid', 'level'
|
||||
]
|
||||
];
|
||||
return $this->create($Categories, $get);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @doc-name 资讯列表
|
||||
* @doc-param int cid 分类id
|
||||
* @doc-return mixed @DoctorArticle{*} 资讯列表
|
||||
*/
|
||||
public function actionArticleList()
|
||||
{
|
||||
|
||||
$get = \Yii::$app->request->get();
|
||||
$this->requestValidate($get,[
|
||||
['cid','required']
|
||||
]);
|
||||
$DoctorArticle = DoctorArticle::find()->where(['cid'=>$get['cid'],'is_delete'=>0]);
|
||||
|
||||
$this->field = [
|
||||
DoctorArticle::class => [
|
||||
'id', 'cid', 'su_id', 'title', 'intro', 'content', 'video_url','cover',
|
||||
'created_at' => function ($d) {
|
||||
return date('Y-m-d Hi:i:s', $d->created_at);
|
||||
},
|
||||
]
|
||||
];
|
||||
return $this->create($DoctorArticle, $get);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @doc-name 资讯详情
|
||||
* @doc-param int id 资讯id
|
||||
* @doc-return mixed @DoctorArticle{*} 资讯详情
|
||||
*/
|
||||
public function actionArticleInfo()
|
||||
{
|
||||
$get = \Yii::$app->request->get();
|
||||
$this->requestValidate($get, [
|
||||
['id', 'required']
|
||||
]);
|
||||
$DoctorArticle = DoctorArticle::findOne(['id' => $get['id'],'is_delete'=>0]);
|
||||
if (!$DoctorArticle) throw new Exception('资讯不存在');
|
||||
return $DoctorArticle;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user