From 99a2ddd8fe5c24260b81eff525def12faff54ad2 Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Sat, 11 Sep 2021 22:50:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/V1/TalkMessageController.php | 78 +++++++++++-------- app/Controller/Api/V1/UploadController.php | 9 +-- app/Service/PushMessageService.php | 11 --- 3 files changed, 48 insertions(+), 50 deletions(-) delete mode 100644 app/Service/PushMessageService.php diff --git a/app/Controller/Api/V1/TalkMessageController.php b/app/Controller/Api/V1/TalkMessageController.php index b8e9267..fd586ba 100644 --- a/app/Controller/Api/V1/TalkMessageController.php +++ b/app/Controller/Api/V1/TalkMessageController.php @@ -240,31 +240,6 @@ class TalkMessageController extends CController return $this->response->success(); } - /** - * 投票处理 - * - * @RequestMapping(path="vote/handle", methods="post") - */ - public function handleVote(): ResponseInterface - { - $params = $this->request->inputs(['record_id', 'options']); - $this->validate($params, [ - 'record_id' => 'required|integer|min:1', - 'options' => 'required', - ]); - - $params['options'] = array_filter(explode(',', $params['options'])); - if (!$params['options']) { - return $this->response->fail('投票失败,请稍后再试!'); - } - - [$isTrue, $cache] = $this->talkMessageService->handleVote($this->uid(), $params); - - if (!$isTrue) return $this->response->fail('投票失败,请稍后再试!'); - - return $this->response->success($cache); - } - /** * 发送表情包消息 * @@ -306,7 +281,7 @@ class TalkMessageController extends CController } /** - * 转发消息记录 + * 发送转发消息 * * @RequestMapping(path="forward", methods="post") */ @@ -349,11 +324,9 @@ class TalkMessageController extends CController // 需要转发的好友或者群组 $items = array_merge($receive_user_ids, $receive_group_ids); - if ($params['forward_mode'] == 1) {// 逐条转发 - $ids = $forwardService->multiSplitForward($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], $params['records_ids'], $items); - } else {// 合并转发 - $ids = $forwardService->multiMergeForward($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], $params['records_ids'], $items); - } + $method = $params['forward_mode'] == 1 ? "multiSplitForward" : "multiMergeForward"; + + $ids = $forwardService->{$method}($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], $params['records_ids'], $items); if (!$ids) return $this->response->fail('转发失败!'); @@ -376,6 +349,16 @@ class TalkMessageController extends CController return $this->response->success([], '转发成功...'); } + /** + * 发送用户名片消息 + * + * @RequestMapping(path="card", methods="post") + */ + public function card(): ResponseInterface + { + // todo 待开发 + } + /** * 收藏聊天图片 * @@ -436,8 +419,35 @@ class TalkMessageController extends CController parse_ids($params['record_id']) ); - return $isTrue - ? $this->response->success([], '删除成功...') - : $this->response->fail('删除失败!'); + if (!$isTrue) { + return $this->response->fail('删除失败!'); + } + + return $this->response->success([], '删除成功...'); + } + + /** + * 投票处理 + * + * @RequestMapping(path="vote/handle", methods="post") + */ + public function handleVote(): ResponseInterface + { + $params = $this->request->inputs(['record_id', 'options']); + $this->validate($params, [ + 'record_id' => 'required|integer|min:1', + 'options' => 'required', + ]); + + $params['options'] = array_filter(explode(',', $params['options'])); + if (!$params['options']) { + return $this->response->fail('投票失败,请稍后再试!'); + } + + [$isTrue, $cache] = $this->talkMessageService->handleVote($this->uid(), $params); + + if (!$isTrue) return $this->response->fail('投票失败,请稍后再试!'); + + return $this->response->success($cache); } } diff --git a/app/Controller/Api/V1/UploadController.php b/app/Controller/Api/V1/UploadController.php index 97446c1..32c7aba 100644 --- a/app/Controller/Api/V1/UploadController.php +++ b/app/Controller/Api/V1/UploadController.php @@ -29,8 +29,9 @@ class UploadController extends CController /** * 图片文件流上传接口 - * @RequestMapping(path="file-stream", methods="post") * + * @RequestMapping(path="file-stream", methods="post") + * @param Filesystem $filesystem * @return ResponseInterface */ public function fileStream(Filesystem $filesystem): ResponseInterface @@ -52,9 +53,8 @@ class UploadController extends CController /** * 获取拆分文件信息 - * @RequestMapping(path="get-file-split-info", methods="get") * - * @return ResponseInterface + * @RequestMapping(path="get-file-split-info", methods="get") */ public function getFileSplitInfo(): ResponseInterface { @@ -71,9 +71,8 @@ class UploadController extends CController /** * 文件拆分上传接口 - * @RequestMapping(path="file-subarea-upload", methods="post") * - * @return ResponseInterface + * @RequestMapping(path="file-subarea-upload", methods="post") */ public function fileSubareaUpload(): ResponseInterface { diff --git a/app/Service/PushMessageService.php b/app/Service/PushMessageService.php deleted file mode 100644 index 5316898..0000000 --- a/app/Service/PushMessageService.php +++ /dev/null @@ -1,11 +0,0 @@ -