Imchat.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\api\controller;
  3. use \app\api\model\Imchat as ImchatModel;
  4. use app\api\service\User as UserService;
  5. /**
  6. * 聊天消息控制器
  7. * Class Imchat
  8. * @package app\api\controller
  9. */
  10. class Imchat extends Controller
  11. {
  12. /**
  13. * 历史消息列表
  14. * @return \think\response\Json
  15. */
  16. public function history()
  17. {
  18. // 获取列表数据
  19. $model = new ImchatModel;
  20. $pageSize = $this->request->param('pageSize', 15);
  21. $list = $model->getList($this->request->param(), $pageSize);
  22. return $this->renderSuccess(compact('list'));
  23. }
  24. /**
  25. * 获取最新消息用户列表
  26. * @return \think\response\Json
  27. */
  28. public function newList()
  29. {
  30. // 获取列表数据
  31. $model = new ImchatModel;
  32. $pageSize = $this->request->param('pageSize', 15);
  33. $userInfo = UserService::getCurrentLoginUser(true);
  34. $userId = isset($userInfo['user_id'])? intval($userInfo['user_id']) : 0;
  35. $list = $model->getListByUser($userId, $this->request->param(), $pageSize);
  36. return $this->renderSuccess(compact('list'));
  37. }
  38. }