MessageController.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Http\Controllers\Admin;
  12. use App\Services\Common\MessageService;
  13. /**
  14. * 消息管理-控制器
  15. * @author laravel开发员
  16. * @since 2020/11/11
  17. * @package App\Http\Controllers
  18. */
  19. class MessageController extends Backend
  20. {
  21. /**
  22. * 构造函数
  23. * @author laravel开发员
  24. * @since 2020/11/11
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. $this->service = new MessageService();
  30. }
  31. public function index()
  32. {
  33. $pageSize = request()->get('limit', 10);
  34. $list = $this->service->getDataList(request()->all(), $pageSize);
  35. $message = array(
  36. "msg" => '操作成功',
  37. "code" => 0,
  38. "data" => isset($list['list'])? $list['list']:[],
  39. "count" => isset($list['total'])? $list['total']:0,
  40. );
  41. return $message;
  42. }
  43. /**
  44. * 历史记录
  45. * @return array
  46. * @throws \Psr\Container\ContainerExceptionInterface
  47. * @throws \Psr\Container\NotFoundExceptionInterface
  48. */
  49. public function history()
  50. {
  51. $pageSize = request()->get('limit', 10);
  52. $list = $this->service->getDataList(request()->all(), $pageSize);
  53. $message = array(
  54. "msg" => '操作成功',
  55. "code" => 0,
  56. "data" => isset($list['list'])? $list['list']:[],
  57. "count" => isset($list['total'])? $list['total']:0,
  58. "unread" => isset($list['unread'])? $list['unread']:0,
  59. );
  60. return $message;
  61. }
  62. /**
  63. * 聊天列表
  64. * @return array
  65. * @throws \Psr\Container\ContainerExceptionInterface
  66. * @throws \Psr\Container\NotFoundExceptionInterface
  67. */
  68. public function chatList()
  69. {
  70. $pageSize = request()->get('limit', 10);
  71. $list = $this->service->getChatList(request()->all(), $pageSize);
  72. $message = array(
  73. "msg" => '操作成功',
  74. "code" => 0,
  75. "data" => isset($list['list'])? $list['list']:[],
  76. "count" => isset($list['total'])? $list['total']:0,
  77. );
  78. return $message;
  79. }
  80. /**
  81. * 选项列表
  82. * @return mixed
  83. */
  84. public function options(){
  85. $result = $this->service->options();
  86. return message(1002,true, $result);
  87. }
  88. }