From ddae0895a360428e03bce5ce22b59bf5c04f20df Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Sat, 22 May 2021 21:45:18 +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 --- app/Controller/Api/V1/ContactsController.php | 12 +++++------- app/Controller/Api/V1/TalkController.php | 7 +------ app/Service/TalkService.php | 14 +++++++------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/app/Controller/Api/V1/ContactsController.php b/app/Controller/Api/V1/ContactsController.php index 36e88fc..8969601 100644 --- a/app/Controller/Api/V1/ContactsController.php +++ b/app/Controller/Api/V1/ContactsController.php @@ -10,10 +10,6 @@ namespace App\Controller\Api\V1; -use App\Cache\FriendApply; -use App\Cache\FriendRemark; -use App\Cache\ServerRunID; -use App\Model\UsersFriendsApply; use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\RequestMapping; @@ -24,10 +20,12 @@ use App\Amqp\Producer\ChatMessageProducer; use App\Service\ContactsService; use App\Service\SocketClientService; use App\Service\UserService; -use App\Cache\ApplyNumCache; -use App\Cache\FriendRemarkCache; -use App\Model\UsersChatList; use App\Constants\SocketConstants; +use App\Model\UsersFriendsApply; +use App\Model\UsersChatList; +use App\Cache\FriendApply; +use App\Cache\FriendRemark; +use App\Cache\ServerRunID; /** * Class ContactsController diff --git a/app/Controller/Api/V1/TalkController.php b/app/Controller/Api/V1/TalkController.php index 94c5810..ed7da6b 100644 --- a/app/Controller/Api/V1/TalkController.php +++ b/app/Controller/Api/V1/TalkController.php @@ -60,12 +60,7 @@ class TalkController extends CController $this->talkService->updateUnreadTalkList($user_id, $list); } - // 获取聊天列表 - if ($rows = $this->talkService->talks($user_id)) { - $rows = arraysSort($rows, 'updated_at'); - } - - return $this->response->success($rows); + return $this->response->success($this->talkService->talks($user_id)); } /** diff --git a/app/Service/TalkService.php b/app/Service/TalkService.php index 19d6d62..e5233c8 100644 --- a/app/Service/TalkService.php +++ b/app/Service/TalkService.php @@ -56,15 +56,15 @@ class TalkService extends BaseService $data['type'] = $item['type']; $data['friend_id'] = $item['friend_id']; $data['group_id'] = $item['group_id']; - $data['name'] = '';//对方昵称/群名称 - $data['unread_num'] = 0; //未读消息数量 - $data['avatar'] = '';//默认头像 - $data['remark_name'] = '';//好友备注 + $data['name'] = ''; // 对方昵称/群名称 + $data['avatar'] = ''; // 默认头像 + $data['remark_name'] = ''; // 好友备注 + $data['unread_num'] = 0; // 未读消息数量 $data['msg_text'] = '......'; $data['updated_at'] = $item['updated_at']; $data['online'] = 0; - $data['not_disturb'] = $item['not_disturb']; $data['is_top'] = $item['is_top']; + $data['not_disturb'] = $item['not_disturb']; if ($item['type'] == 1) { $data['name'] = $item['nickname']; @@ -80,7 +80,7 @@ class TalkService extends BaseService ->where('user1', ($user_id < $item['friend_id']) ? $user_id : $item['friend_id']) ->where('user2', ($user_id < $item['friend_id']) ? $item['friend_id'] : $user_id)->first(); if ($info) { - $data['remark_name'] = ($info->user1 == $item['friend_id']) ? $info->user2_remark : $info->user1_remark; + $data['remark_name'] = $info->user1 == $item['friend_id'] ? $info->user2_remark : $info->user1_remark; FriendRemark::getInstance()->save($user_id, (int)$item['friend_id'], $data['remark_name']); } @@ -505,7 +505,7 @@ class TalkService extends BaseService * 1,'id' => 1658]] 二维数组 * @return array|bool */ - public function mergeForwardRecords(int $user_id, int $receive_id, int $source, $records_ids, array $receive_ids) + public function mergeForwardRecords(int $user_id, int $receive_id, int $source, array $records_ids, array $receive_ids) { // 支持转发的消息类型 $msg_type = [1, 2, 5];