From e298f3f9505562581bf6f24d6d70ccb52c15019b Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Mon, 9 Aug 2021 21:58:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E6=9C=AC=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/Api/V1/TalkMessageController.php | 16 +++++++++++++++- app/Service/Message/ReceiveHandleService.php | 8 ++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/Controller/Api/V1/TalkMessageController.php b/app/Controller/Api/V1/TalkMessageController.php index 9f3e5c0..02f765f 100644 --- a/app/Controller/Api/V1/TalkMessageController.php +++ b/app/Controller/Api/V1/TalkMessageController.php @@ -47,7 +47,21 @@ class TalkMessageController extends CController */ public function text() { - // todo 待开发 + $params = $this->request->inputs(['talk_type', 'receiver_id', 'text']); + $this->validate($params, [ + 'talk_type' => 'required|in:1,2', + 'receiver_id' => 'required|integer|min:1', + 'text' => 'required|max:65535', + ]); + + di()->get(TalkMessageService::class)->insertTextMessage([ + 'talk_type' => $params['talk_type'], + 'user_id' => $this->uid(), + 'receiver_id' => $params['receiver_id'], + 'content' => $params['text'], + ]); + + return $this->response->success(); } /** diff --git a/app/Service/Message/ReceiveHandleService.php b/app/Service/Message/ReceiveHandleService.php index 03f58f4..590f879 100644 --- a/app/Service/Message/ReceiveHandleService.php +++ b/app/Service/Message/ReceiveHandleService.php @@ -44,8 +44,8 @@ class ReceiveHandleService * 对话文本消息 * * @param Response|Server $server - * @param Frame $frame - * @param array|string $data 解析后数据 + * @param Frame $frame + * @param array|string $data 解析后数据 * @return void */ public function onTalk($server, Frame $frame, $data) @@ -77,8 +77,8 @@ class ReceiveHandleService * 键盘输入消息 * * @param Response|Server $server - * @param Frame $frame - * @param array|string $data 解析后数据 + * @param Frame $frame + * @param array|string $data 解析后数据 * @return false */ public function onKeyboard($server, Frame $frame, $data)