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)