From 2104cf36843a0a6adb0b8076338a6d261d590d12 Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Thu, 29 Jul 2021 23:30:42 +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/Cache/FriendApply.php | 3 +++ app/Cache/FriendRemark.php | 3 +++ app/Cache/LastMessage.php | 3 +++ app/Cache/ServerRunID.php | 3 +++ app/Cache/SocketFdBindUser.php | 3 +++ app/Cache/SocketRoom.php | 3 +++ app/Cache/SocketUserBindFds.php | 3 +++ app/Cache/UnreadTalkCache.php | 3 +++ app/Cache/VoteStatisticsCache.php | 4 ++-- app/Controller/Api/V1/TalkMessageController.php | 11 ++++++----- 10 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/Cache/FriendApply.php b/app/Cache/FriendApply.php index e2a0380..dada6e5 100644 --- a/app/Cache/FriendApply.php +++ b/app/Cache/FriendApply.php @@ -3,6 +3,7 @@ namespace App\Cache; use App\Cache\Repository\HashRedis; +use App\Traits\StaticInstance; /** * 好友申请未读数 - 缓存助手 @@ -11,5 +12,7 @@ use App\Cache\Repository\HashRedis; */ class FriendApply extends HashRedis { + use StaticInstance; + public $name = 'friend-apply'; } diff --git a/app/Cache/FriendRemark.php b/app/Cache/FriendRemark.php index 7e40b00..fff8846 100644 --- a/app/Cache/FriendRemark.php +++ b/app/Cache/FriendRemark.php @@ -4,6 +4,7 @@ namespace App\Cache; use App\Cache\Repository\HashRedis; use App\Model\UsersFriend; +use App\Traits\StaticInstance; /** * 好友备注 - 缓存助手 @@ -12,6 +13,8 @@ use App\Model\UsersFriend; */ class FriendRemark extends HashRedis { + use StaticInstance; + public $name = 'friend-remark'; /** diff --git a/app/Cache/LastMessage.php b/app/Cache/LastMessage.php index 106b287..44b28fc 100644 --- a/app/Cache/LastMessage.php +++ b/app/Cache/LastMessage.php @@ -3,6 +3,7 @@ namespace App\Cache; use App\Cache\Repository\HashRedis; +use App\Traits\StaticInstance; /** * 聊天最新消息 - 缓存助手 @@ -11,6 +12,8 @@ use App\Cache\Repository\HashRedis; */ class LastMessage extends HashRedis { + use StaticInstance; + public $name = 'last-message'; /** diff --git a/app/Cache/ServerRunID.php b/app/Cache/ServerRunID.php index 9767278..e907b08 100644 --- a/app/Cache/ServerRunID.php +++ b/app/Cache/ServerRunID.php @@ -3,6 +3,7 @@ namespace App\Cache; use App\Cache\Repository\HashRedis; +use App\Traits\StaticInstance; /** * 服务运行ID - 缓存助手 @@ -11,6 +12,8 @@ use App\Cache\Repository\HashRedis; */ class ServerRunID extends HashRedis { + use StaticInstance; + protected $prefix = 'SERVER_RUN_ID'; protected $name = ''; diff --git a/app/Cache/SocketFdBindUser.php b/app/Cache/SocketFdBindUser.php index bb6058e..160661e 100644 --- a/app/Cache/SocketFdBindUser.php +++ b/app/Cache/SocketFdBindUser.php @@ -3,6 +3,7 @@ namespace App\Cache; use App\Cache\Repository\HashGroupRedis; +use App\Traits\StaticInstance; /** * 注:客户端ID与用户ID绑定(多对一关系) @@ -11,6 +12,8 @@ use App\Cache\Repository\HashGroupRedis; */ class SocketFdBindUser extends HashGroupRedis { + use StaticInstance; + protected $name = 'ws:fd-user'; /** diff --git a/app/Cache/SocketRoom.php b/app/Cache/SocketRoom.php index 1377adc..b9e888d 100644 --- a/app/Cache/SocketRoom.php +++ b/app/Cache/SocketRoom.php @@ -3,6 +3,7 @@ namespace App\Cache; use App\Cache\Repository\SetGroupRedis; +use App\Traits\StaticInstance; /** * 聊天室 - 缓存助手 @@ -11,6 +12,8 @@ use App\Cache\Repository\SetGroupRedis; */ class SocketRoom extends SetGroupRedis { + use StaticInstance; + protected $name = 'ws:room'; /** diff --git a/app/Cache/SocketUserBindFds.php b/app/Cache/SocketUserBindFds.php index bb04604..a6acf89 100644 --- a/app/Cache/SocketUserBindFds.php +++ b/app/Cache/SocketUserBindFds.php @@ -3,6 +3,7 @@ namespace App\Cache; use App\Cache\Repository\SetGroupRedis; +use App\Traits\StaticInstance; /** * 注:用户ID与客户端ID绑定(一对多关系) @@ -11,6 +12,8 @@ use App\Cache\Repository\SetGroupRedis; */ class SocketUserBindFds extends SetGroupRedis { + use StaticInstance; + protected $name = 'ws:user-fds'; /** diff --git a/app/Cache/UnreadTalkCache.php b/app/Cache/UnreadTalkCache.php index 690df55..80e6cc6 100644 --- a/app/Cache/UnreadTalkCache.php +++ b/app/Cache/UnreadTalkCache.php @@ -3,6 +3,7 @@ namespace App\Cache; use App\Cache\Repository\HashRedis; +use App\Traits\StaticInstance; /** * 私信消息未读数 - 缓存助手 @@ -11,6 +12,8 @@ use App\Cache\Repository\HashRedis; */ class UnreadTalkCache extends HashRedis { + use StaticInstance; + public $name = 'unread-talk'; /** diff --git a/app/Cache/VoteStatisticsCache.php b/app/Cache/VoteStatisticsCache.php index 38cb976..003d607 100644 --- a/app/Cache/VoteStatisticsCache.php +++ b/app/Cache/VoteStatisticsCache.php @@ -10,10 +10,10 @@ use App\Traits\StaticInstance; class VoteStatisticsCache extends StringRedis { - protected $name = 'vote-statistic-cache'; - use StaticInstance; + protected $name = 'vote-statistic-cache'; + /** * 更新投票统计缓存 * diff --git a/app/Controller/Api/V1/TalkMessageController.php b/app/Controller/Api/V1/TalkMessageController.php index a7dc8ce..efa1aa1 100644 --- a/app/Controller/Api/V1/TalkMessageController.php +++ b/app/Controller/Api/V1/TalkMessageController.php @@ -1,4 +1,5 @@ uid(); - if (!UserRelation::isFriendOrGroupMember($user_id, $params['receiver_id'], $params['talk_type'])) { + if (!UserRelation::isFriendOrGroupMember($user_id, (int)$params['receiver_id'], (int)$params['talk_type'])) { return $this->response->fail('暂不属于好友关系或群聊成员,无法发送聊天消息!'); } @@ -87,7 +88,7 @@ class TalkMessageController extends CController ]); $user_id = $this->uid(); - if (!UserRelation::isFriendOrGroupMember($user_id, $params['receiver_id'], $params['talk_type'])) { + if (!UserRelation::isFriendOrGroupMember($user_id, (int)$params['receiver_id'], (int)$params['talk_type'])) { return $this->response->fail('暂不属于好友关系或群聊成员,无法发送聊天消息!'); } @@ -140,7 +141,7 @@ class TalkMessageController extends CController ]); $user_id = $this->uid(); - if (!UserRelation::isFriendOrGroupMember($user_id, $params['receiver_id'], $params['talk_type'])) { + if (!UserRelation::isFriendOrGroupMember($user_id, (int)$params['receiver_id'], (int)$params['talk_type'])) { return $this->response->fail('暂不属于好友关系或群聊成员,无法发送聊天消息!'); } @@ -189,7 +190,7 @@ class TalkMessageController extends CController ]); $user_id = $this->uid(); - if (!UserRelation::isFriendOrGroupMember($user_id, $params['receiver_id'], TalkModeConstant::GROUP_CHAT)) { + if (!UserRelation::isFriendOrGroupMember($user_id, (int)$params['receiver_id'], TalkModeConstant::GROUP_CHAT)) { return $this->response->fail('暂不属于好友关系或群聊成员,无法发送聊天消息!'); } @@ -247,7 +248,7 @@ class TalkMessageController extends CController ]); $user_id = $this->uid(); - if (!UserRelation::isFriendOrGroupMember($user_id, $params['receiver_id'], $params['talk_type'])) { + if (!UserRelation::isFriendOrGroupMember($user_id, (int)$params['receiver_id'], (int)$params['talk_type'])) { return $this->response->fail('暂不属于好友关系或群聊成员,无法发送聊天消息!'); }