101 lines
3.8 KiB
PHP
101 lines
3.8 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\cms\CommonNoticeActionForm;
|
||
use app\models\common\cms\CommonNoticeListForm;
|
||
use app\models\cms\Notice;
|
||
use app\components\SysErrCode;
|
||
use yii\web\NotFoundHttpException;
|
||
|
||
class NoticeController extends Controller
|
||
{
|
||
public function behaviors() {
|
||
return array_merge(parent::behaviors(),[
|
||
'login' => [
|
||
'class' => LoginBehavior::className(),
|
||
'ignore' => [
|
||
'api/notice/index',
|
||
'api/notice/detail',
|
||
]
|
||
]
|
||
]);
|
||
}
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 公告
|
||
* @title 公告列表
|
||
* @description 本接口提供公告列表
|
||
* @method get
|
||
* @url /api/notice/index
|
||
* @param keywords 非必选 string 关键词
|
||
* @param page 必选 int 页码
|
||
* @param limit 非必选 int 每页记录数
|
||
* @param is_top 非必选 int 是否置顶:1=是,0=否
|
||
* @param is_index 非必选 int 首页展示:1=是,0=否
|
||
* @return {"code":0,"msg":"ok","data":[{"author":"","title":"公告公告公告公告1","summary":"","content":"<p>公告公告公告公告公告公告公告公告公告公告公告公告公告额</p>","cover_url":"","id":"1","rich_text_id":"1","sort":"103","is_top":"0","is_index":"1","status":"1","created_at":"1625216065","published_at":"1625216065","viewed_num":"0","created_at_cn":"2021-07-02 16:54:25","published_at_cn":"2021-07-02 16:54:25","status_cn":"已发布"}],"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 CommonNoticeListForm();
|
||
$form->attributes = \Yii::$app->request->get();
|
||
$form->cx_mch_id = $this->cx_mch_id;
|
||
$form->status = Notice::STATUS_PUBLISHED;
|
||
$data = $form->search();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 公告
|
||
* @title 公告详情
|
||
* @description 本接口提供公告详情
|
||
* @method get
|
||
* @url /api/notice/detail
|
||
* @param notice_id 必选 int 公告ID
|
||
* @return {"code":0,"msg":"ok","data":{"author":"","title":"公告公告公告公告1","summary":"","content":"<p>公告公告公告公告公告公告公告公告公告公告公告公告公告额</p>","cover_url":"","id":"1","rich_text_id":"1","sort":"103","is_top":"0","is_index":"1","status":"1","created_at":"1625216065","published_at":"1625216065","viewed_num":"0","created_at_cn":"2021-07-02 16:54:25","published_at_cn":"2021-07-02 16:54:25","status_cn":"已发布"}}
|
||
* @return_param param param_type param_desc
|
||
* @remark
|
||
*/
|
||
public function actionDetail()
|
||
{
|
||
$form = new CommonNoticeActionForm();
|
||
$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']
|
||
]);
|
||
}
|
||
}
|
||
|
||
|
||
|