优化代码
parent
73fc864806
commit
2d110bad77
|
@ -94,6 +94,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
|
||||
/**
|
||||
* ChatMessageConsumer constructor.
|
||||
*
|
||||
* @param SocketClientService $socketClientService
|
||||
* @param SocketRoomService $socketRoomService
|
||||
*/
|
||||
|
@ -123,6 +124,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
*
|
||||
* @param $data
|
||||
* @param AMQPMessage $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
|
@ -148,6 +150,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
*
|
||||
* @param array $data 队列消息
|
||||
* @param AMQPMessage $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function onConsumeTalk(array $data, AMQPMessage $message): string
|
||||
|
@ -263,6 +266,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
*
|
||||
* @param array $data 队列消息
|
||||
* @param AMQPMessage $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function onConsumeKeyboard(array $data, AMQPMessage $message): string
|
||||
|
@ -279,6 +283,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
*
|
||||
* @param array $data 队列消息
|
||||
* @param AMQPMessage $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function onConsumeOnlineStatus(array $data, AMQPMessage $message): string
|
||||
|
@ -300,6 +305,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
*
|
||||
* @param array $data 队列消息
|
||||
* @param AMQPMessage $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function onConsumeRevokeTalk(array $data, AMQPMessage $message): string
|
||||
|
@ -336,6 +342,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
*
|
||||
* @param array $data 队列消息
|
||||
* @param AMQPMessage $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function onConsumeFriendApply(array $data, AMQPMessage $message): string
|
||||
|
@ -365,6 +372,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
* 格式化对话的消息体
|
||||
*
|
||||
* @param array $data 对话的消息
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function formatTalkMessage(array $data): array
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* @author Yuandong<837215079@qq.com>
|
||||
* @link https://github.com/gzydong/hyperf-chat
|
||||
*/
|
||||
|
||||
namespace App\Bootstrap;
|
||||
|
||||
use Hyperf\Framework\Bootstrap\ServerStartCallback;
|
||||
|
@ -19,6 +20,7 @@ use Hyperf\Redis\Redis;
|
|||
* 自定义服务启动前回调事件
|
||||
*
|
||||
* Class ServerStart
|
||||
*
|
||||
* @package App\Bootstrap
|
||||
*/
|
||||
class ServerStart extends ServerStartCallback
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Cache;
|
|||
|
||||
/**
|
||||
* Class ApplyNumCache
|
||||
*
|
||||
* @package App\Cache
|
||||
*/
|
||||
class ApplyNumCache
|
||||
|
@ -15,6 +16,7 @@ class ApplyNumCache
|
|||
* 获取好友未读申请数
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get(int $user_id)
|
||||
|
@ -26,6 +28,7 @@ class ApplyNumCache
|
|||
* 设置未读好友申请数(自增加1)
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function setInc(int $user_id)
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Cache;
|
|||
|
||||
/**
|
||||
* Class FriendRemarkCache
|
||||
*
|
||||
* @package App\Cache
|
||||
*/
|
||||
class FriendRemarkCache
|
||||
|
@ -27,6 +28,7 @@ class FriendRemarkCache
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param int $friend_id 好友ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get(int $user_id, int $friend_id)
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Cache;
|
|||
|
||||
/**
|
||||
* Class LastMsgCache
|
||||
*
|
||||
* @package App\Cache
|
||||
*/
|
||||
class LastMsgCache
|
||||
|
@ -12,6 +13,7 @@ class LastMsgCache
|
|||
* 用户聊天或群聊的最后一条消息hash存储的hash名
|
||||
*
|
||||
* @param int $sender
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function _name($sender = 0)
|
||||
|
@ -24,6 +26,7 @@ class LastMsgCache
|
|||
*
|
||||
* @param int $receive 接收者
|
||||
* @param int $sender 发送者
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function _key(int $receive, int $sender)
|
||||
|
@ -48,6 +51,7 @@ class LastMsgCache
|
|||
*
|
||||
* @param int $receive 接收者
|
||||
* @param int $sender 发送者(注:若聊天消息类型为群聊消息 $sender 应设置为0)
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get(int $receive, $sender = 0)
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Cache;
|
|||
|
||||
/**
|
||||
* Class UnreadTalkCache
|
||||
*
|
||||
* @package App\Cache
|
||||
*/
|
||||
class UnreadTalkCache
|
||||
|
@ -15,6 +16,7 @@ class UnreadTalkCache
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param string $friend_id 好友ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setInc(int $user_id, string $friend_id)
|
||||
|
@ -29,6 +31,7 @@ class UnreadTalkCache
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param string $friend_id 好友ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get(int $user_id, string $friend_id)
|
||||
|
@ -40,6 +43,7 @@ class UnreadTalkCache
|
|||
* 获取用户未读消息列表
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAll(int $user_id)
|
||||
|
@ -52,6 +56,7 @@ class UnreadTalkCache
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param string $friend_id 好友ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function del(int $user_id, string $friend_id)
|
||||
|
@ -63,6 +68,7 @@ class UnreadTalkCache
|
|||
* 清除用户所有好友未读数
|
||||
*
|
||||
* @param int $user_id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delAll(int $user_id)
|
||||
|
@ -74,6 +80,7 @@ class UnreadTalkCache
|
|||
* 获取缓存key
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _key(int $user_id)
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
* @author Yuandong<837215079@qq.com>
|
||||
* @link https://github.com/gzydong/hyperf-chat
|
||||
*/
|
||||
|
||||
namespace App\Constants;
|
||||
|
||||
/**
|
||||
* HTTP 响应状态码枚举
|
||||
*
|
||||
* Class ResponseCode
|
||||
*
|
||||
* @package App\Constants
|
||||
*/
|
||||
class ResponseCode
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace App\Constants;
|
|||
* WebSocket 消息事件枚举
|
||||
*
|
||||
* Class SocketConstants
|
||||
*
|
||||
* @package App\Constants
|
||||
*/
|
||||
class SocketConstants
|
||||
|
|
|
@ -20,6 +20,7 @@ use App\Support\Response;
|
|||
* 基类控制器
|
||||
*
|
||||
* Class CController
|
||||
*
|
||||
* @package App\Controller\Api\V1
|
||||
*/
|
||||
class CController extends AbstractController
|
||||
|
|
|
@ -83,6 +83,7 @@ class ContactsController extends CController
|
|||
* @RequestMapping(path="add", methods="post")
|
||||
*
|
||||
* @param UserService $userService
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function addContact(UserService $userService)
|
||||
|
|
|
@ -41,6 +41,7 @@ class DownloadController extends CController
|
|||
*
|
||||
* @param ResponseInterface $response
|
||||
* @param UploadService $uploadService
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function userChatFile(ResponseInterface $response, UploadService $uploadService)
|
||||
|
@ -85,6 +86,7 @@ class DownloadController extends CController
|
|||
*
|
||||
* @param ResponseInterface $response
|
||||
* @param UploadService $uploadService
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function articleAnnex(ResponseInterface $response, UploadService $uploadService)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* @author Yuandong<837215079@qq.com>
|
||||
* @link https://github.com/gzydong/hyperf-chat
|
||||
*/
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
@ -144,6 +145,7 @@ class EmoticonController extends CController
|
|||
* @RequestMapping(path="upload-emoticon", methods="post")
|
||||
*
|
||||
* @param UploadService $uploadService
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function uploadEmoticon(UploadService $uploadService)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* @author Yuandong<837215079@qq.com>
|
||||
* @link https://github.com/gzydong/hyperf-chat
|
||||
*/
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
@ -484,6 +485,7 @@ class TalkController extends CController
|
|||
* @RequestMapping(path="send-image", methods="post")
|
||||
*
|
||||
* @param UploadService $uploadService
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function sendImage(UploadService $uploadService)
|
||||
|
@ -608,6 +610,7 @@ class TalkController extends CController
|
|||
* @RequestMapping(path="send-file", methods="post")
|
||||
*
|
||||
* @param UploadService $uploadService
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function sendFile(UploadService $uploadService)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* @author Yuandong<837215079@qq.com>
|
||||
* @link https://github.com/gzydong/hyperf-chat
|
||||
*/
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
@ -174,6 +175,7 @@ class UsersController extends CController
|
|||
* @RequestMapping(path="change-mobile", methods="post")
|
||||
*
|
||||
* @param SmsCodeService $smsCodeService
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function editUserMobile(SmsCodeService $smsCodeService)
|
||||
|
@ -246,6 +248,7 @@ class UsersController extends CController
|
|||
* @RequestMapping(path="send-mobile-code", methods="post")
|
||||
*
|
||||
* @param SmsCodeService $smsCodeService
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function sendMobileCode(SmsCodeService $smsCodeService)
|
||||
|
@ -283,6 +286,7 @@ class UsersController extends CController
|
|||
* @RequestMapping(path="send-change-email-code", methods="post")
|
||||
*
|
||||
* @param SendEmailCode $sendEmailCode
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function sendChangeEmailCode(SendEmailCode $sendEmailCode)
|
||||
|
|
|
@ -33,6 +33,7 @@ use App\Support\SocketIOParser;
|
|||
|
||||
/**
|
||||
* Class WebSocketController
|
||||
*
|
||||
* @package App\Controller
|
||||
*/
|
||||
class WebSocketController implements OnMessageInterface, OnOpenInterface, OnCloseInterface
|
||||
|
|
|
@ -38,6 +38,7 @@ class AppExceptionHandler extends ExceptionHandler
|
|||
|
||||
/**
|
||||
* @param Throwable $throwable
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(Throwable $throwable): bool
|
||||
|
|
|
@ -11,6 +11,7 @@ use Hyperf\WebSocketServer\Exception\WebSocketHandeShakeException;
|
|||
|
||||
/**
|
||||
* Class JwtAuthExceptionHandler
|
||||
*
|
||||
* @package App\Exception\Handler
|
||||
*/
|
||||
class JwtAuthExceptionHandler extends ExceptionHandler
|
||||
|
@ -38,6 +39,7 @@ class JwtAuthExceptionHandler extends ExceptionHandler
|
|||
* 判断该异常处理器是否要对该异常进行处理
|
||||
*
|
||||
* @param Throwable $throwable
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(Throwable $throwable): bool
|
||||
|
|
|
@ -12,6 +12,7 @@ use Throwable;
|
|||
* 验证器异常处理类
|
||||
*
|
||||
* Class ValidateExceptionHandler
|
||||
*
|
||||
* @package App\Exception\Handler
|
||||
*/
|
||||
class ValidateExceptionHandler extends ExceptionHandler
|
||||
|
@ -19,6 +20,7 @@ class ValidateExceptionHandler extends ExceptionHandler
|
|||
/**
|
||||
* @param Throwable $throwable
|
||||
* @param ResponseInterface $response
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function handle(Throwable $throwable, ResponseInterface $response)
|
||||
|
@ -45,6 +47,7 @@ class ValidateExceptionHandler extends ExceptionHandler
|
|||
* 判断该异常处理器是否要对该异常进行处理
|
||||
*
|
||||
* @param Throwable $throwable
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(Throwable $throwable): bool
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* @author Yuandong<837215079@qq.com>
|
||||
* @link https://github.com/gzydong/hyperf-chat
|
||||
*/
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
use Hyperf\Server\Exception\ServerException;
|
||||
|
@ -17,6 +18,7 @@ use Hyperf\Server\Exception\ServerException;
|
|||
* 验证器异常类
|
||||
*
|
||||
* Class ValidateException
|
||||
*
|
||||
* @package App\Exception
|
||||
*/
|
||||
class ValidateException extends ServerException
|
||||
|
|
|
@ -23,6 +23,7 @@ class Hash
|
|||
* Hash the given value.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function make(string $value)
|
||||
|
@ -35,6 +36,7 @@ class Hash
|
|||
*
|
||||
* @param string $value
|
||||
* @param string $hashedValue
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function check(string $value, string $hashedValue)
|
||||
|
|
|
@ -44,6 +44,7 @@ class HashIdsHelper
|
|||
* 加密
|
||||
*
|
||||
* @param mixed ...$numbers
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function encode(...$numbers)
|
||||
|
@ -55,6 +56,7 @@ class HashIdsHelper
|
|||
* 解密
|
||||
*
|
||||
* @param string $hash
|
||||
*
|
||||
* @return array|mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace App\Helper;
|
|||
* 字符串助手类
|
||||
*
|
||||
* Class StringHelper
|
||||
*
|
||||
* @package App\Helper
|
||||
*/
|
||||
class StringHelper
|
||||
|
@ -25,6 +26,7 @@ class StringHelper
|
|||
* 将字符串转换成二进制
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function str2Bin(string $str): string
|
||||
|
@ -45,6 +47,7 @@ class StringHelper
|
|||
* 将二进制转换成字符串
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function bin2Str(string $str): string
|
||||
|
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace App\Listener;
|
||||
|
||||
use Hyperf\Database\Events\QueryExecuted;
|
||||
|
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace App\Listener;
|
||||
|
||||
use Hyperf\AsyncQueue\Event\AfterHandle;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* @author Yuandong<837215079@qq.com>
|
||||
* @link https://github.com/gzydong/hyperf-chat
|
||||
*/
|
||||
|
||||
namespace App\Middleware;
|
||||
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
|
|
|
@ -80,6 +80,7 @@ class Group extends BaseModel
|
|||
* @param int $user_id 用户ID
|
||||
* @param int $group_id 群ID
|
||||
* @param int|array $leader 管理员类型[0:普通成员;1:管理员;2:群主;]
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isDismiss(int $group_id)
|
||||
|
@ -103,6 +105,7 @@ class Group extends BaseModel
|
|||
*
|
||||
* @param int $group_id 群ID
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isMember(int $group_id, int $user_id)
|
||||
|
|
|
@ -64,6 +64,7 @@ class GroupMember extends BaseModel
|
|||
* 获取聊天群成员ID
|
||||
*
|
||||
* @param int $group_id 群聊ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getGroupMemberIds(int $group_id)
|
||||
|
@ -76,6 +77,7 @@ class GroupMember extends BaseModel
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param int $group_id 群ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function visitCard(int $user_id, int $group_id)
|
||||
|
@ -87,6 +89,7 @@ class GroupMember extends BaseModel
|
|||
* 获取用户的所有群ID
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getUserGroupIds(int $user_id)
|
||||
|
|
|
@ -70,6 +70,7 @@ class UsersChatList extends BaseModel
|
|||
* @param int $user_id 用户ID
|
||||
* @param int $receive_id 接收者ID
|
||||
* @param int $type 创建类型 1:私聊 2:群聊
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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 $list_id 对话列表ID
|
||||
* @param bool $is_top 是否置顶(true:是 false:否)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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 $id 聊天列表ID、好友ID或群聊ID
|
||||
* @param int $type ID类型 (1:聊天列表ID 2:好友ID 3:群聊ID)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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 $type 接收者类型(1:好友 2:群组)
|
||||
* @param int $not_disturb 是否免打扰
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function notDisturbItem(int $user_id, int $receive_id, int $type, int $not_disturb)
|
||||
|
|
|
@ -45,6 +45,7 @@ class UsersEmoticon extends BaseModel
|
|||
/**
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEmoticonIdsAttribute($value)
|
||||
|
|
|
@ -64,6 +64,7 @@ class UsersFriend extends BaseModel
|
|||
* 获取用户所有好友
|
||||
*
|
||||
* @param int $uid 用户ID
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getUserFriends(int $uid)
|
||||
|
@ -94,6 +95,7 @@ SQL;
|
|||
* @param int $user_id1 用户1
|
||||
* @param int $user_id2 用户2
|
||||
* @param bool $cache 是否读取缓存
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isFriend(int $user_id1, int $user_id2, bool $cache = false)
|
||||
|
@ -120,6 +122,7 @@ SQL;
|
|||
* 获取指定用户的所有朋友的用户ID
|
||||
*
|
||||
* @param int $user_id 指定用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFriendIds(int $user_id)
|
||||
|
|
|
@ -24,6 +24,7 @@ class ArticleService extends BaseService
|
|||
* 获取用户文章分类列表
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUserClass(int $user_id)
|
||||
|
@ -42,6 +43,7 @@ class ArticleService extends BaseService
|
|||
* 获取用户文章标签列表
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUserTags(int $user_id)
|
||||
|
@ -61,6 +63,7 @@ class ArticleService extends BaseService
|
|||
* @param int $page 分页
|
||||
* @param int $page_size 分页大小
|
||||
* @param array $params 查询参数
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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 $user_id 用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArticleDetail(int $article_id, $user_id = 0)
|
||||
|
@ -154,6 +158,7 @@ class ArticleService extends BaseService
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param int $article_id 笔记ID
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findArticleAnnexAll(int $user_id, int $article_id)
|
||||
|
@ -171,6 +176,7 @@ class ArticleService extends BaseService
|
|||
* @param int $uid 用户ID
|
||||
* @param int|string $class_id 分类ID
|
||||
* @param string $class_name 分类名
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function editArticleClass(int $uid, $class_id, string $class_name)
|
||||
|
@ -216,6 +222,7 @@ class ArticleService extends BaseService
|
|||
*
|
||||
* @param int $uid 用户ID
|
||||
* @param int $class_id 分类ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delArticleClass(int $uid, int $class_id)
|
||||
|
@ -238,6 +245,7 @@ class ArticleService extends BaseService
|
|||
* @param int $user_id 用户ID
|
||||
* @param int $class_id 文集分类ID
|
||||
* @param int $sort_type 排序方式
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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 $class_id 笔记分类ID
|
||||
* @param int $to_class_id 笔记分类ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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 $tag_id 标签ID
|
||||
* @param string $tag_name 标签名
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
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 $tag_id 标签ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delArticleTags(int $uid, int $tag_id)
|
||||
|
@ -375,6 +386,7 @@ class ArticleService extends BaseService
|
|||
* @param int $user_id 用户ID
|
||||
* @param int $article_id 文章ID
|
||||
* @param array $data 文章数据
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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 $article_id 笔记ID
|
||||
* @param int $status 笔记状态 1:正常 2:已删除
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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 $article_id 笔记ID
|
||||
* @param int $class_id 笔记分类ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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 $article_id 笔记ID
|
||||
* @param int $type 1:标记星号 2:取消星号标记
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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 $article_id 笔记ID
|
||||
* @param array $tags 关联标签ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function updateArticleTag(int $uid, int $article_id, array $tags)
|
||||
|
@ -498,6 +514,7 @@ class ArticleService extends BaseService
|
|||
*
|
||||
* @param int $uid 用户ID
|
||||
* @param int $article_id 笔记ID
|
||||
*
|
||||
* @return bool|int|mixed|null
|
||||
* @throws Exception
|
||||
*/
|
||||
|
@ -547,6 +564,7 @@ class ArticleService extends BaseService
|
|||
* @param int $user_id 用户ID
|
||||
* @param int $annex_id 附件ID
|
||||
* @param int $status 附件状态 1:正常 2:已删除
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function updateArticleAnnexStatus(int $user_id, int $annex_id, int $status)
|
||||
|
@ -563,6 +581,7 @@ class ArticleService extends BaseService
|
|||
* 回收站附件列表
|
||||
*
|
||||
* @param int $uid 用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function recoverAnnexList(int $uid)
|
||||
|
@ -584,12 +603,14 @@ class ArticleService extends BaseService
|
|||
*
|
||||
* @param int $uid 用户ID
|
||||
* @param int $annex_id 笔记附件ID
|
||||
*
|
||||
* @return bool|int|mixed|null
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param int $uid
|
||||
* @param int $annex_id
|
||||
*
|
||||
* @return bool|int|mixed|null
|
||||
* @throws Exception
|
||||
*/
|
||||
|
@ -614,6 +635,7 @@ class ArticleService extends BaseService
|
|||
* @param int $user_id 用户id
|
||||
* @param int $article_id 笔记ID
|
||||
* @param array $annex 笔记附件信息
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function insertArticleAnnex(int $user_id, int $article_id, array $annex)
|
||||
|
|
|
@ -33,6 +33,7 @@ class ContactsService extends BaseService
|
|||
* 获取联系人列表
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getContacts(int $user_id): array
|
||||
|
@ -63,6 +64,7 @@ SQL;
|
|||
* @param int $user_id 用户ID
|
||||
* @param int $friend_id 好友ID
|
||||
* @param string $remarks 申请备注
|
||||
*
|
||||
* @return 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 $friend_id 好友ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteContact(int $user_id, int $friend_id): bool
|
||||
|
@ -123,6 +126,7 @@ SQL;
|
|||
* @param int $user_id 用户ID
|
||||
* @param int $apply_id 联系人申请ID
|
||||
* @param string $remarks 联系人备注名称
|
||||
*
|
||||
* @return 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 $apply_id 联系人申请ID
|
||||
* @param string $remarks 拒绝申请备注信息
|
||||
*
|
||||
* @return 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 $friend_id 朋友ID
|
||||
* @param string $remarks 好友备注名称
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function editContactRemark(int $user_id, int $friend_id, string $remarks): bool
|
||||
|
@ -227,6 +233,7 @@ SQL;
|
|||
* 搜索联系人
|
||||
*
|
||||
* @param string $mobile 用户手机号/登录账号
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function findContact(string $mobile): array
|
||||
|
@ -242,6 +249,7 @@ SQL;
|
|||
* @param int $user_id 用户ID
|
||||
* @param int $page 当前分页
|
||||
* @param int $page_size 分页大小
|
||||
*
|
||||
* @return 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 $apply_id 联系人好友申请ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delContactApplyRecord(int $user_id, int $apply_id): bool
|
||||
|
|
|
@ -12,6 +12,7 @@ use App\Model\UsersEmoticon;
|
|||
* 表情服务层
|
||||
*
|
||||
* Class EmoticonService
|
||||
*
|
||||
* @package App\Services
|
||||
*/
|
||||
class EmoticonService extends BaseService
|
||||
|
@ -21,6 +22,7 @@ class EmoticonService extends BaseService
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param int $emoticon_id 表情包ID
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function installSysEmoticon(int $user_id, int $emoticon_id)
|
||||
|
@ -46,6 +48,7 @@ class EmoticonService extends BaseService
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param int $emoticon_id 表情包ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function removeSysEmoticon(int $user_id, int $emoticon_id)
|
||||
|
@ -75,6 +78,7 @@ class EmoticonService extends BaseService
|
|||
* 获取用户安装的表情ID
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getInstallIds(int $user_id)
|
||||
|
@ -88,6 +92,7 @@ class EmoticonService extends BaseService
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param int $record_id 聊天消息ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function collect(int $user_id, int $record_id)
|
||||
|
@ -143,6 +148,7 @@ class EmoticonService extends BaseService
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param array $ids 表情包详情ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public function deleteCollect(int $user_id, array $ids)
|
||||
|
@ -154,6 +160,7 @@ class EmoticonService extends BaseService
|
|||
* 获取表情包列表
|
||||
*
|
||||
* @param array $where
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDetailsAll(array $where = [])
|
||||
|
|
|
@ -23,6 +23,7 @@ class GroupService extends BaseService
|
|||
* 获取用户所在的群聊
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroups(int $user_id): array
|
||||
|
@ -59,6 +60,7 @@ class GroupService extends BaseService
|
|||
* @param int $user_id 用户ID
|
||||
* @param array $group_info 群聊名称
|
||||
* @param array $friend_ids 好友的用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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 $user_id 用户ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function dismiss(int $group_id, int $user_id)
|
||||
|
@ -174,6 +177,7 @@ class GroupService extends BaseService
|
|||
* @param int $user_id 用户ID
|
||||
* @param int $group_id 聊天群ID
|
||||
* @param array $friend_ids 被邀请的用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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 $group_id 群组ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function quit(int $user_id, int $group_id)
|
||||
|
@ -332,6 +337,7 @@ class GroupService extends BaseService
|
|||
* @param int $group_id 群ID
|
||||
* @param int $user_id 操作用户ID
|
||||
* @param array $member_ids 群成员ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function removeMember(int $group_id, int $user_id, array $member_ids)
|
||||
|
|
|
@ -7,6 +7,7 @@ use PHPMailer\PHPMailer\Exception;
|
|||
|
||||
/**
|
||||
* Class MailerService
|
||||
*
|
||||
* @package App\Service
|
||||
*/
|
||||
class MailerService
|
||||
|
@ -24,6 +25,7 @@ class MailerService
|
|||
* @param string $email 邮箱
|
||||
* @param string $subject 标题
|
||||
* @param string $template 对应邮件模板
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function send($email, $subject, $template)
|
||||
|
@ -41,6 +43,7 @@ class MailerService
|
|||
* @param string $email 邮箱
|
||||
* @param string $subject 标题
|
||||
* @param string $template 对应邮件模板
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function realSend($email, $subject, $template)
|
||||
|
@ -58,6 +61,7 @@ class MailerService
|
|||
* @param string $address 收件人
|
||||
* @param string $subject 邮件标题
|
||||
* @param string $view 邮件内容
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
|
|
|
@ -40,6 +40,7 @@ class MessageHandleService
|
|||
* @param Response|Server $server
|
||||
* @param Frame $frame
|
||||
* @param array|string $data 解析后数据
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function onTalk($server, Frame $frame, $data)
|
||||
|
@ -108,6 +109,7 @@ class MessageHandleService
|
|||
* @param Response|Server $server
|
||||
* @param Frame $frame
|
||||
* @param array|string $data 解析后数据
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function onKeyboard($server, Frame $frame, $data)
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Service;
|
|||
* 短信发送服务
|
||||
*
|
||||
* Class SmsCodeService
|
||||
*
|
||||
* @package App\Services
|
||||
*/
|
||||
class SmsCodeService
|
||||
|
@ -34,6 +35,7 @@ class SmsCodeService
|
|||
*
|
||||
* @param string $type 短信用途
|
||||
* @param string $mobile 手机号
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getKey(string $type, string $mobile)
|
||||
|
@ -47,6 +49,7 @@ class SmsCodeService
|
|||
* @param string $type 发送类型
|
||||
* @param string $mobile 手机号
|
||||
* @param string $code 验证码
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function check(string $type, string $mobile, string $code)
|
||||
|
@ -61,6 +64,7 @@ class SmsCodeService
|
|||
*
|
||||
* @param string $usage 验证码用途
|
||||
* @param string $mobile 手机号
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function send(string $usage, string $mobile)
|
||||
|
@ -99,6 +103,7 @@ class SmsCodeService
|
|||
* 获取缓存的验证码
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCode(string $key)
|
||||
|
@ -112,6 +117,7 @@ class SmsCodeService
|
|||
* @param string $key 缓存key
|
||||
* @param string $sms_code 验证码
|
||||
* @param float|int $exp 过期时间(默认15分钟)
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setCode(string $key, string $sms_code, $exp = 60 * 15)
|
||||
|
@ -124,6 +130,7 @@ class SmsCodeService
|
|||
*
|
||||
* @param string $usage 验证码用途
|
||||
* @param string $mobile 手机号
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function delCode(string $usage, string $mobile)
|
||||
|
@ -136,6 +143,7 @@ class SmsCodeService
|
|||
*
|
||||
* @param string $usage 验证码用途
|
||||
* @param string $mobile 手机号
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function filter(string $usage, string $mobile)
|
||||
|
@ -158,6 +166,7 @@ class SmsCodeService
|
|||
* 判断验证码用途渠道是否注册
|
||||
*
|
||||
* @param string $usage
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isUsages(string $usage)
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Service;
|
|||
/**
|
||||
* 短信服务
|
||||
* Class SmsService
|
||||
*
|
||||
* @package App\Service
|
||||
*/
|
||||
class SmsService
|
||||
|
|
|
@ -42,6 +42,7 @@ class SocketClientService
|
|||
* @param int $fd 客户端fd
|
||||
* @param int $user_id 用户ID
|
||||
* @param string $run_id 服务运行ID(默认当前服务ID)
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
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 string $run_id 服务运行ID(默认当前服务ID)
|
||||
*
|
||||
* @return 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 array $run_ids 服务运行ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOnlineAll(int $user_id, array $run_ids = [])
|
||||
|
@ -101,6 +104,7 @@ class SocketClientService
|
|||
*
|
||||
* @param int $fd 客户端ID
|
||||
* @param string $run_id 服务运行ID(默认当前服务ID)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function findFdUserId(int $fd, $run_id = SERVER_RUN_ID)
|
||||
|
@ -113,6 +117,7 @@ class SocketClientService
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param string $run_id 服务运行ID(默认当前服务ID)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function findUserFds(int $user_id, $run_id = SERVER_RUN_ID)
|
||||
|
@ -127,6 +132,7 @@ class SocketClientService
|
|||
* 获取服务ID列表
|
||||
*
|
||||
* @param int $type 获取类型[1:正在运行;2:已超时;3:所有]
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getServerRunIdAll(int $type = 1)
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Service;
|
|||
* 聊天室房间服务
|
||||
*
|
||||
* Class SocketRoomService
|
||||
*
|
||||
* @package App\Service
|
||||
*/
|
||||
class SocketRoomService
|
||||
|
@ -16,6 +17,7 @@ class SocketRoomService
|
|||
* 获取房间名
|
||||
*
|
||||
* @param string|integer $room 房间名
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRoomName($room)
|
||||
|
@ -27,6 +29,7 @@ class SocketRoomService
|
|||
* 获取房间成员
|
||||
*
|
||||
* @param string $room 房间名
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRoomMembers(string $room)
|
||||
|
@ -39,6 +42,7 @@ class SocketRoomService
|
|||
*
|
||||
* @param int $usr_id 用户ID
|
||||
* @param string|array $room 房间名
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function addRoomMember(int $usr_id, $room)
|
||||
|
@ -51,6 +55,7 @@ class SocketRoomService
|
|||
*
|
||||
* @param string|array $room 房间名
|
||||
* @param string|array $members 用户ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function delRoomMember($room, $members)
|
||||
|
@ -62,6 +67,7 @@ class SocketRoomService
|
|||
* 删除房间
|
||||
*
|
||||
* @param string|int $room 房间名
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function delRoom($room)
|
||||
|
|
|
@ -10,6 +10,7 @@ use Hyperf\HttpMessage\Upload\UploadedFile;
|
|||
* 文件拆分上传服务
|
||||
*
|
||||
* Class SplitUploadService
|
||||
*
|
||||
* @package App\Service
|
||||
*/
|
||||
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();
|
||||
if (!$info) {
|
||||
return FileSplitUpload::create([
|
||||
return (bool)FileSplitUpload::create([
|
||||
'user_id' => $user_id,
|
||||
'file_type' => 2,
|
||||
'hash_name' => $hashName,
|
||||
|
@ -94,7 +95,7 @@ class SplitUploadService
|
|||
'file_ext' => $fileInfo->file_ext,
|
||||
'file_size' => $fileSize,
|
||||
'upload_at' => time(),
|
||||
]) ? true : false;
|
||||
]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -26,6 +26,7 @@ class TalkService extends BaseService
|
|||
* 获取用户的聊天列表
|
||||
*
|
||||
* @param int $user_id 用户ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function talks(int $user_id)
|
||||
|
@ -126,6 +127,7 @@ class TalkService extends BaseService
|
|||
* 处理聊天记录信息
|
||||
*
|
||||
* @param array $rows 聊天记录
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function handleChatRecords(array $rows)
|
||||
|
@ -232,6 +234,7 @@ class TalkService extends BaseService
|
|||
* @param int $record_id 上一次查询的聊天记录ID
|
||||
* @param int $limit 查询数据长度
|
||||
* @param array $msg_type 消息类型
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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 $record_id 聊天记录ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getForwardRecords(int $user_id, int $record_id)
|
||||
|
@ -336,6 +340,7 @@ class TalkService extends BaseService
|
|||
* @param int $source 消息来源 1:好友消息 2:群聊消息
|
||||
* @param int $receive_id 好友ID或者群聊ID
|
||||
* @param array $record_ids 聊天记录ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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 $record_id 聊天记录ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function revokeRecord(int $user_id, int $record_id)
|
||||
|
@ -408,6 +414,7 @@ class TalkService extends BaseService
|
|||
* @param int $user_id 转发的用户ID
|
||||
* @param int $record_id 转发消息的记录ID
|
||||
* @param array $receive_ids 接受者数组 例如:[['source' => 1,'id' => 3045],['source' => 1,'id' => 3046],['source' => 1,'id' => 1658]] 二维数组
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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_size 分页大小
|
||||
* @param array $params 查询参数
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
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 $fileInfo
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function createImgMessage($message, $fileInfo)
|
||||
|
@ -710,6 +719,7 @@ class TalkService extends BaseService
|
|||
*
|
||||
* @param array $message
|
||||
* @param array $codeBlock
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function createCodeMessage(array $message, array $codeBlock)
|
||||
|
@ -742,6 +752,7 @@ class TalkService extends BaseService
|
|||
*
|
||||
* @param array $message
|
||||
* @param array $emoticon
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function createEmoticonMessage(array $message, array $emoticon)
|
||||
|
@ -774,6 +785,7 @@ class TalkService extends BaseService
|
|||
*
|
||||
* @param array $message
|
||||
* @param array $emoticon
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function createFileMessage(array $message, array $emoticon)
|
||||
|
|
|
@ -8,6 +8,7 @@ use Hyperf\HttpMessage\Upload\UploadedFile;
|
|||
* 文件上传服务
|
||||
*
|
||||
* Class UploadService
|
||||
*
|
||||
* @package App\Service
|
||||
*/
|
||||
class UploadService extends BaseService
|
||||
|
|
|
@ -16,6 +16,7 @@ class UserService extends BaseService
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param array $field 查询字段
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findById(int $user_id, $field = ['*'])
|
||||
|
@ -28,6 +29,7 @@ class UserService extends BaseService
|
|||
*
|
||||
* @param string $mobile 手机号
|
||||
* @param string $password 登录密码
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function login(string $mobile, string $password)
|
||||
|
@ -47,6 +49,7 @@ class UserService extends BaseService
|
|||
* 账号注册逻辑
|
||||
*
|
||||
* @param array $data 用户数据
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register(array $data)
|
||||
|
@ -81,6 +84,7 @@ class UserService extends BaseService
|
|||
*
|
||||
* @param string $mobile 用户手机好
|
||||
* @param string $password 新密码
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function resetPassword(string $mobile, string $password)
|
||||
|
@ -93,6 +97,7 @@ class UserService extends BaseService
|
|||
*
|
||||
* @param int $user_id 用户ID
|
||||
* @param string $mobile 换绑手机号
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function changeMobile(int $user_id, string $mobile)
|
||||
|
@ -110,6 +115,7 @@ class UserService extends BaseService
|
|||
*
|
||||
* @param int $friend_id 用户ID
|
||||
* @param int $me_user_id 当前登录用户的ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUserCard(int $friend_id, int $me_user_id)
|
||||
|
|
|
@ -7,6 +7,7 @@ use PHPMailer\PHPMailer\Exception;
|
|||
|
||||
/**
|
||||
* Class Mail
|
||||
*
|
||||
* @package App\Support
|
||||
*/
|
||||
class Mail
|
||||
|
@ -17,6 +18,7 @@ class Mail
|
|||
* @param string $email 邮箱地址
|
||||
* @param string $sms_code 验证码
|
||||
* @param string $title 邮件标题
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function sendEmailCode(string $email, string $sms_code, string $title)
|
||||
|
@ -38,6 +40,7 @@ class Mail
|
|||
* @param string $address
|
||||
* @param string $subject
|
||||
* @param string $view
|
||||
*
|
||||
* @return bool
|
||||
* @throws \PHPMailer\PHPMailer\Exception
|
||||
*/
|
||||
|
@ -65,6 +68,7 @@ class Mail
|
|||
* @param string $engine
|
||||
* @param $template
|
||||
* @param array $params
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function view(string $engine, $template, $params = []): string
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Support;
|
|||
/**
|
||||
* 邮件视图模板
|
||||
* Class MailerViewTemplate
|
||||
*
|
||||
* @package App\Support
|
||||
*/
|
||||
class MailerTemplate
|
||||
|
@ -15,6 +16,7 @@ class MailerTemplate
|
|||
* @param string $engine 模板引擎
|
||||
* @param string $template 模板名称
|
||||
* @param array $params 模板参数
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function view(string $engine, string $template, $params = []): string
|
||||
|
@ -27,6 +29,7 @@ class MailerTemplate
|
|||
*
|
||||
* @param string $sms_code 验证码
|
||||
* @param array $params 模板参数
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function emailCode(string $sms_code, array $params = [])
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Support;
|
|||
|
||||
/**
|
||||
* Class RedisLock
|
||||
*
|
||||
* @package App\Support
|
||||
*/
|
||||
class RedisLock
|
||||
|
@ -34,6 +35,7 @@ class RedisLock
|
|||
* @param integer $lockSecond 锁定时间 单位(秒)
|
||||
* @param integer $timeout 取锁超时时间。单位(秒)。等于0,如果当前锁被占用,则立即返回失败。如果大于0,则反复尝试获取锁直到达到该超时时间。
|
||||
* @param integer|float $sleep 取锁间隔时间 单位(秒)。当锁为占用状态时。每隔多久尝试去取锁。默认 0.1 秒一次取锁。
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
@ -67,6 +69,7 @@ class RedisLock
|
|||
*
|
||||
* @param string $key 被加锁的KEY
|
||||
* @param string|int $requestId 客户端请求唯一ID
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function release(string $key, $requestId)
|
||||
|
@ -90,6 +93,7 @@ LAU;
|
|||
* 获取锁 Key
|
||||
*
|
||||
* @param string $key 需要加锁的KEY
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getLockKey(string $key)
|
||||
|
|
|
@ -17,6 +17,7 @@ class Response
|
|||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return PsrResponseInterface
|
||||
*/
|
||||
public function json($data)
|
||||
|
@ -29,6 +30,7 @@ class Response
|
|||
*
|
||||
* @param array $data 响应数据
|
||||
* @param string $message 响应提示
|
||||
*
|
||||
* @return PsrResponseInterface
|
||||
*/
|
||||
public function success(array $data = [], $message = 'success')
|
||||
|
@ -54,6 +56,7 @@ class Response
|
|||
/**
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
*
|
||||
* @return PsrResponseInterface
|
||||
*/
|
||||
public function error($message = '', $code = ResponseCode::SERVER_ERROR)
|
||||
|
|
|
@ -15,6 +15,7 @@ class SendEmailCode
|
|||
*
|
||||
* @param string $type
|
||||
* @param string $mobile
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getKey(string $type, string $mobile)
|
||||
|
@ -28,6 +29,7 @@ class SendEmailCode
|
|||
* @param string $type 发送类型
|
||||
* @param string $email 手机号
|
||||
* @param string $code 验证码
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function check(string $type, string $email, string $code)
|
||||
|
@ -46,6 +48,7 @@ class SendEmailCode
|
|||
* @param string $type 类型
|
||||
* @param string $title 邮件标题
|
||||
* @param string $email 邮箱地址
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function send(string $type, string $title, string $email)
|
||||
|
@ -67,6 +70,7 @@ class SendEmailCode
|
|||
* 获取缓存的验证码
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCode(string $key)
|
||||
|
@ -80,6 +84,7 @@ class SendEmailCode
|
|||
* @param string $key 缓存key
|
||||
* @param string $sms_code 验证码
|
||||
* @param float|int $exp 过期时间
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setCode(string $key, string $sms_code, $exp = 60 * 15)
|
||||
|
@ -92,6 +97,7 @@ class SendEmailCode
|
|||
*
|
||||
* @param string $type 类型
|
||||
* @param string $email 邮箱地址
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function delCode(string $type, string $email)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
class SocketIOParser extends Packet
|
||||
|
|
Loading…
Reference in New Issue