MessageController.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * MessageController.php UTF-8
  4. *
  5. *
  6. * @date : 2018/5/29 17:47
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\cfloat\controller;
  13. use api\common\controller\CFloatBaseController;
  14. use huo\controller\message\Message;
  15. use huolib\status\CommonStatus;
  16. class MessageController extends CFloatBaseController {
  17. public function _initialize() {
  18. parent::_initialize();
  19. $this->checkLogin();
  20. }
  21. /**
  22. * Client浮点消息列表
  23. * http://doc.1tsdk.com/138?page_id=3370
  24. * 【域名】/cfloat/msg/list
  25. */
  26. public function index() {
  27. $_mem_id = $this->getMemId();
  28. $_param = $this->request->param();
  29. $_page = $this->request->param('page/d', 1);
  30. $_offset = $this->request->param('offset/d', 10);
  31. $_msg_class = new Message();
  32. $_rs = $_msg_class->getList($_param, $_page.','.$_offset, $_mem_id);
  33. if (CommonStatus::NO_ERROR != $_rs['code']) {
  34. $this->error($_rs['msg'], [], $_rs['code']);
  35. }
  36. $this->success($_rs['msg'], $_rs['data'], $_rs['code']);
  37. }
  38. /**
  39. * 消息详情
  40. * http://doc.1tsdk.com/138?page_id=3371
  41. * 【域名】/cfloat/msg/detail
  42. *
  43. */
  44. public function detail() {
  45. $_mem_id = $this->getMemId();
  46. $_param = $this->request->param();
  47. $_msg_id = get_val($_param, 'id');
  48. if (empty($_msg_id)) {
  49. $this->error('消息ID不能为空', [], CommonStatus::INVALID_PARAMS);
  50. }
  51. $_msg_class = new Message();
  52. $_rs = $_msg_class->getDetail($_msg_id, $_mem_id);
  53. if (CommonStatus::NO_ERROR != $_rs['code']) {
  54. $this->error($_rs['msg'], [], $_rs['code']);
  55. }
  56. $this->success($_rs['msg'], $_rs['data'], $_rs['code']);
  57. }
  58. }