优化代码

main
gzydong 2021-04-20 16:30:57 +08:00
parent 73fc864806
commit 2d110bad77
75 changed files with 1049 additions and 861 deletions

View File

@ -94,6 +94,7 @@ class ChatMessageConsumer extends ConsumerMessage
/** /**
* ChatMessageConsumer constructor. * ChatMessageConsumer constructor.
*
* @param SocketClientService $socketClientService * @param SocketClientService $socketClientService
* @param SocketRoomService $socketRoomService * @param SocketRoomService $socketRoomService
*/ */
@ -123,6 +124,7 @@ class ChatMessageConsumer extends ConsumerMessage
* *
* @param $data * @param $data
* @param AMQPMessage $message * @param AMQPMessage $message
*
* @return string * @return string
*/ */
public function consumeMessage($data, AMQPMessage $message): string public function consumeMessage($data, AMQPMessage $message): string
@ -148,6 +150,7 @@ class ChatMessageConsumer extends ConsumerMessage
* *
* @param array $data 队列消息 * @param array $data 队列消息
* @param AMQPMessage $message * @param AMQPMessage $message
*
* @return string * @return string
*/ */
public function onConsumeTalk(array $data, AMQPMessage $message): string public function onConsumeTalk(array $data, AMQPMessage $message): string
@ -263,6 +266,7 @@ class ChatMessageConsumer extends ConsumerMessage
* *
* @param array $data 队列消息 * @param array $data 队列消息
* @param AMQPMessage $message * @param AMQPMessage $message
*
* @return string * @return string
*/ */
public function onConsumeKeyboard(array $data, AMQPMessage $message): string public function onConsumeKeyboard(array $data, AMQPMessage $message): string
@ -279,6 +283,7 @@ class ChatMessageConsumer extends ConsumerMessage
* *
* @param array $data 队列消息 * @param array $data 队列消息
* @param AMQPMessage $message * @param AMQPMessage $message
*
* @return string * @return string
*/ */
public function onConsumeOnlineStatus(array $data, AMQPMessage $message): string public function onConsumeOnlineStatus(array $data, AMQPMessage $message): string
@ -300,6 +305,7 @@ class ChatMessageConsumer extends ConsumerMessage
* *
* @param array $data 队列消息 * @param array $data 队列消息
* @param AMQPMessage $message * @param AMQPMessage $message
*
* @return string * @return string
*/ */
public function onConsumeRevokeTalk(array $data, AMQPMessage $message): string public function onConsumeRevokeTalk(array $data, AMQPMessage $message): string
@ -336,6 +342,7 @@ class ChatMessageConsumer extends ConsumerMessage
* *
* @param array $data 队列消息 * @param array $data 队列消息
* @param AMQPMessage $message * @param AMQPMessage $message
*
* @return string * @return string
*/ */
public function onConsumeFriendApply(array $data, AMQPMessage $message): string public function onConsumeFriendApply(array $data, AMQPMessage $message): string
@ -365,6 +372,7 @@ class ChatMessageConsumer extends ConsumerMessage
* 格式化对话的消息体 * 格式化对话的消息体
* *
* @param array $data 对话的消息 * @param array $data 对话的消息
*
* @return array * @return array
*/ */
private function formatTalkMessage(array $data): array private function formatTalkMessage(array $data): array

View File

@ -9,6 +9,7 @@
* @author Yuandong<837215079@qq.com> * @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat * @link https://github.com/gzydong/hyperf-chat
*/ */
namespace App\Bootstrap; namespace App\Bootstrap;
use Hyperf\Framework\Bootstrap\ServerStartCallback; use Hyperf\Framework\Bootstrap\ServerStartCallback;
@ -19,6 +20,7 @@ use Hyperf\Redis\Redis;
* 自定义服务启动前回调事件 * 自定义服务启动前回调事件
* *
* Class ServerStart * Class ServerStart
*
* @package App\Bootstrap * @package App\Bootstrap
*/ */
class ServerStart extends ServerStartCallback class ServerStart extends ServerStartCallback

View File

@ -4,6 +4,7 @@ namespace App\Cache;
/** /**
* Class ApplyNumCache * Class ApplyNumCache
*
* @package App\Cache * @package App\Cache
*/ */
class ApplyNumCache class ApplyNumCache
@ -15,6 +16,7 @@ class ApplyNumCache
* 获取好友未读申请数 * 获取好友未读申请数
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return string * @return string
*/ */
public static function get(int $user_id) public static function get(int $user_id)
@ -26,6 +28,7 @@ class ApplyNumCache
* 设置未读好友申请数自增加1 * 设置未读好友申请数自增加1
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return int * @return int
*/ */
public static function setInc(int $user_id) public static function setInc(int $user_id)

View File

@ -4,6 +4,7 @@ namespace App\Cache;
/** /**
* Class FriendRemarkCache * Class FriendRemarkCache
*
* @package App\Cache * @package App\Cache
*/ */
class FriendRemarkCache class FriendRemarkCache
@ -27,6 +28,7 @@ class FriendRemarkCache
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $friend_id 好友ID * @param int $friend_id 好友ID
*
* @return string * @return string
*/ */
public static function get(int $user_id, int $friend_id) public static function get(int $user_id, int $friend_id)

View File

@ -4,6 +4,7 @@ namespace App\Cache;
/** /**
* Class LastMsgCache * Class LastMsgCache
*
* @package App\Cache * @package App\Cache
*/ */
class LastMsgCache class LastMsgCache
@ -12,6 +13,7 @@ class LastMsgCache
* 用户聊天或群聊的最后一条消息hash存储的hash名 * 用户聊天或群聊的最后一条消息hash存储的hash名
* *
* @param int $sender * @param int $sender
*
* @return string * @return string
*/ */
private static function _name($sender = 0) private static function _name($sender = 0)
@ -24,6 +26,7 @@ class LastMsgCache
* *
* @param int $receive 接收者 * @param int $receive 接收者
* @param int $sender 发送者 * @param int $sender 发送者
*
* @return string * @return string
*/ */
private static function _key(int $receive, int $sender) private static function _key(int $receive, int $sender)
@ -48,6 +51,7 @@ class LastMsgCache
* *
* @param int $receive 接收者 * @param int $receive 接收者
* @param int $sender 发送者(注:若聊天消息类型为群聊消息 $sender 应设置为0) * @param int $sender 发送者(注:若聊天消息类型为群聊消息 $sender 应设置为0)
*
* @return mixed * @return mixed
*/ */
public static function get(int $receive, $sender = 0) public static function get(int $receive, $sender = 0)

View File

@ -4,6 +4,7 @@ namespace App\Cache;
/** /**
* Class UnreadTalkCache * Class UnreadTalkCache
*
* @package App\Cache * @package App\Cache
*/ */
class UnreadTalkCache class UnreadTalkCache
@ -15,6 +16,7 @@ class UnreadTalkCache
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $friend_id 好友ID * @param string $friend_id 好友ID
*
* @return bool * @return bool
*/ */
public function setInc(int $user_id, string $friend_id) public function setInc(int $user_id, string $friend_id)
@ -29,6 +31,7 @@ class UnreadTalkCache
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $friend_id 好友ID * @param string $friend_id 好友ID
*
* @return int * @return int
*/ */
public function get(int $user_id, string $friend_id) public function get(int $user_id, string $friend_id)
@ -40,6 +43,7 @@ class UnreadTalkCache
* 获取用户未读消息列表 * 获取用户未读消息列表
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return mixed * @return mixed
*/ */
public function getAll(int $user_id) public function getAll(int $user_id)
@ -52,6 +56,7 @@ class UnreadTalkCache
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $friend_id 好友ID * @param string $friend_id 好友ID
*
* @return bool * @return bool
*/ */
public function del(int $user_id, string $friend_id) public function del(int $user_id, string $friend_id)
@ -63,6 +68,7 @@ class UnreadTalkCache
* 清除用户所有好友未读数 * 清除用户所有好友未读数
* *
* @param int $user_id * @param int $user_id
*
* @return bool * @return bool
*/ */
public function delAll(int $user_id) public function delAll(int $user_id)
@ -74,6 +80,7 @@ class UnreadTalkCache
* 获取缓存key * 获取缓存key
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return string * @return string
*/ */
private function _key(int $user_id) private function _key(int $user_id)

View File

@ -9,12 +9,14 @@
* @author Yuandong<837215079@qq.com> * @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat * @link https://github.com/gzydong/hyperf-chat
*/ */
namespace App\Constants; namespace App\Constants;
/** /**
* HTTP 响应状态码枚举 * HTTP 响应状态码枚举
* *
* Class ResponseCode * Class ResponseCode
*
* @package App\Constants * @package App\Constants
*/ */
class ResponseCode class ResponseCode

View File

@ -16,6 +16,7 @@ namespace App\Constants;
* WebSocket 消息事件枚举 * WebSocket 消息事件枚举
* *
* Class SocketConstants * Class SocketConstants
*
* @package App\Constants * @package App\Constants
*/ */
class SocketConstants class SocketConstants

View File

@ -20,6 +20,7 @@ use App\Support\Response;
* 基类控制器 * 基类控制器
* *
* Class CController * Class CController
*
* @package App\Controller\Api\V1 * @package App\Controller\Api\V1
*/ */
class CController extends AbstractController class CController extends AbstractController

View File

@ -83,6 +83,7 @@ class ContactsController extends CController
* @RequestMapping(path="add", methods="post") * @RequestMapping(path="add", methods="post")
* *
* @param UserService $userService * @param UserService $userService
*
* @return ResponseInterface * @return ResponseInterface
*/ */
public function addContact(UserService $userService) public function addContact(UserService $userService)

View File

@ -41,6 +41,7 @@ class DownloadController extends CController
* *
* @param ResponseInterface $response * @param ResponseInterface $response
* @param UploadService $uploadService * @param UploadService $uploadService
*
* @return \Psr\Http\Message\ResponseInterface * @return \Psr\Http\Message\ResponseInterface
*/ */
public function userChatFile(ResponseInterface $response, UploadService $uploadService) public function userChatFile(ResponseInterface $response, UploadService $uploadService)
@ -85,6 +86,7 @@ class DownloadController extends CController
* *
* @param ResponseInterface $response * @param ResponseInterface $response
* @param UploadService $uploadService * @param UploadService $uploadService
*
* @return \Psr\Http\Message\ResponseInterface * @return \Psr\Http\Message\ResponseInterface
*/ */
public function articleAnnex(ResponseInterface $response, UploadService $uploadService) public function articleAnnex(ResponseInterface $response, UploadService $uploadService)

View File

@ -9,6 +9,7 @@
* @author Yuandong<837215079@qq.com> * @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat * @link https://github.com/gzydong/hyperf-chat
*/ */
namespace App\Controller\Api\V1; namespace App\Controller\Api\V1;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
@ -144,6 +145,7 @@ class EmoticonController extends CController
* @RequestMapping(path="upload-emoticon", methods="post") * @RequestMapping(path="upload-emoticon", methods="post")
* *
* @param UploadService $uploadService * @param UploadService $uploadService
*
* @return ResponseInterface * @return ResponseInterface
*/ */
public function uploadEmoticon(UploadService $uploadService) public function uploadEmoticon(UploadService $uploadService)

View File

@ -9,6 +9,7 @@
* @author Yuandong<837215079@qq.com> * @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat * @link https://github.com/gzydong/hyperf-chat
*/ */
namespace App\Controller\Api\V1; namespace App\Controller\Api\V1;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
@ -484,6 +485,7 @@ class TalkController extends CController
* @RequestMapping(path="send-image", methods="post") * @RequestMapping(path="send-image", methods="post")
* *
* @param UploadService $uploadService * @param UploadService $uploadService
*
* @return ResponseInterface * @return ResponseInterface
*/ */
public function sendImage(UploadService $uploadService) public function sendImage(UploadService $uploadService)
@ -608,6 +610,7 @@ class TalkController extends CController
* @RequestMapping(path="send-file", methods="post") * @RequestMapping(path="send-file", methods="post")
* *
* @param UploadService $uploadService * @param UploadService $uploadService
*
* @return ResponseInterface * @return ResponseInterface
*/ */
public function sendFile(UploadService $uploadService) public function sendFile(UploadService $uploadService)

View File

@ -9,6 +9,7 @@
* @author Yuandong<837215079@qq.com> * @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat * @link https://github.com/gzydong/hyperf-chat
*/ */
namespace App\Controller\Api\V1; namespace App\Controller\Api\V1;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
@ -174,6 +175,7 @@ class UsersController extends CController
* @RequestMapping(path="change-mobile", methods="post") * @RequestMapping(path="change-mobile", methods="post")
* *
* @param SmsCodeService $smsCodeService * @param SmsCodeService $smsCodeService
*
* @return ResponseInterface * @return ResponseInterface
*/ */
public function editUserMobile(SmsCodeService $smsCodeService) public function editUserMobile(SmsCodeService $smsCodeService)
@ -246,6 +248,7 @@ class UsersController extends CController
* @RequestMapping(path="send-mobile-code", methods="post") * @RequestMapping(path="send-mobile-code", methods="post")
* *
* @param SmsCodeService $smsCodeService * @param SmsCodeService $smsCodeService
*
* @return ResponseInterface * @return ResponseInterface
*/ */
public function sendMobileCode(SmsCodeService $smsCodeService) public function sendMobileCode(SmsCodeService $smsCodeService)
@ -283,6 +286,7 @@ class UsersController extends CController
* @RequestMapping(path="send-change-email-code", methods="post") * @RequestMapping(path="send-change-email-code", methods="post")
* *
* @param SendEmailCode $sendEmailCode * @param SendEmailCode $sendEmailCode
*
* @return ResponseInterface * @return ResponseInterface
*/ */
public function sendChangeEmailCode(SendEmailCode $sendEmailCode) public function sendChangeEmailCode(SendEmailCode $sendEmailCode)

View File

@ -33,6 +33,7 @@ use App\Support\SocketIOParser;
/** /**
* Class WebSocketController * Class WebSocketController
*
* @package App\Controller * @package App\Controller
*/ */
class WebSocketController implements OnMessageInterface, OnOpenInterface, OnCloseInterface class WebSocketController implements OnMessageInterface, OnOpenInterface, OnCloseInterface

View File

@ -38,6 +38,7 @@ class AppExceptionHandler extends ExceptionHandler
/** /**
* @param Throwable $throwable * @param Throwable $throwable
*
* @return bool * @return bool
*/ */
public function isValid(Throwable $throwable): bool public function isValid(Throwable $throwable): bool

View File

@ -11,6 +11,7 @@ use Hyperf\WebSocketServer\Exception\WebSocketHandeShakeException;
/** /**
* Class JwtAuthExceptionHandler * Class JwtAuthExceptionHandler
*
* @package App\Exception\Handler * @package App\Exception\Handler
*/ */
class JwtAuthExceptionHandler extends ExceptionHandler class JwtAuthExceptionHandler extends ExceptionHandler
@ -38,6 +39,7 @@ class JwtAuthExceptionHandler extends ExceptionHandler
* 判断该异常处理器是否要对该异常进行处理 * 判断该异常处理器是否要对该异常进行处理
* *
* @param Throwable $throwable * @param Throwable $throwable
*
* @return bool * @return bool
*/ */
public function isValid(Throwable $throwable): bool public function isValid(Throwable $throwable): bool

View File

@ -12,6 +12,7 @@ use Throwable;
* 验证器异常处理类 * 验证器异常处理类
* *
* Class ValidateExceptionHandler * Class ValidateExceptionHandler
*
* @package App\Exception\Handler * @package App\Exception\Handler
*/ */
class ValidateExceptionHandler extends ExceptionHandler class ValidateExceptionHandler extends ExceptionHandler
@ -19,6 +20,7 @@ class ValidateExceptionHandler extends ExceptionHandler
/** /**
* @param Throwable $throwable * @param Throwable $throwable
* @param ResponseInterface $response * @param ResponseInterface $response
*
* @return ResponseInterface * @return ResponseInterface
*/ */
public function handle(Throwable $throwable, ResponseInterface $response) public function handle(Throwable $throwable, ResponseInterface $response)
@ -45,6 +47,7 @@ class ValidateExceptionHandler extends ExceptionHandler
* 判断该异常处理器是否要对该异常进行处理 * 判断该异常处理器是否要对该异常进行处理
* *
* @param Throwable $throwable * @param Throwable $throwable
*
* @return bool * @return bool
*/ */
public function isValid(Throwable $throwable): bool public function isValid(Throwable $throwable): bool

View File

@ -9,6 +9,7 @@
* @author Yuandong<837215079@qq.com> * @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat * @link https://github.com/gzydong/hyperf-chat
*/ */
namespace App\Exception; namespace App\Exception;
use Hyperf\Server\Exception\ServerException; use Hyperf\Server\Exception\ServerException;
@ -17,6 +18,7 @@ use Hyperf\Server\Exception\ServerException;
* 验证器异常类 * 验证器异常类
* *
* Class ValidateException * Class ValidateException
*
* @package App\Exception * @package App\Exception
*/ */
class ValidateException extends ServerException class ValidateException extends ServerException

View File

@ -23,6 +23,7 @@ class Hash
* Hash the given value. * Hash the given value.
* *
* @param string $value * @param string $value
*
* @return string * @return string
*/ */
public static function make(string $value) public static function make(string $value)
@ -35,6 +36,7 @@ class Hash
* *
* @param string $value * @param string $value
* @param string $hashedValue * @param string $hashedValue
*
* @return bool * @return bool
*/ */
public static function check(string $value, string $hashedValue) public static function check(string $value, string $hashedValue)

View File

@ -44,6 +44,7 @@ class HashIdsHelper
* 加密 * 加密
* *
* @param mixed ...$numbers * @param mixed ...$numbers
*
* @return string * @return string
*/ */
public static function encode(...$numbers) public static function encode(...$numbers)
@ -55,6 +56,7 @@ class HashIdsHelper
* 解密 * 解密
* *
* @param string $hash * @param string $hash
*
* @return array|mixed * @return array|mixed
* @throws \Exception * @throws \Exception
*/ */

View File

@ -17,6 +17,7 @@ namespace App\Helper;
* 字符串助手类 * 字符串助手类
* *
* Class StringHelper * Class StringHelper
*
* @package App\Helper * @package App\Helper
*/ */
class StringHelper class StringHelper
@ -25,6 +26,7 @@ class StringHelper
* 将字符串转换成二进制 * 将字符串转换成二进制
* *
* @param string $str * @param string $str
*
* @return string * @return string
*/ */
public static function str2Bin(string $str): string public static function str2Bin(string $str): string
@ -45,6 +47,7 @@ class StringHelper
* 将二进制转换成字符串 * 将二进制转换成字符串
* *
* @param string $str * @param string $str
*
* @return string * @return string
*/ */
public static function bin2Str(string $str): string public static function bin2Str(string $str): string

View File

@ -9,6 +9,7 @@ declare(strict_types=1);
* @contact group@hyperf.io * @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/ */
namespace App\Listener; namespace App\Listener;
use Hyperf\Database\Events\QueryExecuted; use Hyperf\Database\Events\QueryExecuted;

View File

@ -9,6 +9,7 @@ declare(strict_types=1);
* @contact group@hyperf.io * @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/ */
namespace App\Listener; namespace App\Listener;
use Hyperf\AsyncQueue\Event\AfterHandle; use Hyperf\AsyncQueue\Event\AfterHandle;

View File

@ -9,6 +9,7 @@
* @author Yuandong<837215079@qq.com> * @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat * @link https://github.com/gzydong/hyperf-chat
*/ */
namespace App\Middleware; namespace App\Middleware;
use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\HttpServer\Contract\RequestInterface;

View File

@ -80,6 +80,7 @@ class Group extends BaseModel
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $group_id 群ID * @param int $group_id 群ID
* @param int|array $leader 管理员类型[0:普通成员;1:管理员;2:群主;] * @param int|array $leader 管理员类型[0:普通成员;1:管理员;2:群主;]
*
* @return bool * @return bool
*/ */
public static function isManager(int $user_id, int $group_id, $leader = 2) public static function isManager(int $user_id, int $group_id, $leader = 2)
@ -91,6 +92,7 @@ class Group extends BaseModel
* 判断群组是否已解散 * 判断群组是否已解散
* *
* @param int $group_id 群ID * @param int $group_id 群ID
*
* @return bool * @return bool
*/ */
public static function isDismiss(int $group_id) public static function isDismiss(int $group_id)
@ -103,6 +105,7 @@ class Group extends BaseModel
* *
* @param int $group_id 群ID * @param int $group_id 群ID
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return bool * @return bool
*/ */
public static function isMember(int $group_id, int $user_id) public static function isMember(int $group_id, int $user_id)

View File

@ -64,6 +64,7 @@ class GroupMember extends BaseModel
* 获取聊天群成员ID * 获取聊天群成员ID
* *
* @param int $group_id 群聊ID * @param int $group_id 群聊ID
*
* @return array * @return array
*/ */
public static function getGroupMemberIds(int $group_id) public static function getGroupMemberIds(int $group_id)
@ -76,6 +77,7 @@ class GroupMember extends BaseModel
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $group_id 群ID * @param int $group_id 群ID
*
* @return string * @return string
*/ */
public static function visitCard(int $user_id, int $group_id) public static function visitCard(int $user_id, int $group_id)
@ -87,6 +89,7 @@ class GroupMember extends BaseModel
* 获取用户的所有群ID * 获取用户的所有群ID
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return array * @return array
*/ */
public static function getUserGroupIds(int $user_id) public static function getUserGroupIds(int $user_id)

View File

@ -70,6 +70,7 @@ class UsersChatList extends BaseModel
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $receive_id 接收者ID * @param int $receive_id 接收者ID
* @param int $type 创建类型 1:私聊 2:群聊 * @param int $type 创建类型 1:私聊 2:群聊
*
* @return array * @return array
*/ */
public static function addItem(int $user_id, int $receive_id, int $type) public static function addItem(int $user_id, int $receive_id, int $type)
@ -114,6 +115,7 @@ class UsersChatList extends BaseModel
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $list_id 对话列表ID * @param int $list_id 对话列表ID
* @param bool $is_top 是否置顶true: false:否) * @param bool $is_top 是否置顶true: false:否)
*
* @return bool * @return bool
*/ */
public static function topItem(int $user_id, int $list_id, $is_top = true) public static function topItem(int $user_id, int $list_id, $is_top = true)
@ -130,6 +132,7 @@ class UsersChatList extends BaseModel
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $id 聊天列表ID、好友ID或群聊ID * @param int $id 聊天列表ID、好友ID或群聊ID
* @param int $type ID类型 1聊天列表ID 2:好友ID 3:群聊ID * @param int $type ID类型 1聊天列表ID 2:好友ID 3:群聊ID
*
* @return bool * @return bool
*/ */
public static function delItem(int $user_id, int $id, $type = 1) public static function delItem(int $user_id, int $id, $type = 1)
@ -151,6 +154,7 @@ class UsersChatList extends BaseModel
* @param int $receive_id 接收者ID * @param int $receive_id 接收者ID
* @param int $type 接收者类型1:好友 2:群组) * @param int $type 接收者类型1:好友 2:群组)
* @param int $not_disturb 是否免打扰 * @param int $not_disturb 是否免打扰
*
* @return boolean * @return boolean
*/ */
public static function notDisturbItem(int $user_id, int $receive_id, int $type, int $not_disturb) public static function notDisturbItem(int $user_id, int $receive_id, int $type, int $not_disturb)

View File

@ -45,6 +45,7 @@ class UsersEmoticon extends BaseModel
/** /**
* *
* @param string $value * @param string $value
*
* @return string * @return string
*/ */
public function getEmoticonIdsAttribute($value) public function getEmoticonIdsAttribute($value)

View File

@ -64,6 +64,7 @@ class UsersFriend extends BaseModel
* 获取用户所有好友 * 获取用户所有好友
* *
* @param int $uid 用户ID * @param int $uid 用户ID
*
* @return mixed * @return mixed
*/ */
public static function getUserFriends(int $uid) public static function getUserFriends(int $uid)
@ -94,6 +95,7 @@ SQL;
* @param int $user_id1 用户1 * @param int $user_id1 用户1
* @param int $user_id2 用户2 * @param int $user_id2 用户2
* @param bool $cache 是否读取缓存 * @param bool $cache 是否读取缓存
*
* @return bool * @return bool
*/ */
public static function isFriend(int $user_id1, int $user_id2, bool $cache = false) public static function isFriend(int $user_id1, int $user_id2, bool $cache = false)
@ -120,6 +122,7 @@ SQL;
* 获取指定用户的所有朋友的用户ID * 获取指定用户的所有朋友的用户ID
* *
* @param int $user_id 指定用户ID * @param int $user_id 指定用户ID
*
* @return array * @return array
*/ */
public static function getFriendIds(int $user_id) public static function getFriendIds(int $user_id)

View File

@ -24,6 +24,7 @@ class ArticleService extends BaseService
* 获取用户文章分类列表 * 获取用户文章分类列表
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return array * @return array
*/ */
public function getUserClass(int $user_id) public function getUserClass(int $user_id)
@ -42,6 +43,7 @@ class ArticleService extends BaseService
* 获取用户文章标签列表 * 获取用户文章标签列表
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return mixed * @return mixed
*/ */
public function getUserTags(int $user_id) public function getUserTags(int $user_id)
@ -61,6 +63,7 @@ class ArticleService extends BaseService
* @param int $page 分页 * @param int $page 分页
* @param int $page_size 分页大小 * @param int $page_size 分页大小
* @param array $params 查询参数 * @param array $params 查询参数
*
* @return array * @return array
*/ */
public function getUserArticleList(int $user_id, int $page, int $page_size, $params = []) public function getUserArticleList(int $user_id, int $page, int $page_size, $params = [])
@ -114,6 +117,7 @@ class ArticleService extends BaseService
* *
* @param int $article_id 文章ID * @param int $article_id 文章ID
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return array * @return array
*/ */
public function getArticleDetail(int $article_id, $user_id = 0) public function getArticleDetail(int $article_id, $user_id = 0)
@ -154,6 +158,7 @@ class ArticleService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $article_id 笔记ID * @param int $article_id 笔记ID
*
* @return mixed * @return mixed
*/ */
public function findArticleAnnexAll(int $user_id, int $article_id) public function findArticleAnnexAll(int $user_id, int $article_id)
@ -171,6 +176,7 @@ class ArticleService extends BaseService
* @param int $uid 用户ID * @param int $uid 用户ID
* @param int|string $class_id 分类ID * @param int|string $class_id 分类ID
* @param string $class_name 分类名 * @param string $class_name 分类名
*
* @return bool|int * @return bool|int
*/ */
public function editArticleClass(int $uid, $class_id, string $class_name) public function editArticleClass(int $uid, $class_id, string $class_name)
@ -216,6 +222,7 @@ class ArticleService extends BaseService
* *
* @param int $uid 用户ID * @param int $uid 用户ID
* @param int $class_id 分类ID * @param int $class_id 分类ID
*
* @return bool * @return bool
*/ */
public function delArticleClass(int $uid, int $class_id) public function delArticleClass(int $uid, int $class_id)
@ -238,6 +245,7 @@ class ArticleService extends BaseService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $class_id 文集分类ID * @param int $class_id 文集分类ID
* @param int $sort_type 排序方式 * @param int $sort_type 排序方式
*
* @return bool * @return bool
*/ */
public function articleClassSort(int $user_id, int $class_id, int $sort_type) public function articleClassSort(int $user_id, int $class_id, int $sort_type)
@ -302,6 +310,7 @@ class ArticleService extends BaseService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $class_id 笔记分类ID * @param int $class_id 笔记分类ID
* @param int $to_class_id 笔记分类ID * @param int $to_class_id 笔记分类ID
*
* @return bool * @return bool
*/ */
public function mergeArticleClass(int $user_id, int $class_id, int $to_class_id) public function mergeArticleClass(int $user_id, int $class_id, int $to_class_id)
@ -322,6 +331,7 @@ class ArticleService extends BaseService
* @param int $uid 用户ID * @param int $uid 用户ID
* @param int $tag_id 标签ID * @param int $tag_id 标签ID
* @param string $tag_name 标签名 * @param string $tag_name 标签名
*
* @return bool|int * @return bool|int
*/ */
public function editArticleTag(int $uid, int $tag_id, string $tag_name) public function editArticleTag(int $uid, int $tag_id, string $tag_name)
@ -353,6 +363,7 @@ class ArticleService extends BaseService
* *
* @param int $uid 用户ID * @param int $uid 用户ID
* @param int $tag_id 标签ID * @param int $tag_id 标签ID
*
* @return bool * @return bool
*/ */
public function delArticleTags(int $uid, int $tag_id) public function delArticleTags(int $uid, int $tag_id)
@ -375,6 +386,7 @@ class ArticleService extends BaseService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $article_id 文章ID * @param int $article_id 文章ID
* @param array $data 文章数据 * @param array $data 文章数据
*
* @return bool * @return bool
*/ */
public function editArticle(int $user_id, int $article_id, $data = []) public function editArticle(int $user_id, int $article_id, $data = [])
@ -440,6 +452,7 @@ class ArticleService extends BaseService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $article_id 笔记ID * @param int $article_id 笔记ID
* @param int $status 笔记状态 1:正常 2:已删除 * @param int $status 笔记状态 1:正常 2:已删除
*
* @return bool * @return bool
*/ */
public function updateArticleStatus(int $user_id, int $article_id, int $status) public function updateArticleStatus(int $user_id, int $article_id, int $status)
@ -458,6 +471,7 @@ class ArticleService extends BaseService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $article_id 笔记ID * @param int $article_id 笔记ID
* @param int $class_id 笔记分类ID * @param int $class_id 笔记分类ID
*
* @return bool * @return bool
*/ */
public function moveArticle(int $user_id, int $article_id, int $class_id) public function moveArticle(int $user_id, int $article_id, int $class_id)
@ -471,6 +485,7 @@ class ArticleService extends BaseService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $article_id 笔记ID * @param int $article_id 笔记ID
* @param int $type 1:标记星号 2:取消星号标记 * @param int $type 1:标记星号 2:取消星号标记
*
* @return bool * @return bool
*/ */
public function setAsteriskArticle(int $user_id, int $article_id, int $type) public function setAsteriskArticle(int $user_id, int $article_id, int $type)
@ -486,6 +501,7 @@ class ArticleService extends BaseService
* @param int $uid 用户ID * @param int $uid 用户ID
* @param int $article_id 笔记ID * @param int $article_id 笔记ID
* @param array $tags 关联标签ID * @param array $tags 关联标签ID
*
* @return bool * @return bool
*/ */
public function updateArticleTag(int $uid, int $article_id, array $tags) public function updateArticleTag(int $uid, int $article_id, array $tags)
@ -498,6 +514,7 @@ class ArticleService extends BaseService
* *
* @param int $uid 用户ID * @param int $uid 用户ID
* @param int $article_id 笔记ID * @param int $article_id 笔记ID
*
* @return bool|int|mixed|null * @return bool|int|mixed|null
* @throws Exception * @throws Exception
*/ */
@ -547,6 +564,7 @@ class ArticleService extends BaseService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $annex_id 附件ID * @param int $annex_id 附件ID
* @param int $status 附件状态 1:正常 2:已删除 * @param int $status 附件状态 1:正常 2:已删除
*
* @return bool * @return bool
*/ */
public function updateArticleAnnexStatus(int $user_id, int $annex_id, int $status) public function updateArticleAnnexStatus(int $user_id, int $annex_id, int $status)
@ -563,6 +581,7 @@ class ArticleService extends BaseService
* 回收站附件列表 * 回收站附件列表
* *
* @param int $uid 用户ID * @param int $uid 用户ID
*
* @return array * @return array
*/ */
public function recoverAnnexList(int $uid) public function recoverAnnexList(int $uid)
@ -584,12 +603,14 @@ class ArticleService extends BaseService
* *
* @param int $uid 用户ID * @param int $uid 用户ID
* @param int $annex_id 笔记附件ID * @param int $annex_id 笔记附件ID
*
* @return bool|int|mixed|null * @return bool|int|mixed|null
*/ */
/** /**
* @param int $uid * @param int $uid
* @param int $annex_id * @param int $annex_id
*
* @return bool|int|mixed|null * @return bool|int|mixed|null
* @throws Exception * @throws Exception
*/ */
@ -614,6 +635,7 @@ class ArticleService extends BaseService
* @param int $user_id 用户id * @param int $user_id 用户id
* @param int $article_id 笔记ID * @param int $article_id 笔记ID
* @param array $annex 笔记附件信息 * @param array $annex 笔记附件信息
*
* @return bool * @return bool
*/ */
public function insertArticleAnnex(int $user_id, int $article_id, array $annex) public function insertArticleAnnex(int $user_id, int $article_id, array $annex)

View File

@ -33,6 +33,7 @@ class ContactsService extends BaseService
* 获取联系人列表 * 获取联系人列表
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return array * @return array
*/ */
public function getContacts(int $user_id): array public function getContacts(int $user_id): array
@ -63,6 +64,7 @@ SQL;
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $friend_id 好友ID * @param int $friend_id 好友ID
* @param string $remarks 申请备注 * @param string $remarks 申请备注
*
* @return bool * @return bool
*/ */
public function addContact(int $user_id, int $friend_id, string $remarks): bool public function addContact(int $user_id, int $friend_id, string $remarks): bool
@ -99,6 +101,7 @@ SQL;
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $friend_id 好友ID * @param int $friend_id 好友ID
*
* @return bool * @return bool
*/ */
public function deleteContact(int $user_id, int $friend_id): bool public function deleteContact(int $user_id, int $friend_id): bool
@ -123,6 +126,7 @@ SQL;
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $apply_id 联系人申请ID * @param int $apply_id 联系人申请ID
* @param string $remarks 联系人备注名称 * @param string $remarks 联系人备注名称
*
* @return bool * @return bool
*/ */
public function acceptInvitation(int $user_id, int $apply_id, string $remarks = ''): bool public function acceptInvitation(int $user_id, int $apply_id, string $remarks = ''): bool
@ -185,6 +189,7 @@ SQL;
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $apply_id 联系人申请ID * @param int $apply_id 联系人申请ID
* @param string $remarks 拒绝申请备注信息 * @param string $remarks 拒绝申请备注信息
*
* @return bool * @return bool
*/ */
public function declineInvitation(int $user_id, int $apply_id, string $remarks = ''): bool public function declineInvitation(int $user_id, int $apply_id, string $remarks = ''): bool
@ -208,6 +213,7 @@ SQL;
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $friend_id 朋友ID * @param int $friend_id 朋友ID
* @param string $remarks 好友备注名称 * @param string $remarks 好友备注名称
*
* @return bool * @return bool
*/ */
public function editContactRemark(int $user_id, int $friend_id, string $remarks): bool public function editContactRemark(int $user_id, int $friend_id, string $remarks): bool
@ -227,6 +233,7 @@ SQL;
* 搜索联系人 * 搜索联系人
* *
* @param string $mobile 用户手机号/登录账号 * @param string $mobile 用户手机号/登录账号
*
* @return array * @return array
*/ */
public function findContact(string $mobile): array public function findContact(string $mobile): array
@ -242,6 +249,7 @@ SQL;
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $page 当前分页 * @param int $page 当前分页
* @param int $page_size 分页大小 * @param int $page_size 分页大小
*
* @return array * @return array
*/ */
public function getContactApplyRecords(int $user_id, $page = 1, $page_size = 30): array public function getContactApplyRecords(int $user_id, $page = 1, $page_size = 30): array
@ -275,6 +283,7 @@ SQL;
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $apply_id 联系人好友申请ID * @param int $apply_id 联系人好友申请ID
*
* @return bool * @return bool
*/ */
public function delContactApplyRecord(int $user_id, int $apply_id): bool public function delContactApplyRecord(int $user_id, int $apply_id): bool

View File

@ -12,6 +12,7 @@ use App\Model\UsersEmoticon;
* 表情服务层 * 表情服务层
* *
* Class EmoticonService * Class EmoticonService
*
* @package App\Services * @package App\Services
*/ */
class EmoticonService extends BaseService class EmoticonService extends BaseService
@ -21,6 +22,7 @@ class EmoticonService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $emoticon_id 表情包ID * @param int $emoticon_id 表情包ID
*
* @return mixed * @return mixed
*/ */
public function installSysEmoticon(int $user_id, int $emoticon_id) public function installSysEmoticon(int $user_id, int $emoticon_id)
@ -46,6 +48,7 @@ class EmoticonService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $emoticon_id 表情包ID * @param int $emoticon_id 表情包ID
*
* @return bool * @return bool
*/ */
public function removeSysEmoticon(int $user_id, int $emoticon_id) public function removeSysEmoticon(int $user_id, int $emoticon_id)
@ -75,6 +78,7 @@ class EmoticonService extends BaseService
* 获取用户安装的表情ID * 获取用户安装的表情ID
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return array * @return array
*/ */
public function getInstallIds(int $user_id) public function getInstallIds(int $user_id)
@ -88,6 +92,7 @@ class EmoticonService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $record_id 聊天消息ID * @param int $record_id 聊天消息ID
*
* @return array * @return array
*/ */
public function collect(int $user_id, int $record_id) public function collect(int $user_id, int $record_id)
@ -143,6 +148,7 @@ class EmoticonService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param array $ids 表情包详情ID * @param array $ids 表情包详情ID
*
* @return * @return
*/ */
public function deleteCollect(int $user_id, array $ids) public function deleteCollect(int $user_id, array $ids)
@ -154,6 +160,7 @@ class EmoticonService extends BaseService
* 获取表情包列表 * 获取表情包列表
* *
* @param array $where * @param array $where
*
* @return mixed * @return mixed
*/ */
public function getDetailsAll(array $where = []) public function getDetailsAll(array $where = [])

View File

@ -23,6 +23,7 @@ class GroupService extends BaseService
* 获取用户所在的群聊 * 获取用户所在的群聊
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return array * @return array
*/ */
public function getGroups(int $user_id): array public function getGroups(int $user_id): array
@ -59,6 +60,7 @@ class GroupService extends BaseService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param array $group_info 群聊名称 * @param array $group_info 群聊名称
* @param array $friend_ids 好友的用户ID * @param array $friend_ids 好友的用户ID
*
* @return array * @return array
*/ */
public function create(int $user_id, array $group_info, $friend_ids = []) public function create(int $user_id, array $group_info, $friend_ids = [])
@ -144,6 +146,7 @@ class GroupService extends BaseService
* *
* @param int $group_id 群ID * @param int $group_id 群ID
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return bool * @return bool
*/ */
public function dismiss(int $group_id, int $user_id) public function dismiss(int $group_id, int $user_id)
@ -174,6 +177,7 @@ class GroupService extends BaseService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $group_id 聊天群ID * @param int $group_id 聊天群ID
* @param array $friend_ids 被邀请的用户ID * @param array $friend_ids 被邀请的用户ID
*
* @return array * @return array
*/ */
public function invite(int $user_id, int $group_id, $friend_ids = []) public function invite(int $user_id, int $group_id, $friend_ids = [])
@ -278,6 +282,7 @@ class GroupService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $group_id 群组ID * @param int $group_id 群组ID
*
* @return array * @return array
*/ */
public function quit(int $user_id, int $group_id) public function quit(int $user_id, int $group_id)
@ -332,6 +337,7 @@ class GroupService extends BaseService
* @param int $group_id 群ID * @param int $group_id 群ID
* @param int $user_id 操作用户ID * @param int $user_id 操作用户ID
* @param array $member_ids 群成员ID * @param array $member_ids 群成员ID
*
* @return array * @return array
*/ */
public function removeMember(int $group_id, int $user_id, array $member_ids) public function removeMember(int $group_id, int $user_id, array $member_ids)

View File

@ -7,6 +7,7 @@ use PHPMailer\PHPMailer\Exception;
/** /**
* Class MailerService * Class MailerService
*
* @package App\Service * @package App\Service
*/ */
class MailerService class MailerService
@ -24,6 +25,7 @@ class MailerService
* @param string $email 邮箱 * @param string $email 邮箱
* @param string $subject 标题 * @param string $subject 标题
* @param string $template 对应邮件模板 * @param string $template 对应邮件模板
*
* @return bool * @return bool
*/ */
public function send($email, $subject, $template) public function send($email, $subject, $template)
@ -41,6 +43,7 @@ class MailerService
* @param string $email 邮箱 * @param string $email 邮箱
* @param string $subject 标题 * @param string $subject 标题
* @param string $template 对应邮件模板 * @param string $template 对应邮件模板
*
* @return bool * @return bool
*/ */
public function realSend($email, $subject, $template) public function realSend($email, $subject, $template)
@ -58,6 +61,7 @@ class MailerService
* @param string $address 收件人 * @param string $address 收件人
* @param string $subject 邮件标题 * @param string $subject 邮件标题
* @param string $view 邮件内容 * @param string $view 邮件内容
*
* @return bool * @return bool
* @throws Exception * @throws Exception
*/ */

View File

@ -40,6 +40,7 @@ class MessageHandleService
* @param Response|Server $server * @param Response|Server $server
* @param Frame $frame * @param Frame $frame
* @param array|string $data 解析后数据 * @param array|string $data 解析后数据
*
* @return bool|void * @return bool|void
*/ */
public function onTalk($server, Frame $frame, $data) public function onTalk($server, Frame $frame, $data)
@ -108,6 +109,7 @@ class MessageHandleService
* @param Response|Server $server * @param Response|Server $server
* @param Frame $frame * @param Frame $frame
* @param array|string $data 解析后数据 * @param array|string $data 解析后数据
*
* @return bool|void * @return bool|void
*/ */
public function onKeyboard($server, Frame $frame, $data) public function onKeyboard($server, Frame $frame, $data)

View File

@ -6,6 +6,7 @@ namespace App\Service;
* 短信发送服务 * 短信发送服务
* *
* Class SmsCodeService * Class SmsCodeService
*
* @package App\Services * @package App\Services
*/ */
class SmsCodeService class SmsCodeService
@ -34,6 +35,7 @@ class SmsCodeService
* *
* @param string $type 短信用途 * @param string $type 短信用途
* @param string $mobile 手机号 * @param string $mobile 手机号
*
* @return string * @return string
*/ */
private function getKey(string $type, string $mobile) private function getKey(string $type, string $mobile)
@ -47,6 +49,7 @@ class SmsCodeService
* @param string $type 发送类型 * @param string $type 发送类型
* @param string $mobile 手机号 * @param string $mobile 手机号
* @param string $code 验证码 * @param string $code 验证码
*
* @return bool * @return bool
*/ */
public function check(string $type, string $mobile, string $code) public function check(string $type, string $mobile, string $code)
@ -61,6 +64,7 @@ class SmsCodeService
* *
* @param string $usage 验证码用途 * @param string $usage 验证码用途
* @param string $mobile 手机号 * @param string $mobile 手机号
*
* @return array|bool * @return array|bool
*/ */
public function send(string $usage, string $mobile) public function send(string $usage, string $mobile)
@ -99,6 +103,7 @@ class SmsCodeService
* 获取缓存的验证码 * 获取缓存的验证码
* *
* @param string $key * @param string $key
*
* @return mixed * @return mixed
*/ */
public function getCode(string $key) public function getCode(string $key)
@ -112,6 +117,7 @@ class SmsCodeService
* @param string $key 缓存key * @param string $key 缓存key
* @param string $sms_code 验证码 * @param string $sms_code 验证码
* @param float|int $exp 过期时间默认15分钟 * @param float|int $exp 过期时间默认15分钟
*
* @return mixed * @return mixed
*/ */
public function setCode(string $key, string $sms_code, $exp = 60 * 15) public function setCode(string $key, string $sms_code, $exp = 60 * 15)
@ -124,6 +130,7 @@ class SmsCodeService
* *
* @param string $usage 验证码用途 * @param string $usage 验证码用途
* @param string $mobile 手机号 * @param string $mobile 手机号
*
* @return mixed * @return mixed
*/ */
public function delCode(string $usage, string $mobile) public function delCode(string $usage, string $mobile)
@ -136,6 +143,7 @@ class SmsCodeService
* *
* @param string $usage 验证码用途 * @param string $usage 验证码用途
* @param string $mobile 手机号 * @param string $mobile 手机号
*
* @return array * @return array
*/ */
public function filter(string $usage, string $mobile) public function filter(string $usage, string $mobile)
@ -158,6 +166,7 @@ class SmsCodeService
* 判断验证码用途渠道是否注册 * 判断验证码用途渠道是否注册
* *
* @param string $usage * @param string $usage
*
* @return bool * @return bool
*/ */
public function isUsages(string $usage) public function isUsages(string $usage)

View File

@ -5,6 +5,7 @@ namespace App\Service;
/** /**
* 短信服务 * 短信服务
* Class SmsService * Class SmsService
*
* @package App\Service * @package App\Service
*/ */
class SmsService class SmsService

View File

@ -42,6 +42,7 @@ class SocketClientService
* @param int $fd 客户端fd * @param int $fd 客户端fd
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $run_id 服务运行ID默认当前服务ID * @param string $run_id 服务运行ID默认当前服务ID
*
* @return mixed * @return mixed
*/ */
public function bindRelation(int $fd, int $user_id, $run_id = SERVER_RUN_ID) public function bindRelation(int $fd, int $user_id, $run_id = SERVER_RUN_ID)
@ -71,6 +72,7 @@ class SocketClientService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $run_id 服务运行ID默认当前服务ID * @param string $run_id 服务运行ID默认当前服务ID
*
* @return bool * @return bool
*/ */
public function isOnline(int $user_id, $run_id = SERVER_RUN_ID): bool public function isOnline(int $user_id, $run_id = SERVER_RUN_ID): bool
@ -83,6 +85,7 @@ class SocketClientService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param array $run_ids 服务运行ID * @param array $run_ids 服务运行ID
*
* @return bool * @return bool
*/ */
public function isOnlineAll(int $user_id, array $run_ids = []) public function isOnlineAll(int $user_id, array $run_ids = [])
@ -101,6 +104,7 @@ class SocketClientService
* *
* @param int $fd 客户端ID * @param int $fd 客户端ID
* @param string $run_id 服务运行ID默认当前服务ID * @param string $run_id 服务运行ID默认当前服务ID
*
* @return int * @return int
*/ */
public function findFdUserId(int $fd, $run_id = SERVER_RUN_ID) public function findFdUserId(int $fd, $run_id = SERVER_RUN_ID)
@ -113,6 +117,7 @@ class SocketClientService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $run_id 服务运行ID默认当前服务ID * @param string $run_id 服务运行ID默认当前服务ID
*
* @return array * @return array
*/ */
public function findUserFds(int $user_id, $run_id = SERVER_RUN_ID) public function findUserFds(int $user_id, $run_id = SERVER_RUN_ID)
@ -127,6 +132,7 @@ class SocketClientService
* 获取服务ID列表 * 获取服务ID列表
* *
* @param int $type 获取类型[1:正在运行;2:已超时;3:所有] * @param int $type 获取类型[1:正在运行;2:已超时;3:所有]
*
* @return array * @return array
*/ */
public function getServerRunIdAll(int $type = 1) public function getServerRunIdAll(int $type = 1)

View File

@ -6,6 +6,7 @@ namespace App\Service;
* 聊天室房间服务 * 聊天室房间服务
* *
* Class SocketRoomService * Class SocketRoomService
*
* @package App\Service * @package App\Service
*/ */
class SocketRoomService class SocketRoomService
@ -16,6 +17,7 @@ class SocketRoomService
* 获取房间名 * 获取房间名
* *
* @param string|integer $room 房间名 * @param string|integer $room 房间名
*
* @return string * @return string
*/ */
public function getRoomName($room) public function getRoomName($room)
@ -27,6 +29,7 @@ class SocketRoomService
* 获取房间成员 * 获取房间成员
* *
* @param string $room 房间名 * @param string $room 房间名
*
* @return array * @return array
*/ */
public function getRoomMembers(string $room) public function getRoomMembers(string $room)
@ -39,6 +42,7 @@ class SocketRoomService
* *
* @param int $usr_id 用户ID * @param int $usr_id 用户ID
* @param string|array $room 房间名 * @param string|array $room 房间名
*
* @return bool|int * @return bool|int
*/ */
public function addRoomMember(int $usr_id, $room) public function addRoomMember(int $usr_id, $room)
@ -51,6 +55,7 @@ class SocketRoomService
* *
* @param string|array $room 房间名 * @param string|array $room 房间名
* @param string|array $members 用户ID * @param string|array $members 用户ID
*
* @return int * @return int
*/ */
public function delRoomMember($room, $members) public function delRoomMember($room, $members)
@ -62,6 +67,7 @@ class SocketRoomService
* 删除房间 * 删除房间
* *
* @param string|int $room 房间名 * @param string|int $room 房间名
*
* @return int * @return int
*/ */
public function delRoom($room) public function delRoom($room)

View File

@ -10,6 +10,7 @@ use Hyperf\HttpMessage\Upload\UploadedFile;
* 文件拆分上传服务 * 文件拆分上传服务
* *
* Class SplitUploadService * Class SplitUploadService
*
* @package App\Service * @package App\Service
*/ */
class SplitUploadService class SplitUploadService
@ -83,7 +84,7 @@ class SplitUploadService
$info = FileSplitUpload::where('user_id', $user_id)->where('hash_name', $hashName)->where('split_index', $split_index)->first(); $info = FileSplitUpload::where('user_id', $user_id)->where('hash_name', $hashName)->where('split_index', $split_index)->first();
if (!$info) { if (!$info) {
return FileSplitUpload::create([ return (bool)FileSplitUpload::create([
'user_id' => $user_id, 'user_id' => $user_id,
'file_type' => 2, 'file_type' => 2,
'hash_name' => $hashName, 'hash_name' => $hashName,
@ -94,7 +95,7 @@ class SplitUploadService
'file_ext' => $fileInfo->file_ext, 'file_ext' => $fileInfo->file_ext,
'file_size' => $fileSize, 'file_size' => $fileSize,
'upload_at' => time(), 'upload_at' => time(),
]) ? true : false; ]);
} }
return true; return true;

View File

@ -26,6 +26,7 @@ class TalkService extends BaseService
* 获取用户的聊天列表 * 获取用户的聊天列表
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
*
* @return array * @return array
*/ */
public function talks(int $user_id) public function talks(int $user_id)
@ -126,6 +127,7 @@ class TalkService extends BaseService
* 处理聊天记录信息 * 处理聊天记录信息
* *
* @param array $rows 聊天记录 * @param array $rows 聊天记录
*
* @return array * @return array
*/ */
public function handleChatRecords(array $rows) public function handleChatRecords(array $rows)
@ -232,6 +234,7 @@ class TalkService extends BaseService
* @param int $record_id 上一次查询的聊天记录ID * @param int $record_id 上一次查询的聊天记录ID
* @param int $limit 查询数据长度 * @param int $limit 查询数据长度
* @param array $msg_type 消息类型 * @param array $msg_type 消息类型
*
* @return array * @return array
*/ */
public function getChatRecords(int $user_id, int $receive_id, int $source, int $record_id, $limit = 30, $msg_type = []) public function getChatRecords(int $user_id, int $receive_id, int $source, int $record_id, $limit = 30, $msg_type = [])
@ -292,6 +295,7 @@ class TalkService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $record_id 聊天记录ID * @param int $record_id 聊天记录ID
*
* @return array * @return array
*/ */
public function getForwardRecords(int $user_id, int $record_id) public function getForwardRecords(int $user_id, int $record_id)
@ -336,6 +340,7 @@ class TalkService extends BaseService
* @param int $source 消息来源 1:好友消息 2:群聊消息 * @param int $source 消息来源 1:好友消息 2:群聊消息
* @param int $receive_id 好友ID或者群聊ID * @param int $receive_id 好友ID或者群聊ID
* @param array $record_ids 聊天记录ID * @param array $record_ids 聊天记录ID
*
* @return bool * @return bool
*/ */
public function removeRecords(int $user_id, int $source, int $receive_id, array $record_ids) public function removeRecords(int $user_id, int $source, int $receive_id, array $record_ids)
@ -374,6 +379,7 @@ class TalkService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param int $record_id 聊天记录ID * @param int $record_id 聊天记录ID
*
* @return array * @return array
*/ */
public function revokeRecord(int $user_id, int $record_id) public function revokeRecord(int $user_id, int $record_id)
@ -408,6 +414,7 @@ class TalkService extends BaseService
* @param int $user_id 转发的用户ID * @param int $user_id 转发的用户ID
* @param int $record_id 转发消息的记录ID * @param int $record_id 转发消息的记录ID
* @param array $receive_ids 接受者数组 例如:[['source' => 1,'id' => 3045],['source' => 1,'id' => 3046],['source' => 1,'id' => 1658]] 二维数组 * @param array $receive_ids 接受者数组 例如:[['source' => 1,'id' => 3045],['source' => 1,'id' => 3046],['source' => 1,'id' => 1658]] 二维数组
*
* @return array * @return array
*/ */
public function forwardRecords(int $user_id, int $record_id, array $receive_ids) public function forwardRecords(int $user_id, int $record_id, array $receive_ids)
@ -621,6 +628,7 @@ class TalkService extends BaseService
* @param int $page 当前查询分页 * @param int $page 当前查询分页
* @param int $page_size 分页大小 * @param int $page_size 分页大小
* @param array $params 查询参数 * @param array $params 查询参数
*
* @return mixed * @return mixed
*/ */
public function searchRecords(int $user_id, int $receive_id, int $source, int $page, int $page_size, array $params) public function searchRecords(int $user_id, int $receive_id, int $source, int $page, int $page_size, array $params)
@ -677,6 +685,7 @@ class TalkService extends BaseService
* *
* @param $message * @param $message
* @param $fileInfo * @param $fileInfo
*
* @return bool|int * @return bool|int
*/ */
public function createImgMessage($message, $fileInfo) public function createImgMessage($message, $fileInfo)
@ -710,6 +719,7 @@ class TalkService extends BaseService
* *
* @param array $message * @param array $message
* @param array $codeBlock * @param array $codeBlock
*
* @return bool|int * @return bool|int
*/ */
public function createCodeMessage(array $message, array $codeBlock) public function createCodeMessage(array $message, array $codeBlock)
@ -742,6 +752,7 @@ class TalkService extends BaseService
* *
* @param array $message * @param array $message
* @param array $emoticon * @param array $emoticon
*
* @return bool|int * @return bool|int
*/ */
public function createEmoticonMessage(array $message, array $emoticon) public function createEmoticonMessage(array $message, array $emoticon)
@ -774,6 +785,7 @@ class TalkService extends BaseService
* *
* @param array $message * @param array $message
* @param array $emoticon * @param array $emoticon
*
* @return bool|int * @return bool|int
*/ */
public function createFileMessage(array $message, array $emoticon) public function createFileMessage(array $message, array $emoticon)

View File

@ -8,6 +8,7 @@ use Hyperf\HttpMessage\Upload\UploadedFile;
* 文件上传服务 * 文件上传服务
* *
* Class UploadService * Class UploadService
*
* @package App\Service * @package App\Service
*/ */
class UploadService extends BaseService class UploadService extends BaseService

View File

@ -16,6 +16,7 @@ class UserService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param array $field 查询字段 * @param array $field 查询字段
*
* @return mixed * @return mixed
*/ */
public function findById(int $user_id, $field = ['*']) public function findById(int $user_id, $field = ['*'])
@ -28,6 +29,7 @@ class UserService extends BaseService
* *
* @param string $mobile 手机号 * @param string $mobile 手机号
* @param string $password 登录密码 * @param string $password 登录密码
*
* @return array|bool * @return array|bool
*/ */
public function login(string $mobile, string $password) public function login(string $mobile, string $password)
@ -47,6 +49,7 @@ class UserService extends BaseService
* 账号注册逻辑 * 账号注册逻辑
* *
* @param array $data 用户数据 * @param array $data 用户数据
*
* @return bool * @return bool
*/ */
public function register(array $data) public function register(array $data)
@ -81,6 +84,7 @@ class UserService extends BaseService
* *
* @param string $mobile 用户手机好 * @param string $mobile 用户手机好
* @param string $password 新密码 * @param string $password 新密码
*
* @return mixed * @return mixed
*/ */
public function resetPassword(string $mobile, string $password) public function resetPassword(string $mobile, string $password)
@ -93,6 +97,7 @@ class UserService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $mobile 换绑手机号 * @param string $mobile 换绑手机号
*
* @return array|bool * @return array|bool
*/ */
public function changeMobile(int $user_id, string $mobile) public function changeMobile(int $user_id, string $mobile)
@ -110,6 +115,7 @@ class UserService extends BaseService
* *
* @param int $friend_id 用户ID * @param int $friend_id 用户ID
* @param int $me_user_id 当前登录用户的ID * @param int $me_user_id 当前登录用户的ID
*
* @return array * @return array
*/ */
public function getUserCard(int $friend_id, int $me_user_id) public function getUserCard(int $friend_id, int $me_user_id)

View File

@ -7,6 +7,7 @@ use PHPMailer\PHPMailer\Exception;
/** /**
* Class Mail * Class Mail
*
* @package App\Support * @package App\Support
*/ */
class Mail class Mail
@ -17,6 +18,7 @@ class Mail
* @param string $email 邮箱地址 * @param string $email 邮箱地址
* @param string $sms_code 验证码 * @param string $sms_code 验证码
* @param string $title 邮件标题 * @param string $title 邮件标题
*
* @return bool * @return bool
*/ */
public function sendEmailCode(string $email, string $sms_code, string $title) public function sendEmailCode(string $email, string $sms_code, string $title)
@ -38,6 +40,7 @@ class Mail
* @param string $address * @param string $address
* @param string $subject * @param string $subject
* @param string $view * @param string $view
*
* @return bool * @return bool
* @throws \PHPMailer\PHPMailer\Exception * @throws \PHPMailer\PHPMailer\Exception
*/ */
@ -65,6 +68,7 @@ class Mail
* @param string $engine * @param string $engine
* @param $template * @param $template
* @param array $params * @param array $params
*
* @return string * @return string
*/ */
private function view(string $engine, $template, $params = []): string private function view(string $engine, $template, $params = []): string

View File

@ -5,6 +5,7 @@ namespace App\Support;
/** /**
* 邮件视图模板 * 邮件视图模板
* Class MailerViewTemplate * Class MailerViewTemplate
*
* @package App\Support * @package App\Support
*/ */
class MailerTemplate class MailerTemplate
@ -15,6 +16,7 @@ class MailerTemplate
* @param string $engine 模板引擎 * @param string $engine 模板引擎
* @param string $template 模板名称 * @param string $template 模板名称
* @param array $params 模板参数 * @param array $params 模板参数
*
* @return string * @return string
*/ */
public function view(string $engine, string $template, $params = []): string public function view(string $engine, string $template, $params = []): string
@ -27,6 +29,7 @@ class MailerTemplate
* *
* @param string $sms_code 验证码 * @param string $sms_code 验证码
* @param array $params 模板参数 * @param array $params 模板参数
*
* @return string * @return string
*/ */
public function emailCode(string $sms_code, array $params = []) public function emailCode(string $sms_code, array $params = [])

View File

@ -4,6 +4,7 @@ namespace App\Support;
/** /**
* Class RedisLock * Class RedisLock
*
* @package App\Support * @package App\Support
*/ */
class RedisLock class RedisLock
@ -34,6 +35,7 @@ class RedisLock
* @param integer $lockSecond 锁定时间 单位() * @param integer $lockSecond 锁定时间 单位()
* @param integer $timeout 取锁超时时间。单位()。等于0,如果当前锁被占用,则立即返回失败。如果大于0,则反复尝试获取锁直到达到该超时时间。 * @param integer $timeout 取锁超时时间。单位()。等于0,如果当前锁被占用,则立即返回失败。如果大于0,则反复尝试获取锁直到达到该超时时间。
* @param integer|float $sleep 取锁间隔时间 单位()。当锁为占用状态时。每隔多久尝试去取锁。默认 0.1 秒一次取锁。 * @param integer|float $sleep 取锁间隔时间 单位()。当锁为占用状态时。每隔多久尝试去取锁。默认 0.1 秒一次取锁。
*
* @return bool * @return bool
* @throws \Exception * @throws \Exception
*/ */
@ -67,6 +69,7 @@ class RedisLock
* *
* @param string $key 被加锁的KEY * @param string $key 被加锁的KEY
* @param string|int $requestId 客户端请求唯一ID * @param string|int $requestId 客户端请求唯一ID
*
* @return bool * @return bool
*/ */
public static function release(string $key, $requestId) public static function release(string $key, $requestId)
@ -90,6 +93,7 @@ LAU;
* 获取锁 Key * 获取锁 Key
* *
* @param string $key 需要加锁的KEY * @param string $key 需要加锁的KEY
*
* @return string * @return string
*/ */
public static function getLockKey(string $key) public static function getLockKey(string $key)

View File

@ -17,6 +17,7 @@ class Response
/** /**
* @param $data * @param $data
*
* @return PsrResponseInterface * @return PsrResponseInterface
*/ */
public function json($data) public function json($data)
@ -29,6 +30,7 @@ class Response
* *
* @param array $data 响应数据 * @param array $data 响应数据
* @param string $message 响应提示 * @param string $message 响应提示
*
* @return PsrResponseInterface * @return PsrResponseInterface
*/ */
public function success(array $data = [], $message = 'success') public function success(array $data = [], $message = 'success')
@ -54,6 +56,7 @@ class Response
/** /**
* @param string $message * @param string $message
* @param int $code * @param int $code
*
* @return PsrResponseInterface * @return PsrResponseInterface
*/ */
public function error($message = '', $code = ResponseCode::SERVER_ERROR) public function error($message = '', $code = ResponseCode::SERVER_ERROR)

View File

@ -15,6 +15,7 @@ class SendEmailCode
* *
* @param string $type * @param string $type
* @param string $mobile * @param string $mobile
*
* @return string * @return string
*/ */
private function getKey(string $type, string $mobile) private function getKey(string $type, string $mobile)
@ -28,6 +29,7 @@ class SendEmailCode
* @param string $type 发送类型 * @param string $type 发送类型
* @param string $email 手机号 * @param string $email 手机号
* @param string $code 验证码 * @param string $code 验证码
*
* @return bool * @return bool
*/ */
public function check(string $type, string $email, string $code) public function check(string $type, string $email, string $code)
@ -46,6 +48,7 @@ class SendEmailCode
* @param string $type 类型 * @param string $type 类型
* @param string $title 邮件标题 * @param string $title 邮件标题
* @param string $email 邮箱地址 * @param string $email 邮箱地址
*
* @return boolean * @return boolean
*/ */
public function send(string $type, string $title, string $email) public function send(string $type, string $title, string $email)
@ -67,6 +70,7 @@ class SendEmailCode
* 获取缓存的验证码 * 获取缓存的验证码
* *
* @param string $key * @param string $key
*
* @return mixed * @return mixed
*/ */
public function getCode(string $key) public function getCode(string $key)
@ -80,6 +84,7 @@ class SendEmailCode
* @param string $key 缓存key * @param string $key 缓存key
* @param string $sms_code 验证码 * @param string $sms_code 验证码
* @param float|int $exp 过期时间 * @param float|int $exp 过期时间
*
* @return mixed * @return mixed
*/ */
public function setCode(string $key, string $sms_code, $exp = 60 * 15) public function setCode(string $key, string $sms_code, $exp = 60 * 15)
@ -92,6 +97,7 @@ class SendEmailCode
* *
* @param string $type 类型 * @param string $type 类型
* @param string $email 邮箱地址 * @param string $email 邮箱地址
*
* @return mixed * @return mixed
*/ */
public function delCode(string $type, string $email) public function delCode(string $type, string $email)

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Support; namespace App\Support;
class SocketIOParser extends Packet class SocketIOParser extends Packet