NewsController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * NewsController.php UTF-8
  4. * 资讯详情
  5. *
  6. * @date : 2017/11/15 18:41
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\wapapp\controller\v8;
  13. use api\common\controller\V2ApiBaseController;
  14. use huo\controller\posts\Post;
  15. use huo\controller\posts\Posts;
  16. use huolib\constant\FormatConst;
  17. use huolib\status\CommonStatus;
  18. class NewsController extends V2ApiBaseController {
  19. public function __construct() {
  20. parent::__construct();
  21. }
  22. /**
  23. * 资讯列表
  24. * http://doc.1tsdk.com/95?page_id=2297
  25. * 【域名】/v8/news/list
  26. *
  27. */
  28. public function index() {
  29. $_param = $this->request->param();
  30. $_page = $this->request->param('page/d', 1);
  31. $_offset = $this->request->param('offset/d', 10);
  32. $_post_class = new Posts();
  33. $_data = $_post_class->getList($_param, $_page.','.$_offset);
  34. if (CommonStatus::NO_ERROR != $_data['code']) {
  35. $this->error($_data['msg'], $_data['data'], $_data['code']);
  36. }
  37. if (FormatConst::FORMAT_HTML == $this->response_type) {
  38. $this->assign($_data);
  39. return $this->fetch('news/index');
  40. }
  41. $this->success(lang('SUCCESS'), $_data);
  42. }
  43. /**
  44. * 资讯详情
  45. * http://doc.1tsdk.com/138?page_id=2850
  46. * 【域名】/v8/news/detail
  47. *
  48. */
  49. public function read() {
  50. $_news_id = $this->request->param('news_id/d', 0);
  51. $_post_class = new Posts();
  52. $_data = $_post_class->getDetail($_news_id);
  53. if (CommonStatus::NO_ERROR != $_data['code']) {
  54. $this->error($_data['msg'], $_data['data'], $_data['code']);
  55. }
  56. if (FormatConst::FORMAT_HTML == $this->response_type) {
  57. $this->assign($_data);
  58. return $this->fetch('news/detail');
  59. }
  60. $this->success(lang('SUCCESS'), $_data);
  61. }
  62. }