129 lines
5.6 KiB
PHP
129 lines
5.6 KiB
PHP
<?php
|
||
|
||
/**
|
||
* @author Any
|
||
* @description KISS
|
||
* @date 2021年6月30日
|
||
* @version 1.0.0
|
||
*
|
||
* _____LOG_____
|
||
*
|
||
*/
|
||
namespace app\modules\api\controllers;
|
||
|
||
use app\modules\api\behaviors\LoginBehavior;
|
||
use app\components\SiteHelper;
|
||
use app\components\SysConst;
|
||
use app\models\common\CommonFaqActionForm;
|
||
use app\models\common\CommonFaqListForm;
|
||
use app\models\common\CommonFaqTreeListForm;
|
||
use app\models\Faq;
|
||
use app\models\FaqMeta;
|
||
use app\components\SysErrCode;
|
||
use yii\web\NotFoundHttpException;
|
||
|
||
class FaqController extends Controller
|
||
{
|
||
public function behaviors() {
|
||
return array_merge(parent::behaviors(),[
|
||
'login' => [
|
||
'class' => LoginBehavior::className(),
|
||
'ignore' => [
|
||
'api/faq/index',
|
||
'api/faq/tree',
|
||
'api/faq/detail',
|
||
]
|
||
]
|
||
]);
|
||
}
|
||
|
||
/**
|
||
* hidedoc
|
||
* @catalog 帮助反馈/帮助列表
|
||
* @title 帮助列表
|
||
* @description 本接口提供帮助列表
|
||
* @method get
|
||
* @url /api/faq/index
|
||
* @param keywords 非必选 string 关键词
|
||
* @param page 必选 int 页码
|
||
* @param limit 非必选 int 每页记录数
|
||
* @param cat_id 非必选 int 帮助分类
|
||
* @param is_hot 非必选 int 是否热门问题:1=是,0=否
|
||
* @return {"code":0,"msg":"ok","data":[{"id":"1","title":"购买购买购买购买购买购买","content":"<p>购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买</p>","created_at":"1625036704","published_at":"1625036826","status":"1","sort":"100","is_hot":"1","created_at_cn":"2021-06-30 15:05:04","published_at_cn":"2021-06-30 15:07:06","status_cn":"已发布","cat_list":[{"name":"购买","cat_id":"1"}]}],"count":"1","page_size":20,"page_count":1,"page_no":1,"end_flag":false}
|
||
* @return_param count int 记录条数
|
||
* @return_param page_size int 每页记录数
|
||
* @return_param page_count int 总页数
|
||
* @return_param page_no int 当前页码
|
||
* @return_param end_flag bool 是否加载结束
|
||
* @remark
|
||
*/
|
||
public function actionIndex()
|
||
{
|
||
$form = new CommonFaqListForm();
|
||
$form->attributes = \Yii::$app->request->get();
|
||
$form->cx_mch_id = $this->cx_mch_id;
|
||
$form->status = Faq::STATUS_PUBLISHED;
|
||
$data = $form->search();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
/**
|
||
* hidedoc
|
||
* @catalog 帮助反馈/帮助列表
|
||
* @title 帮助树状列表
|
||
* @description 本接口提供帮助树状列表,按照分类划分
|
||
* @method get
|
||
* @url /api/faq/tree
|
||
* @param param param_required_desc param_type param_desc
|
||
* @return {"code":0,"msg":"ok","data":[{"id":"2","name":"订单","img_url":"http://app.tpl.dev.1nww.com/upload/0/1/upload/image/2021/0630/1625033430775640.png","list":[]},{"id":"1","name":"购买","img_url":"http://app.tpl.dev.1nww.com/upload/0/1/upload/image/2021/0630/1625029451785776.png","list":[{"cat_id":"1","id":"1","title":"购买购买购买购买购买购买","content":"<p>购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买</p>","created_at":"1625036704","published_at":"1625036826","status":"1","sort":"100","is_hot":"1","created_at_cn":"2021-06-30 15:05:04","published_at_cn":"2021-06-30 15:07:06","status_cn":"已发布","cat_list":[{"name":"购买","cat_id":"1"},{"name":"订单","cat_id":"2"}]}]}]}
|
||
* @return_param count int 记录条数
|
||
* @return_param page_size int 每页记录数
|
||
* @return_param page_count int 总页数
|
||
* @return_param page_no int 当前页码
|
||
* @return_param end_flag bool 是否加载结束
|
||
* @remark
|
||
*/
|
||
public function actionTree()
|
||
{
|
||
$form = new CommonFaqTreeListForm();
|
||
$form->attributes = \Yii::$app->request->get();
|
||
$form->cx_mch_id = $this->cx_mch_id;
|
||
$data = $form->search();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
/**
|
||
* hidedoc
|
||
* @catalog 帮助反馈/帮助列表
|
||
* @title 帮助详情
|
||
* @description 本接口提供帮助详情
|
||
* @method get
|
||
* @url /api/faq/detail
|
||
* @param faq_id 必选 int 帮助ID
|
||
* @return {"code":0,"msg":"ok","data":{"id":"1","title":"购买购买购买购买购买购买","content":"<p>购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买购买</p>","created_at":"1625036704","published_at":"1625036826","status":"1","sort":"100","is_hot":"1","created_at_cn":"2021-06-30 15:05:04","published_at_cn":"2021-06-30 15:07:06","status_cn":"已发布","cat_list":[{"name":"购买","cat_id":"1"}]}}
|
||
* @return_param param param_type param_desc
|
||
* @remark
|
||
*/
|
||
public function actionDetail()
|
||
{
|
||
$form = new CommonFaqActionForm();
|
||
$form->attributes = \Yii::$app->request->get();
|
||
$form->cx_mch_id = $this->cx_mch_id;
|
||
$data = $form->detail();
|
||
$render = \Yii::$app->request->get('render');
|
||
if(!$render){
|
||
return $this->responseHandler($data);
|
||
}
|
||
if($data['code'] != SysErrCode::$apiReturnSuccess){
|
||
throw new NotFoundHttpException($data['msg']);
|
||
}
|
||
return $this->render('detail',[
|
||
'title' => $data['data']['title'],
|
||
'content' => $data['data']['content']
|
||
]);
|
||
}
|
||
}
|
||
|
||
|
||
|