// +---------------------------------------------------------------------- namespace App\Http\Controllers\Admin; use App\Services\ChatMessageService; /** * 聊天管理-控制器 * Class ChatController * @package App\Http\Controllers */ class ChatController extends Backend { /** * 构造函数 * @author laravel开发员 * @since 2020/11/11 * ChatController constructor. */ public function __construct() { parent::__construct(); $this->service = new ChatMessageService(); } /** * 获取聊天消息历史 * @return array */ public function index() { $pageSize = request()->post('limit', 30); $params = request()->all(); $list = $this->service->getDataList($params, $pageSize); $message = array( "msg" => '操作成功', "code" => 0, "data" => isset($list['list'])? $list['list']:[], "count" => isset($list['total'])? $list['total']:0, ); return $message; } /** * 获取最新的聊天窗口列表 * @return array */ public function newlist() { $pageSize = request()->post('limit', 30); $params = request()->all(); $type = isset($params['type'])? $params['type'] : 2; if($type == 2){ $list = $this->service->getDataList($params, $pageSize); }else{ $list = $this->service->getWaitList($params, $pageSize); } $userId = $this->userInfo['user_type']==2? $this->userInfo['user_id'] : 1; $counts = $this->service->getNewCount($userId); $message = array( "msg" => '操作成功', "code" => 0, "data" => isset($list['list'])? $list['list']:[], "counts" => $counts, ); return $message; } }