* @version : HUOSDK 8.0 */ namespace api\wapapp\controller\v8; use api\common\controller\V2ApiBaseController; use huo\controller\posts\Post; use huo\controller\posts\Posts; use huolib\constant\FormatConst; use huolib\status\CommonStatus; class NewsController extends V2ApiBaseController { public function __construct() { parent::__construct(); } /** * 资讯列表 * http://doc.1tsdk.com/95?page_id=2297 * 【域名】/v8/news/list * */ 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']); } if (FormatConst::FORMAT_HTML == $this->response_type) { $this->assign($_data); return $this->fetch('news/index'); } $this->success(lang('SUCCESS'), $_data); } /** * 资讯详情 * http://doc.1tsdk.com/138?page_id=2850 * 【域名】/v8/news/detail * */ public function read() { $_news_id = $this->request->param('news_id/d', 0); $_post_class = new Posts(); $_data = $_post_class->getDetail($_news_id); if (CommonStatus::NO_ERROR != $_data['code']) { $this->error($_data['msg'], $_data['data'], $_data['code']); } if (FormatConst::FORMAT_HTML == $this->response_type) { $this->assign($_data); return $this->fetch('news/detail'); } $this->success(lang('SUCCESS'), $_data); } }