优化代码
parent
1fea98efb8
commit
2104cf3684
|
@ -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';
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 = '';
|
||||
|
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,10 +10,10 @@ use App\Traits\StaticInstance;
|
|||
|
||||
class VoteStatisticsCache extends StringRedis
|
||||
{
|
||||
protected $name = 'vote-statistic-cache';
|
||||
|
||||
use StaticInstance;
|
||||
|
||||
protected $name = 'vote-statistic-cache';
|
||||
|
||||
/**
|
||||
* 更新投票统计缓存
|
||||
*
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
|
@ -55,7 +56,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('暂不属于好友关系或群聊成员,无法发送聊天消息!');
|
||||
}
|
||||
|
||||
|
@ -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('暂不属于好友关系或群聊成员,无法发送聊天消息!');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue