优化代码

main
gzydong 2021-04-20 19:59:39 +08:00
parent 2d110bad77
commit 146a9c4993
3 changed files with 8 additions and 9 deletions

View File

@ -378,9 +378,9 @@ class ChatMessageConsumer extends ConsumerMessage
private function formatTalkMessage(array $data): array
{
$message = [
"id" => 0,// 消息记录ID
"source" => 1,// 消息来源[1:好友私信;2:群聊]
"msg_type" => 1,
"id" => 0, // 消息记录ID
"source" => 1, // 消息来源[1:好友私信;2:群聊]
"msg_type" => 1, // 消息类型
"user_id" => 0, // 发送者用户ID
"receive_id" => 0, // 接收者ID[好友ID或群ID]
"content" => '',// 文本消息

View File

@ -25,9 +25,6 @@ use Hyperf\Redis\Redis;
*/
class ServerStart extends ServerStartCallback
{
/**
* 回调事件
*/
public function beforeStart()
{
stdout_log()->info(sprintf('服务运行ID : %s', SERVER_RUN_ID));

View File

@ -129,12 +129,14 @@ class TalkController extends CController
];
if ($result['type'] == 1) {
$data['unread_num'] = $this->unreadTalkCache->get($user_id, $result['friend_id']);
$userInfo = User::where('id', $user_id)->first(['nickname', 'avatar']);
$data['name'] = $userInfo->nickname;
$data['avatar'] = $userInfo->avatar;
$data['unread_num'] = $this->unreadTalkCache->get($user_id, $result['friend_id']);
} else if ($result['type'] == 2) {
$groupInfo = Group::where('id', $result['group_id'])->first(['group_name', 'avatar']);
$data['name'] = $groupInfo->group_name;
$data['avatar'] = $groupInfo->avatar;
}