74 lines
1.9 KiB
PHP
74 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace member\modules\v1\controllers;
|
|
|
|
use common\core\BaseAppController;
|
|
use common\models\oldDb\Categories;
|
|
use common\models\oldDb\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;
|
|
}
|
|
} |