1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace api\cfloat\controller;
- use api\common\controller\CFloatBaseController;
- use huo\controller\posts\Posts;
- use huolib\status\CommonStatus;
- class NewsController extends CFloatBaseController {
- public function _initialize() {
- parent::_initialize();
- }
-
- public function index() {
- $_param = $this->request->param();
- $_page = $this->request->param('page/d', 1);
- $_offset = $this->request->param('offset/d', 10);
- $_post_class = new Posts();
- $_data = $_post_class->getList($_param, $_page.','.$_offset);
- if (CommonStatus::NO_ERROR != $_data['code']) {
- $this->error($_data['msg'], $_data['data'], $_data['code']);
- }
- $this->success(lang('SUCCESS'), $_data['data'], $_data['code']);
- }
-
- public function detail() {
- $_news_id = $this->request->param('news_id/d', 0);
- if (empty($_news_id)) {
- $this->error('资讯ID不能为空', [], CommonStatus::INVALID_PARAMS);
- }
- $_post_class = new Posts();
- $_data = $_post_class->getDetail($_news_id);
- $this->success(lang('SUCCESS'), $_data['data'], $_data['code']);
- }
- }
|