优化代码
parent
67c0e0adee
commit
ddae0895a3
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,14 +57,14 @@ class TalkService extends BaseService
|
|||
$data['friend_id'] = $item['friend_id'];
|
||||
$data['group_id'] = $item['group_id'];
|
||||
$data['name'] = ''; // 对方昵称/群名称
|
||||
$data['unread_num'] = 0; //未读消息数量
|
||||
$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];
|
||||
|
|
Loading…
Reference in New Issue