优化代码

main
gzydong 2021-09-11 22:50:57 +08:00
parent 5435634906
commit 99a2ddd8fe
3 changed files with 48 additions and 50 deletions

View File

@ -240,31 +240,6 @@ class TalkMessageController extends CController
return $this->response->success(); 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") * @RequestMapping(path="forward", methods="post")
*/ */
@ -349,11 +324,9 @@ class TalkMessageController extends CController
// 需要转发的好友或者群组 // 需要转发的好友或者群组
$items = array_merge($receive_user_ids, $receive_group_ids); $items = array_merge($receive_user_ids, $receive_group_ids);
if ($params['forward_mode'] == 1) {// 逐条转发 $method = $params['forward_mode'] == 1 ? "multiSplitForward" : "multiMergeForward";
$ids = $forwardService->multiSplitForward($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], $params['records_ids'], $items);
} else {// 合并转发 $ids = $forwardService->{$method}($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], $params['records_ids'], $items);
$ids = $forwardService->multiMergeForward($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], $params['records_ids'], $items);
}
if (!$ids) return $this->response->fail('转发失败!'); if (!$ids) return $this->response->fail('转发失败!');
@ -376,6 +349,16 @@ class TalkMessageController extends CController
return $this->response->success([], '转发成功...'); 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']) parse_ids($params['record_id'])
); );
return $isTrue if (!$isTrue) {
? $this->response->success([], '删除成功...') return $this->response->fail('删除失败!');
: $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);
} }
} }

View File

@ -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 * @return ResponseInterface
*/ */
public function fileStream(Filesystem $filesystem): 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 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 public function fileSubareaUpload(): ResponseInterface
{ {

View File

@ -1,11 +0,0 @@
<?php
namespace App\Service;
class PushMessageService
{
public function loginMessage(int $user_id, array $params)
{
}
}