优化代码

main
gzydong 2021-04-22 16:14:34 +08:00
parent 146a9c4993
commit 52410df8a6
79 changed files with 310 additions and 881 deletions

View File

@ -1,9 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -32,11 +30,11 @@ use App\Service\SocketClientService;
use App\Service\SocketRoomService; use App\Service\SocketRoomService;
use App\Constants\SocketConstants; use App\Constants\SocketConstants;
/** ///**
* 消息推送消费者队列 // * 消息推送消费者队列
* // * @Consumer(name="ConsumerChat",enable=true)
* @Consumer(name="ConsumerChat",enable=true) // */
*/
class ChatMessageConsumer extends ConsumerMessage class ChatMessageConsumer extends ConsumerMessage
{ {
/** /**
@ -109,7 +107,6 @@ class ChatMessageConsumer extends ConsumerMessage
/** /**
* 重写创建队列生成类 * 重写创建队列生成类
*
* 注释:设置自动删除队列 * 注释:设置自动删除队列
* *
* @return QueueBuilder * @return QueueBuilder
@ -124,7 +121,6 @@ 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
@ -150,7 +146,6 @@ 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
@ -266,7 +261,6 @@ 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
@ -283,7 +277,6 @@ 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
@ -305,7 +298,6 @@ 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
@ -342,7 +334,6 @@ 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
@ -372,7 +363,6 @@ 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

@ -1,9 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -49,7 +47,7 @@ class ChatMessageProducer extends ProducerMessage
public function __construct(string $event, array $data, array $options = []) public function __construct(string $event, array $data, array $options = [])
{ {
$message = [ $message = [
'uuid' => $this->uuid(),// 自定义消息ID 'uuid' => $this->uuid(),
'event' => $event, 'event' => $event,
'data' => $data, 'data' => $data,
'options' => $options 'options' => $options

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -19,8 +17,6 @@ use Hyperf\Redis\Redis;
/** /**
* 自定义服务启动前回调事件 * 自定义服务启动前回调事件
* *
* Class ServerStart
*
* @package App\Bootstrap * @package App\Bootstrap
*/ */
class ServerStart extends ServerStartCallback class ServerStart extends ServerStartCallback

View File

@ -9,14 +9,12 @@ namespace App\Cache;
*/ */
class ApplyNumCache class ApplyNumCache
{ {
const KEY = 'friend:apply:unread:num'; const KEY = 'friend:apply:unread:num';
/** /**
* 获取好友未读申请数 * 获取好友未读申请数
* *
* @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)
@ -28,7 +26,6 @@ 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

@ -28,7 +28,6 @@ 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

@ -13,7 +13,6 @@ 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)
@ -26,7 +25,6 @@ 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)
@ -51,7 +49,6 @@ 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

@ -16,7 +16,6 @@ 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)
@ -31,7 +30,6 @@ 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)
@ -43,7 +41,6 @@ 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)
@ -56,7 +53,6 @@ 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)
@ -68,7 +64,6 @@ 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)
@ -80,7 +75,6 @@ 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

@ -1,9 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *

View File

@ -1,22 +1,10 @@
<?php <?php
/**
*
* This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code
*
* @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat
*/
namespace App\Constants; namespace App\Constants;
/** /**
* HTTP 响应状态码枚举 * HTTP 响应状态码枚举
* *
* Class ResponseCode
*
* @package App\Constants * @package App\Constants
*/ */
class ResponseCode class ResponseCode

View File

@ -1,22 +1,10 @@
<?php <?php
/**
*
* This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code
*
* @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat
*/
namespace App\Constants; namespace App\Constants;
/** /**
* WebSocket 消息事件枚举 * WebSocket 消息事件枚举
* *
* Class SocketConstants
*
* @package App\Constants * @package App\Constants
*/ */
class SocketConstants class SocketConstants

View File

@ -1,9 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -21,10 +19,10 @@ use App\Service\ArticleService;
use App\Service\UploadService; use App\Service\UploadService;
use App\Support\RedisLock; use App\Support\RedisLock;
use Hyperf\Utils\Str; use Hyperf\Utils\Str;
use Psr\Http\Message\ResponseInterface;
/** /**
* Class ArticleController * Class ArticleController
*
* @Controller(path="/api/v1/article") * @Controller(path="/api/v1/article")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
* *
@ -46,8 +44,9 @@ class ArticleController extends CController
/** /**
* 获取笔记分类列表 * 获取笔记分类列表
*
* @RequestMapping(path="article-class", methods="get") * @RequestMapping(path="article-class", methods="get")
*
* @return ResponseInterface
*/ */
public function getArticleClass() public function getArticleClass()
{ {
@ -58,8 +57,9 @@ class ArticleController extends CController
/** /**
* 获取笔记标签列表 * 获取笔记标签列表
*
* @RequestMapping(path="article-tags", methods="get") * @RequestMapping(path="article-tags", methods="get")
*
* @return ResponseInterface
*/ */
public function getArticleTags() public function getArticleTags()
{ {
@ -70,8 +70,9 @@ class ArticleController extends CController
/** /**
* 获取笔记列表 * 获取笔记列表
*
* @RequestMapping(path="article-list", methods="get") * @RequestMapping(path="article-list", methods="get")
*
* @return ResponseInterface
*/ */
public function getArticleList() public function getArticleList()
{ {
@ -103,8 +104,9 @@ class ArticleController extends CController
/** /**
* 获取笔记详情 * 获取笔记详情
*
* @RequestMapping(path="article-detail", methods="get") * @RequestMapping(path="article-detail", methods="get")
*
* @return ResponseInterface
*/ */
public function getArticleDetail() public function getArticleDetail()
{ {
@ -120,8 +122,9 @@ class ArticleController extends CController
/** /**
* 添加或编辑笔记分类 * 添加或编辑笔记分类
*
* @RequestMapping(path="edit-article-class", methods="post") * @RequestMapping(path="edit-article-class", methods="post")
*
* @return ResponseInterface
*/ */
public function editArticleClass() public function editArticleClass()
{ {
@ -141,8 +144,9 @@ class ArticleController extends CController
/** /**
* 删除笔记分类 * 删除笔记分类
*
* @RequestMapping(path="del-article-class", methods="post") * @RequestMapping(path="del-article-class", methods="post")
*
* @return ResponseInterface
*/ */
public function delArticleClass() public function delArticleClass()
{ {
@ -160,8 +164,9 @@ class ArticleController extends CController
/** /**
* 笔记分类列表排序接口 * 笔记分类列表排序接口
*
* @RequestMapping(path="article-class-sort", methods="post") * @RequestMapping(path="article-class-sort", methods="post")
*
* @return ResponseInterface
*/ */
public function articleClassSort() public function articleClassSort()
{ {
@ -190,8 +195,9 @@ class ArticleController extends CController
/** /**
* 笔记分类合并接口 * 笔记分类合并接口
*
* @RequestMapping(path="merge-article-class", methods="post") * @RequestMapping(path="merge-article-class", methods="post")
*
* @return ResponseInterface
*/ */
public function mergeArticleClass() public function mergeArticleClass()
{ {
@ -210,8 +216,9 @@ class ArticleController extends CController
/** /**
* 添加或编辑笔记标签 * 添加或编辑笔记标签
*
* @RequestMapping(path="edit-article-tag", methods="post") * @RequestMapping(path="edit-article-tag", methods="post")
*
* @return ResponseInterface
*/ */
public function editArticleTags() public function editArticleTags()
{ {
@ -230,8 +237,9 @@ class ArticleController extends CController
/** /**
* 删除笔记标签 * 删除笔记标签
*
* @RequestMapping(path="del-article-tag", methods="post") * @RequestMapping(path="del-article-tag", methods="post")
*
* @return ResponseInterface
*/ */
public function delArticleTags() public function delArticleTags()
{ {
@ -249,8 +257,9 @@ class ArticleController extends CController
/** /**
* 添加或编辑笔记 * 添加或编辑笔记
*
* @RequestMapping(path="edit-article", methods="post") * @RequestMapping(path="edit-article", methods="post")
*
* @return ResponseInterface
*/ */
public function editArticle() public function editArticle()
{ {
@ -279,8 +288,9 @@ class ArticleController extends CController
/** /**
* 删除笔记 * 删除笔记
*
* @RequestMapping(path="delete-article", methods="post") * @RequestMapping(path="delete-article", methods="post")
*
* @return ResponseInterface
*/ */
public function deleteArticle() public function deleteArticle()
{ {
@ -298,8 +308,9 @@ class ArticleController extends CController
/** /**
* 恢复删除笔记 * 恢复删除笔记
*
* @RequestMapping(path="recover-article", methods="post") * @RequestMapping(path="recover-article", methods="post")
*
* @return ResponseInterface
*/ */
public function recoverArticle() public function recoverArticle()
{ {
@ -317,8 +328,9 @@ class ArticleController extends CController
/** /**
* 笔记图片上传接口 * 笔记图片上传接口
*
* @RequestMapping(path="upload-article-image", methods="post") * @RequestMapping(path="upload-article-image", methods="post")
*
* @return ResponseInterface
*/ */
public function uploadArticleImage() public function uploadArticleImage()
{ {
@ -347,8 +359,9 @@ class ArticleController extends CController
/** /**
* 移动笔记至指定分类 * 移动笔记至指定分类
*
* @RequestMapping(path="move-article", methods="post") * @RequestMapping(path="move-article", methods="post")
*
* @return ResponseInterface
*/ */
public function moveArticle() public function moveArticle()
{ {
@ -371,8 +384,9 @@ class ArticleController extends CController
/** /**
* 笔记标记星号接口 * 笔记标记星号接口
*
* @RequestMapping(path="set-asterisk-article", methods="post") * @RequestMapping(path="set-asterisk-article", methods="post")
*
* @return ResponseInterface
*/ */
public function setAsteriskArticle() public function setAsteriskArticle()
{ {
@ -395,8 +409,9 @@ class ArticleController extends CController
/** /**
* 更新笔记关联标签ID * 更新笔记关联标签ID
*
* @RequestMapping(path="update-article-tag", methods="post") * @RequestMapping(path="update-article-tag", methods="post")
*
* @return ResponseInterface
*/ */
public function updateArticleTag() public function updateArticleTag()
{ {
@ -415,8 +430,9 @@ class ArticleController extends CController
/** /**
* 永久删除笔记文章 * 永久删除笔记文章
*
* @RequestMapping(path="forever-delete-article", methods="post") * @RequestMapping(path="forever-delete-article", methods="post")
*
* @return ResponseInterface
*/ */
public function foreverDelArticle() public function foreverDelArticle()
{ {
@ -434,8 +450,9 @@ class ArticleController extends CController
/** /**
* 上传笔记附件 * 上传笔记附件
*
* @RequestMapping(path="upload-article-annex", methods="post") * @RequestMapping(path="upload-article-annex", methods="post")
*
* @return ResponseInterface
*/ */
public function uploadArticleAnnex() public function uploadArticleAnnex()
{ {
@ -476,8 +493,9 @@ class ArticleController extends CController
/** /**
* 删除笔记附件 * 删除笔记附件
*
* @RequestMapping(path="delete-article-annex", methods="post") * @RequestMapping(path="delete-article-annex", methods="post")
*
* @return ResponseInterface
*/ */
public function deleteArticleAnnex() public function deleteArticleAnnex()
{ {
@ -495,8 +513,9 @@ class ArticleController extends CController
/** /**
* 恢复笔记附件 * 恢复笔记附件
*
* @RequestMapping(path="recover-article-annex", methods="post") * @RequestMapping(path="recover-article-annex", methods="post")
*
* @return ResponseInterface
*/ */
public function recoverArticleAnnex() public function recoverArticleAnnex()
{ {
@ -514,8 +533,9 @@ class ArticleController extends CController
/** /**
* 获取附件回收站列表 * 获取附件回收站列表
*
* @RequestMapping(path="recover-annex-list", methods="get") * @RequestMapping(path="recover-annex-list", methods="get")
*
* @return ResponseInterface
*/ */
public function recoverAnnexList() public function recoverAnnexList()
{ {
@ -538,8 +558,10 @@ class ArticleController extends CController
/** /**
* 永久删除笔记附件(从已删除附件中永久删除) * 永久删除笔记附件(从已删除附件中永久删除)
*
* @RequestMapping(path="forever-delete-annex", methods="post") * @RequestMapping(path="forever-delete-annex", methods="post")
*
* @return ResponseInterface
* @throws \Exception
*/ */
public function foreverDelAnnex() public function foreverDelAnnex()
{ {

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -25,7 +23,6 @@ use Phper666\JWTAuth\JWT;
/** /**
* 授权相关控制器 * 授权相关控制器
*
* @Controller(path="/api/v1/auth") * @Controller(path="/api/v1/auth")
*/ */
class AuthController extends CController class AuthController extends CController
@ -50,7 +47,6 @@ class AuthController extends CController
/** /**
* 授权登录接口 * 授权登录接口
*
* @RequestMapping(path="login", methods="post") * @RequestMapping(path="login", methods="post")
*/ */
public function login() public function login()
@ -93,7 +89,6 @@ class AuthController extends CController
/** /**
* 退出登录接口 * 退出登录接口
*
* @RequestMapping(path="logout", methods="post") * @RequestMapping(path="logout", methods="post")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
*/ */
@ -106,7 +101,6 @@ class AuthController extends CController
/** /**
* 账号注册接口 * 账号注册接口
*
* @RequestMapping(path="register", methods="post") * @RequestMapping(path="register", methods="post")
*/ */
public function register() public function register()
@ -142,7 +136,6 @@ class AuthController extends CController
/** /**
* 账号找回接口 * 账号找回接口
*
* @RequestMapping(path="forget", methods="post") * @RequestMapping(path="forget", methods="post")
*/ */
public function forget() public function forget()
@ -171,7 +164,6 @@ class AuthController extends CController
/** /**
* 授权刷新接口 * 授权刷新接口
*
* @RequestMapping(path="refresh", methods="post") * @RequestMapping(path="refresh", methods="post")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
*/ */
@ -187,7 +179,6 @@ class AuthController extends CController
/** /**
* 发送验证码 * 发送验证码
*
* @RequestMapping(path="send-verify-code", methods="post") * @RequestMapping(path="send-verify-code", methods="post")
*/ */
public function sendVerifyCode() public function sendVerifyCode()

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -19,8 +17,6 @@ use App\Support\Response;
/** /**
* 基类控制器 * 基类控制器
* *
* Class CController
*
* @package App\Controller\Api\V1 * @package App\Controller\Api\V1
*/ */
class CController extends AbstractController class CController extends AbstractController

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -13,7 +11,6 @@
namespace App\Controller\Api\V1; namespace App\Controller\Api\V1;
use App\Model\UsersFriendsApply; use App\Model\UsersFriendsApply;
use Co\Context;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping; use Hyperf\HttpServer\Annotation\RequestMapping;
@ -32,7 +29,6 @@ use App\Constants\SocketConstants;
/** /**
* Class ContactsController * Class ContactsController
*
* @Controller(path="/api/v1/contacts") * @Controller(path="/api/v1/contacts")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
* *
@ -60,8 +56,9 @@ class ContactsController extends CController
/** /**
* 获取用户联系人列表 * 获取用户联系人列表
*
* @RequestMapping(path="list", methods="get") * @RequestMapping(path="list", methods="get")
*
* @return ResponseInterface
*/ */
public function getContacts() public function getContacts()
{ {
@ -79,11 +76,9 @@ 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)
@ -126,8 +121,9 @@ class ContactsController extends CController
/** /**
* 删除联系人 * 删除联系人
*
* @RequestMapping(path="delete", methods="post") * @RequestMapping(path="delete", methods="post")
*
* @return ResponseInterface
*/ */
public function deleteContact() public function deleteContact()
{ {
@ -152,8 +148,9 @@ class ContactsController extends CController
/** /**
* 同意添加联系人 * 同意添加联系人
*
* @RequestMapping(path="accept-invitation", methods="post") * @RequestMapping(path="accept-invitation", methods="post")
*
* @return ResponseInterface
*/ */
public function acceptInvitation() public function acceptInvitation()
{ {
@ -192,8 +189,9 @@ class ContactsController extends CController
/** /**
* 拒绝添加联系人(预留) * 拒绝添加联系人(预留)
*
* @RequestMapping(path="decline-invitation", methods="post") * @RequestMapping(path="decline-invitation", methods="post")
*
* @return ResponseInterface
*/ */
public function declineInvitation() public function declineInvitation()
{ {
@ -212,8 +210,9 @@ class ContactsController extends CController
/** /**
* 删除联系人申请记录 * 删除联系人申请记录
*
* @RequestMapping(path="delete-apply", methods="post") * @RequestMapping(path="delete-apply", methods="post")
*
* @return ResponseInterface
*/ */
public function deleteContactApply() public function deleteContactApply()
{ {
@ -231,8 +230,9 @@ class ContactsController extends CController
/** /**
* 获取联系人申请未读数 * 获取联系人申请未读数
*
* @RequestMapping(path="apply-unread-num", methods="get") * @RequestMapping(path="apply-unread-num", methods="get")
*
* @return ResponseInterface
*/ */
public function getContactApplyUnreadNum() public function getContactApplyUnreadNum()
{ {
@ -244,8 +244,9 @@ class ContactsController extends CController
/** /**
* 获取联系人申请未读数 * 获取联系人申请未读数
*
* @RequestMapping(path="apply-records", methods="get") * @RequestMapping(path="apply-records", methods="get")
*
* @return ResponseInterface
*/ */
public function getContactApplyRecords() public function getContactApplyRecords()
{ {
@ -268,8 +269,9 @@ class ContactsController extends CController
/** /**
* 搜索联系人 * 搜索联系人
*
* @RequestMapping(path="search", methods="get") * @RequestMapping(path="search", methods="get")
*
* @return ResponseInterface
*/ */
public function searchContacts() public function searchContacts()
{ {
@ -284,8 +286,9 @@ class ContactsController extends CController
/** /**
* 编辑联系人备注 * 编辑联系人备注
*
* @RequestMapping(path="edit-remark", methods="post") * @RequestMapping(path="edit-remark", methods="post")
*
* @return ResponseInterface
*/ */
public function editContactRemark() public function editContactRemark()
{ {

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -26,7 +24,6 @@ use Hyperf\HttpServer\Contract\ResponseInterface;
/** /**
* Class DownloadController * Class DownloadController
*
* @Controller(path="/api/v1/download") * @Controller(path="/api/v1/download")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
* *
@ -36,12 +33,10 @@ class DownloadController extends CController
{ {
/** /**
* 下载用户聊天文件 * 下载用户聊天文件
*
* @RequestMapping(path="user-chat-file", methods="get") * @RequestMapping(path="user-chat-file", methods="get")
* *
* @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)
@ -81,12 +76,10 @@ class DownloadController extends CController
/** /**
* 下载笔记附件 * 下载笔记附件
*
* @RequestMapping(path="article-annex", methods="get") * @RequestMapping(path="article-annex", methods="get")
* *
* @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

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -26,7 +24,6 @@ use Psr\Http\Message\ResponseInterface;
/** /**
* Class EmoticonController * Class EmoticonController
*
* @Controller(path="/api/v1/emoticon") * @Controller(path="/api/v1/emoticon")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
* *
@ -42,8 +39,9 @@ class EmoticonController extends CController
/** /**
* 获取用户表情包列表 * 获取用户表情包列表
*
* @RequestMapping(path="user-emoticon", methods="get") * @RequestMapping(path="user-emoticon", methods="get")
*
* @return ResponseInterface
*/ */
public function getUserEmoticon() public function getUserEmoticon()
{ {
@ -76,8 +74,9 @@ class EmoticonController extends CController
/** /**
* 获取系统表情包 * 获取系统表情包
*
* @RequestMapping(path="system-emoticon", methods="get") * @RequestMapping(path="system-emoticon", methods="get")
*
* @return ResponseInterface
*/ */
public function getSystemEmoticon() public function getSystemEmoticon()
{ {
@ -95,8 +94,9 @@ class EmoticonController extends CController
/** /**
* 安装或移除系统表情包 * 安装或移除系统表情包
*
* @RequestMapping(path="set-user-emoticon", methods="post") * @RequestMapping(path="set-user-emoticon", methods="post")
*
* @return ResponseInterface
*/ */
public function setUserEmoticon() public function setUserEmoticon()
{ {
@ -141,11 +141,9 @@ 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)
@ -197,8 +195,9 @@ class EmoticonController extends CController
/** /**
* 收藏聊天图片的我的表情包 * 收藏聊天图片的我的表情包
*
* @RequestMapping(path="collect-emoticon", methods="post") * @RequestMapping(path="collect-emoticon", methods="post")
*
* @return ResponseInterface
*/ */
public function collectEmoticon() public function collectEmoticon()
{ {
@ -220,8 +219,9 @@ class EmoticonController extends CController
/** /**
* 移除收藏的表情包 * 移除收藏的表情包
*
* @RequestMapping(path="del-collect-emoticon", methods="post") * @RequestMapping(path="del-collect-emoticon", methods="post")
*
* @return ResponseInterface
*/ */
public function delCollectEmoticon() public function delCollectEmoticon()
{ {

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -27,10 +25,10 @@ use App\Amqp\Producer\ChatMessageProducer;
use App\Service\SocketRoomService; use App\Service\SocketRoomService;
use App\Service\GroupService; use App\Service\GroupService;
use App\Constants\SocketConstants; use App\Constants\SocketConstants;
use Psr\Http\Message\ResponseInterface;
/** /**
* Class GroupController * Class GroupController
*
* @Controller(path="/api/v1/group") * @Controller(path="/api/v1/group")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
* *
@ -58,10 +56,9 @@ class GroupController extends CController
/** /**
* 创建群组 * 创建群组
*
* @RequestMapping(path="create", methods="post") * @RequestMapping(path="create", methods="post")
* *
* @return mixed * @return ResponseInterface
*/ */
public function create() public function create()
{ {
@ -107,8 +104,9 @@ class GroupController extends CController
/** /**
* 解散群组接口 * 解散群组接口
*
* @RequestMapping(path="dismiss", methods="post") * @RequestMapping(path="dismiss", methods="post")
*
* @return ResponseInterface
*/ */
public function dismiss() public function dismiss()
{ {
@ -131,8 +129,9 @@ class GroupController extends CController
/** /**
* 邀请好友加入群组接口 * 邀请好友加入群组接口
*
* @RequestMapping(path="invite", methods="post") * @RequestMapping(path="invite", methods="post")
*
* @return ResponseInterface
*/ */
public function invite() public function invite()
{ {
@ -170,8 +169,9 @@ class GroupController extends CController
/** /**
* 退出群组接口 * 退出群组接口
*
* @RequestMapping(path="secede", methods="post") * @RequestMapping(path="secede", methods="post")
*
* @return ResponseInterface
*/ */
public function secede() public function secede()
{ {
@ -204,8 +204,9 @@ class GroupController extends CController
/** /**
* 编辑群组信息 * 编辑群组信息
*
* @RequestMapping(path="edit", methods="post") * @RequestMapping(path="edit", methods="post")
*
* @return ResponseInterface
*/ */
public function editDetail() public function editDetail()
{ {
@ -232,8 +233,9 @@ class GroupController extends CController
/** /**
* 移除指定成员(管理员权限) * 移除指定成员(管理员权限)
*
* @RequestMapping(path="remove-members", methods="post") * @RequestMapping(path="remove-members", methods="post")
*
* @return ResponseInterface
*/ */
public function removeMembers() public function removeMembers()
{ {
@ -275,8 +277,9 @@ class GroupController extends CController
/** /**
* 获取群信息接口 * 获取群信息接口
*
* @RequestMapping(path="detail", methods="get") * @RequestMapping(path="detail", methods="get")
*
* @return ResponseInterface
*/ */
public function detail() public function detail()
{ {
@ -319,8 +322,9 @@ class GroupController extends CController
/** /**
* 设置群名片 * 设置群名片
*
* @RequestMapping(path="set-group-card", methods="post") * @RequestMapping(path="set-group-card", methods="post")
*
* @return ResponseInterface
*/ */
public function editGroupCard() public function editGroupCard()
{ {
@ -341,8 +345,9 @@ class GroupController extends CController
/** /**
* 获取可邀请加入群组的好友列表 * 获取可邀请加入群组的好友列表
*
* @RequestMapping(path="invite-friends", methods="get") * @RequestMapping(path="invite-friends", methods="get")
*
* @return ResponseInterface
*/ */
public function getInviteFriends() public function getInviteFriends()
{ {
@ -363,8 +368,9 @@ class GroupController extends CController
/** /**
* 获取群组列表 * 获取群组列表
*
* @RequestMapping(path="list", methods="get") * @RequestMapping(path="list", methods="get")
*
* @return ResponseInterface
*/ */
public function getGroups() public function getGroups()
{ {
@ -375,8 +381,9 @@ class GroupController extends CController
/** /**
* 获取群组成员列表 * 获取群组成员列表
*
* @RequestMapping(path="members", methods="get") * @RequestMapping(path="members", methods="get")
*
* @return ResponseInterface
*/ */
public function getGroupMembers() public function getGroupMembers()
{ {
@ -409,8 +416,9 @@ class GroupController extends CController
/** /**
* 获取群组公告列表 * 获取群组公告列表
*
* @RequestMapping(path="notices", methods="get") * @RequestMapping(path="notices", methods="get")
*
* @return ResponseInterface
*/ */
public function getGroupNotice() public function getGroupNotice()
{ {
@ -448,8 +456,9 @@ class GroupController extends CController
/** /**
* 创建/编辑群公告 * 创建/编辑群公告
*
* @RequestMapping(path="edit-notice", methods="post") * @RequestMapping(path="edit-notice", methods="post")
*
* @return ResponseInterface
*/ */
public function editNotice() public function editNotice()
{ {
@ -506,8 +515,9 @@ class GroupController extends CController
/** /**
* 删除群公告(软删除) * 删除群公告(软删除)
*
* @RequestMapping(path="delete-notice", methods="post") * @RequestMapping(path="delete-notice", methods="post")
*
* @return ResponseInterface
*/ */
public function deleteNotice() public function deleteNotice()
{ {

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -35,7 +33,6 @@ use App\Constants\SocketConstants;
/** /**
* Class TalkController * Class TalkController
*
* @Controller(path="/api/v1/talk") * @Controller(path="/api/v1/talk")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
* *
@ -63,8 +60,9 @@ class TalkController extends CController
/** /**
* 获取用户对话列表 * 获取用户对话列表
*
* @RequestMapping(path="list", methods="get") * @RequestMapping(path="list", methods="get")
*
* @return ResponseInterface
*/ */
public function list() public function list()
{ {
@ -85,8 +83,9 @@ class TalkController extends CController
/** /**
* 新增对话列表 * 新增对话列表
*
* @RequestMapping(path="create", methods="post") * @RequestMapping(path="create", methods="post")
*
* @return ResponseInterface
*/ */
public function create() public function create()
{ {
@ -152,8 +151,9 @@ class TalkController extends CController
/** /**
* 删除对话列表 * 删除对话列表
*
* @RequestMapping(path="delete", methods="post") * @RequestMapping(path="delete", methods="post")
*
* @return ResponseInterface
*/ */
public function delete() public function delete()
{ {
@ -169,8 +169,9 @@ class TalkController extends CController
/** /**
* 对话列表置顶 * 对话列表置顶
*
* @RequestMapping(path="topping", methods="post") * @RequestMapping(path="topping", methods="post")
*
* @return ResponseInterface
*/ */
public function topping() public function topping()
{ {
@ -187,8 +188,9 @@ class TalkController extends CController
/** /**
* 设置消息免打扰状态 * 设置消息免打扰状态
*
* @RequestMapping(path="set-not-disturb", methods="post") * @RequestMapping(path="set-not-disturb", methods="post")
*
* @return ResponseInterface
*/ */
public function setNotDisturb() public function setNotDisturb()
{ {
@ -208,8 +210,9 @@ class TalkController extends CController
/** /**
* 更新对话列表未读数 * 更新对话列表未读数
*
* @RequestMapping(path="update-unread-num", methods="post") * @RequestMapping(path="update-unread-num", methods="post")
*
* @return ResponseInterface
*/ */
public function updateUnreadNum() public function updateUnreadNum()
{ {
@ -229,8 +232,9 @@ class TalkController extends CController
/** /**
* 撤回聊天对话消息 * 撤回聊天对话消息
*
* @RequestMapping(path="revoke-records", methods="post") * @RequestMapping(path="revoke-records", methods="post")
*
* @return ResponseInterface
*/ */
public function revokeChatRecords() public function revokeChatRecords()
{ {
@ -255,8 +259,9 @@ class TalkController extends CController
/** /**
* 删除聊天记录 * 删除聊天记录
*
* @RequestMapping(path="remove-records", methods="post") * @RequestMapping(path="remove-records", methods="post")
*
* @return ResponseInterface
*/ */
public function removeChatRecords() public function removeChatRecords()
{ {
@ -283,8 +288,9 @@ class TalkController extends CController
/** /**
* 转发聊天记录(待优化) * 转发聊天记录(待优化)
*
* @RequestMapping(path="forward-records", methods="post") * @RequestMapping(path="forward-records", methods="post")
*
* @return ResponseInterface
*/ */
public function forwardChatRecords() public function forwardChatRecords()
{ {
@ -353,8 +359,9 @@ class TalkController extends CController
/** /**
* 获取对话面板中的聊天记录 * 获取对话面板中的聊天记录
*
* @RequestMapping(path="records", methods="get") * @RequestMapping(path="records", methods="get")
*
* @return ResponseInterface
*/ */
public function getChatRecords() public function getChatRecords()
{ {
@ -394,8 +401,9 @@ class TalkController extends CController
/** /**
* 获取转发记录详情 * 获取转发记录详情
*
* @RequestMapping(path="get-forward-records", methods="get") * @RequestMapping(path="get-forward-records", methods="get")
*
* @return ResponseInterface
*/ */
public function getForwardRecords() public function getForwardRecords()
{ {
@ -414,8 +422,9 @@ class TalkController extends CController
/** /**
* 查询聊天记录 * 查询聊天记录
*
* @RequestMapping(path="find-chat-records", methods="get") * @RequestMapping(path="find-chat-records", methods="get")
*
* @return ResponseInterface
*/ */
public function findChatRecords() public function findChatRecords()
{ {
@ -463,8 +472,9 @@ class TalkController extends CController
/** /**
* 搜索聊天记录(待开发) * 搜索聊天记录(待开发)
*
* @RequestMapping(path="search-chat-records", methods="get") * @RequestMapping(path="search-chat-records", methods="get")
*
* @return ResponseInterface
*/ */
public function searchChatRecords() public function searchChatRecords()
{ {
@ -473,8 +483,9 @@ class TalkController extends CController
/** /**
* 获取聊天记录上下文数据(待开发) * 获取聊天记录上下文数据(待开发)
*
* @RequestMapping(path="get-records-context", methods="get") * @RequestMapping(path="get-records-context", methods="get")
*
* @return ResponseInterface
*/ */
public function getRecordsContext() public function getRecordsContext()
{ {
@ -483,11 +494,9 @@ 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)
@ -558,8 +567,9 @@ class TalkController extends CController
/** /**
* 发送代码块消息 * 发送代码块消息
*
* @RequestMapping(path="send-code-block", methods="post") * @RequestMapping(path="send-code-block", methods="post")
*
* @return ResponseInterface
*/ */
public function sendCodeBlock() public function sendCodeBlock()
{ {
@ -608,11 +618,9 @@ 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)
@ -679,8 +687,9 @@ class TalkController extends CController
/** /**
* 发送表情包消息 * 发送表情包消息
*
* @RequestMapping(path="send-emoticon", methods="post") * @RequestMapping(path="send-emoticon", methods="post")
*
* @return ResponseInterface
*/ */
public function sendEmoticon() public function sendEmoticon()
{ {

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -24,9 +22,7 @@ use Psr\Http\Message\ResponseInterface;
/** /**
* 上传控制器 * 上传控制器
*
* Class UploadController * Class UploadController
*
* @Controller(path="/api/v1/upload") * @Controller(path="/api/v1/upload")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
* *
@ -36,22 +32,21 @@ class UploadController extends CController
{ {
/** /**
* @inject * @inject
*
* @var UploadService * @var UploadService
*/ */
private $uploadService; private $uploadService;
/** /**
* @inject * @inject
*
* @var SplitUploadService * @var SplitUploadService
*/ */
private $splitUploadService; private $splitUploadService;
/** /**
* 图片文件流上传接口 * 图片文件流上传接口
*
* @RequestMapping(path="file-stream", methods="post") * @RequestMapping(path="file-stream", methods="post")
*
* @return ResponseInterface
*/ */
public function fileStream() public function fileStream()
{ {
@ -66,8 +61,9 @@ class UploadController extends CController
/** /**
* 获取拆分文件信息 * 获取拆分文件信息
*
* @RequestMapping(path="get-file-split-info", methods="get") * @RequestMapping(path="get-file-split-info", methods="get")
*
* @return ResponseInterface
*/ */
public function getFileSplitInfo() public function getFileSplitInfo()
{ {
@ -84,8 +80,9 @@ class UploadController extends CController
/** /**
* 文件拆分上传接口 * 文件拆分上传接口
*
* @RequestMapping(path="file-subarea-upload", methods="post") * @RequestMapping(path="file-subarea-upload", methods="post")
*
* @return ResponseInterface
*/ */
public function fileSubareaUpload() public function fileSubareaUpload()
{ {

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -22,12 +20,10 @@ use App\Support\SendEmailCode;
use App\Helper\Hash; use App\Helper\Hash;
use App\Service\UserService; use App\Service\UserService;
use App\Service\SmsCodeService; use App\Service\SmsCodeService;
use App\Constants\ResponseCode;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
/** /**
* Class UsersController * Class UsersController
*
* @Controller(path="/api/v1/users") * @Controller(path="/api/v1/users")
* @Middleware(JWTAuthMiddleware::class) * @Middleware(JWTAuthMiddleware::class)
* *
@ -43,8 +39,9 @@ class UsersController extends CController
/** /**
* 获取我的信息 * 获取我的信息
*
* @RequestMapping(path="detail", methods="get") * @RequestMapping(path="detail", methods="get")
*
* @return ResponseInterface
*/ */
public function getUserDetail() public function getUserDetail()
{ {
@ -61,8 +58,9 @@ class UsersController extends CController
/** /**
* 用户相关设置 * 用户相关设置
*
* @RequestMapping(path="setting", methods="get") * @RequestMapping(path="setting", methods="get")
*
* @return ResponseInterface
*/ */
public function getUserSetting() public function getUserSetting()
{ {
@ -87,8 +85,9 @@ class UsersController extends CController
/** /**
* 编辑我的信息 * 编辑我的信息
*
* @RequestMapping(path="edit-user-detail", methods="post") * @RequestMapping(path="edit-user-detail", methods="post")
*
* @return ResponseInterface
*/ */
public function editUserDetail() public function editUserDetail()
{ {
@ -109,8 +108,9 @@ class UsersController extends CController
/** /**
* 修改用户头像 * 修改用户头像
*
* @RequestMapping(path="edit-avatar", methods="post") * @RequestMapping(path="edit-avatar", methods="post")
*
* @return ResponseInterface
*/ */
public function editAvatar() public function editAvatar()
{ {
@ -128,8 +128,9 @@ class UsersController extends CController
/** /**
* 通过手机号查找用户 * 通过手机号查找用户
*
* @RequestMapping(path="search-user", methods="post") * @RequestMapping(path="search-user", methods="post")
*
* @return ResponseInterface
*/ */
public function searchUserInfo() public function searchUserInfo()
{ {
@ -145,8 +146,9 @@ class UsersController extends CController
/** /**
* 修改我的密码 * 修改我的密码
*
* @RequestMapping(path="change-password", methods="post") * @RequestMapping(path="change-password", methods="post")
*
* @return ResponseInterface
*/ */
public function editUserPassword() public function editUserPassword()
{ {
@ -171,11 +173,9 @@ 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)
@ -209,8 +209,9 @@ class UsersController extends CController
/** /**
* 修改用户邮箱接口 * 修改用户邮箱接口
*
* @RequestMapping(path="change-email", methods="post") * @RequestMapping(path="change-email", methods="post")
*
* @return ResponseInterface
*/ */
public function editUserEmail() public function editUserEmail()
{ {
@ -244,11 +245,9 @@ 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)
@ -282,11 +281,9 @@ 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

@ -1,9 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -13,12 +11,18 @@ declare(strict_types=1);
namespace App\Controller; namespace App\Controller;
use App\Model\UsersEmoticon;
use Hyperf\HttpServer\Contract\ResponseInterface; use Hyperf\HttpServer\Contract\ResponseInterface;
class IndexController extends AbstractController class IndexController extends AbstractController
{ {
public function index(ResponseInterface $response) public function index(ResponseInterface $response)
{ {
$res = (bool)UsersEmoticon::where('user_id', 9999999)->delete();
var_dump($res);
$user = $this->request->input('user', 'Hyperf'); $user = $this->request->input('user', 'Hyperf');
$method = $this->request->getMethod(); $method = $this->request->getMethod();

View File

@ -1,9 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *

View File

@ -38,7 +38,6 @@ 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

@ -39,7 +39,6 @@ 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

@ -10,7 +10,6 @@ use Throwable;
/** /**
* 验证器异常处理类 * 验证器异常处理类
*
* Class ValidateExceptionHandler * Class ValidateExceptionHandler
* *
* @package App\Exception\Handler * @package App\Exception\Handler
@ -20,7 +19,6 @@ 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)
@ -47,7 +45,6 @@ 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

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -17,8 +15,6 @@ use Hyperf\Server\Exception\ServerException;
/** /**
* 验证器异常类 * 验证器异常类
* *
* Class ValidateException
*
* @package App\Exception * @package App\Exception
*/ */
class ValidateException extends ServerException class ValidateException extends ServerException

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -23,7 +21,6 @@ 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)
@ -36,7 +33,6 @@ 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

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -44,7 +42,6 @@ class HashIdsHelper
* 加密 * 加密
* *
* @param mixed ...$numbers * @param mixed ...$numbers
*
* @return string * @return string
*/ */
public static function encode(...$numbers) public static function encode(...$numbers)
@ -56,7 +53,6 @@ class HashIdsHelper
* 解密 * 解密
* *
* @param string $hash * @param string $hash
*
* @return array|mixed * @return array|mixed
* @throws \Exception * @throws \Exception
*/ */

View File

@ -1,9 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -15,7 +13,6 @@ namespace App\Helper;
/** /**
* 字符串助手类 * 字符串助手类
*
* Class StringHelper * Class StringHelper
* *
* @package App\Helper * @package App\Helper
@ -26,7 +23,6 @@ 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
@ -47,7 +43,6 @@ 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

@ -1,9 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *

View File

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *

View File

@ -1,9 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *

View File

@ -9,35 +9,24 @@ use App\Model\BaseModel;
/** /**
* 笔记数据表模型 * 笔记数据表模型
* *
* @property integer $id 笔记ID * @property integer $id 笔记ID
* @property integer $user_id 用户ID * @property integer $user_id 用户ID
* @property integer $class_id 分类ID * @property integer $class_id 分类ID
* @property string $tags_id 笔记标签ID * @property string $tags_id 笔记标签ID
* @property string $title 笔记标题 * @property string $title 笔记标题
* @property string $abstract 笔记摘要 * @property string $abstract 笔记摘要
* @property string $image 笔记头图 * @property string $image 笔记头图
* @property integer $is_asterisk 是否标记星号 * @property integer $is_asterisk 是否标记星号
* @property integer $status 笔记状态 * @property integer $status 笔记状态
* @property string $created_at 创建时间 * @property string $created_at 创建时间
* @property string $updated_at 更新时间 * @property string $updated_at 更新时间
* @property string $deleted_at 删除时间 * @property string $deleted_at 删除时间
*
* @package App\Model\Article * @package App\Model\Article
*/ */
class Article extends BaseModel class Article extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'article'; protected $table = 'article';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'user_id', 'user_id',
'class_id', 'class_id',
@ -50,11 +39,6 @@ class Article extends BaseModel
'updated_at', 'updated_at',
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'user_id' => 'integer', 'user_id' => 'integer',

View File

@ -19,23 +19,12 @@ use App\Model\BaseModel;
* @property integer $status 文件状态 * @property integer $status 文件状态
* @property string $created_at 上传时间 * @property string $created_at 上传时间
* @property string $deleted_at 删除时间 * @property string $deleted_at 删除时间
*
* @package App\Model\Article * @package App\Model\Article
*/ */
class ArticleAnnex extends BaseModel class ArticleAnnex extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'article_annex'; protected $table = 'article_annex';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'user_id', 'user_id',
'article_id', 'article_id',
@ -48,11 +37,6 @@ class ArticleAnnex extends BaseModel
'deleted_at' 'deleted_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'user_id' => 'integer', 'user_id' => 'integer',

View File

@ -15,23 +15,12 @@ use App\Model\BaseModel;
* @property integer $sort 排序[值越小越靠前] * @property integer $sort 排序[值越小越靠前]
* @property integer $is_default 默认分类[1:;0:不是] * @property integer $is_default 默认分类[1:;0:不是]
* @property string $created_at 创建时间 * @property string $created_at 创建时间
*
* @package App\Model\Article * @package App\Model\Article
*/ */
class ArticleClass extends BaseModel class ArticleClass extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'article_class'; protected $table = 'article_class';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'user_id', 'user_id',
'class_name', 'class_name',
@ -40,11 +29,6 @@ class ArticleClass extends BaseModel
'created_at', 'created_at',
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'user_id' => 'integer', 'user_id' => 'integer',

View File

@ -13,34 +13,18 @@ use App\Model\BaseModel;
* @property integer $article_id 笔记ID * @property integer $article_id 笔记ID
* @property string $md_content 笔记MD格式内容 * @property string $md_content 笔记MD格式内容
* @property string $content 笔记html格式内容 * @property string $content 笔记html格式内容
*
* @package App\Model\Article * @package App\Model\Article
*/ */
class ArticleDetail extends BaseModel class ArticleDetail extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'article_detail'; protected $table = 'article_detail';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'article_id', 'article_id',
'md_content', 'md_content',
'content', 'content',
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'article_id' => 'integer' 'article_id' => 'integer'

View File

@ -7,6 +7,8 @@ namespace App\Model\Article;
use App\Model\BaseModel; use App\Model\BaseModel;
/** /**
* 笔记标签数据表模型
*
* @property integer $id 标签ID * @property integer $id 标签ID
* @property integer $user_id 用户ID * @property integer $user_id 用户ID
* @property string $tag_name 标签名称 * @property string $tag_name 标签名称
@ -15,27 +17,15 @@ use App\Model\BaseModel;
*/ */
class ArticleTag extends BaseModel class ArticleTag extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'article_tags'; protected $table = 'article_tags';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'user_id', 'tag_name', 'sort', 'created_at' 'user_id',
'tag_name',
'sort',
'created_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'user_id' => 'integer', 'user_id' => 'integer',

View File

@ -17,23 +17,12 @@ use App\Model\BaseModel;
* @property string $content 文本消息 * @property string $content 文本消息
* @property int $is_revoke 是否撤回消息[0:;1:] * @property int $is_revoke 是否撤回消息[0:;1:]
* @property string $created_at 创建时间 * @property string $created_at 创建时间
*
* @package App\Model\Chat * @package App\Model\Chat
*/ */
class ChatRecord extends BaseModel class ChatRecord extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'chat_records'; protected $table = 'chat_records';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'source', 'source',
'msg_type', 'msg_type',
@ -44,11 +33,6 @@ class ChatRecord extends BaseModel
'created_at', 'created_at',
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'source' => 'integer', 'source' => 'integer',

View File

@ -15,23 +15,12 @@ use App\Model\BaseModel;
* @property string $code_lang 代码语言 * @property string $code_lang 代码语言
* @property string $code 代码详情 * @property string $code 代码详情
* @property string $created_at 创建时间 * @property string $created_at 创建时间
*
* @package App\Model\Chat * @package App\Model\Chat
*/ */
class ChatRecordsCode extends BaseModel class ChatRecordsCode extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'chat_records_code'; protected $table = 'chat_records_code';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'record_id', 'record_id',
'user_id', 'user_id',
@ -40,11 +29,6 @@ class ChatRecordsCode extends BaseModel
'created_at' 'created_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'record_id' => 'integer', 'record_id' => 'integer',

View File

@ -13,30 +13,14 @@ use App\Model\BaseModel;
* @property int $record_id 聊天记录ID * @property int $record_id 聊天记录ID
* @property int $user_id 用户ID * @property int $user_id 用户ID
* @property string $created_at 删除时间 * @property string $created_at 删除时间
*
* @package App\Model\Chat * @package App\Model\Chat
*/ */
class ChatRecordsDelete extends BaseModel class ChatRecordsDelete extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'chat_records_delete'; protected $table = 'chat_records_delete';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = []; protected $fillable = [];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'record_id' => 'integer', 'record_id' => 'integer',

View File

@ -21,23 +21,12 @@ use App\Model\BaseModel;
* @property string $save_dir 文件保存路径 * @property string $save_dir 文件保存路径
* @property int $is_delete 是否已删除 * @property int $is_delete 是否已删除
* @property string $created_at 上传时间 * @property string $created_at 上传时间
*
* @package App\Model\Chat * @package App\Model\Chat
*/ */
class ChatRecordsFile extends BaseModel class ChatRecordsFile extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'chat_records_file'; protected $table = 'chat_records_file';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'record_id', 'record_id',
'user_id', 'user_id',
@ -52,11 +41,6 @@ class ChatRecordsFile extends BaseModel
'created_at' 'created_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'record_id' => 'integer', 'record_id' => 'integer',

View File

@ -15,32 +15,20 @@ use App\Model\BaseModel;
* @property string $records_id 聊天记录ID多个用英文','拼接 * @property string $records_id 聊天记录ID多个用英文','拼接
* @property string $text 缓存信息 * @property string $text 缓存信息
* @property int $created_at 转发时间 * @property int $created_at 转发时间
*
* @package App\Model\Chat * @package App\Model\Chat
*/ */
class ChatRecordsForward extends BaseModel class ChatRecordsForward extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'chat_records_forward'; protected $table = 'chat_records_forward';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'record_id', 'user_id', 'records_id', 'text', 'created_at' 'record_id',
'user_id',
'records_id',
'text',
'created_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'record_id' => 'integer', 'record_id' => 'integer',

View File

@ -14,23 +14,12 @@ use App\Model\BaseModel;
* @property int $type 通知类型[1:入群通知;2:自动退群;3:管理员踢群] * @property int $type 通知类型[1:入群通知;2:自动退群;3:管理员踢群]
* @property int $operate_user_id 操作人的用户ID[邀请人OR管理员ID] * @property int $operate_user_id 操作人的用户ID[邀请人OR管理员ID]
* @property string $user_ids 用户ID(多个用 , 分割) * @property string $user_ids 用户ID(多个用 , 分割)
*
* @package App\Model\Chat * @package App\Model\Chat
*/ */
class ChatRecordsInvite extends BaseModel class ChatRecordsInvite extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'chat_records_invite'; protected $table = 'chat_records_invite';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'record_id', 'record_id',
'type', 'type',
@ -38,11 +27,6 @@ class ChatRecordsInvite extends BaseModel
'user_ids', 'user_ids',
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'record_id' => 'integer', 'record_id' => 'integer',

View File

@ -11,30 +11,14 @@ namespace App\Model;
* @property string $name 分组名称 * @property string $name 分组名称
* @property string $url 默认表情 * @property string $url 默认表情
* @property string $created_at 创建时间 * @property string $created_at 创建时间
*
* @package App\Model * @package App\Model
*/ */
class Emoticon extends BaseModel class Emoticon extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'emoticon'; protected $table = 'emoticon';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = []; protected $fillable = [];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'created_at' => 'datetime' 'created_at' => 'datetime'

View File

@ -15,23 +15,12 @@ namespace App\Model;
* @property string $file_suffix 文件前缀 * @property string $file_suffix 文件前缀
* @property int $file_size 表情包文件大小 * @property int $file_size 表情包文件大小
* @property string $created_at 创建时间 * @property string $created_at 创建时间
*
* @package App\Model * @package App\Model
*/ */
class EmoticonDetail extends BaseModel class EmoticonDetail extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'emoticon_details'; protected $table = 'emoticon_details';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'emoticon_id', 'emoticon_id',
'user_id', 'user_id',
@ -42,11 +31,6 @@ class EmoticonDetail extends BaseModel
'created_at', 'created_at',
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'emoticon_id' => 'integer', 'emoticon_id' => 'integer',

View File

@ -19,23 +19,12 @@ namespace App\Model;
* @property int $file_size 临时文件大小 * @property int $file_size 临时文件大小
* @property int $is_delete 文件是否已被删除[1:;0:;] * @property int $is_delete 文件是否已被删除[1:;0:;]
* @property int $upload_at 文件上传时间 * @property int $upload_at 文件上传时间
*
* @package App\Model * @package App\Model
*/ */
class FileSplitUpload extends BaseModel class FileSplitUpload extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'file_split_upload'; protected $table = 'file_split_upload';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'file_type', 'file_type',
'user_id', 'user_id',
@ -50,11 +39,6 @@ class FileSplitUpload extends BaseModel
'upload_at' 'upload_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'file_type' => 'integer', 'file_type' => 'integer',

View File

@ -19,26 +19,17 @@ use App\Model\BaseModel;
* @property integer $is_dismiss 是否已解散[0:;1:;] * @property integer $is_dismiss 是否已解散[0:;1:;]
* @property string $created_at 创建时间 * @property string $created_at 创建时间
* @property string $dismissed_at 解散时间 * @property string $dismissed_at 解散时间
*
* @package App\Model\Group * @package App\Model\Group
*/ */
class Group extends BaseModel class Group extends BaseModel
{ {
// 最大成员数量 /**
* 最大成员数量
*/
const MAX_MEMBER_NUM = 200; const MAX_MEMBER_NUM = 200;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'group'; protected $table = 'group';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'creator_id', 'creator_id',
'group_name', 'group_name',
@ -52,11 +43,6 @@ class Group extends BaseModel
'dismissed_at', 'dismissed_at',
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'creator_id' => 'integer', 'creator_id' => 'integer',
'max_num' => 'integer', 'max_num' => 'integer',
@ -80,7 +66,6 @@ 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)
@ -92,7 +77,6 @@ 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)
@ -105,7 +89,6 @@ 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

@ -17,23 +17,12 @@ use App\Model\BaseModel;
* @property string $user_card 群名片 * @property string $user_card 群名片
* @property string $created_at 入群时间 * @property string $created_at 入群时间
* @property string $deleted_at 退群时间 * @property string $deleted_at 退群时间
*
* @package App\Model\Group * @package App\Model\Group
*/ */
class GroupMember extends BaseModel class GroupMember extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'group_member'; protected $table = 'group_member';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'group_id', 'group_id',
'user_id', 'user_id',
@ -45,11 +34,6 @@ class GroupMember extends BaseModel
'deleted_at', 'deleted_at',
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'group_id' => 'integer', 'group_id' => 'integer',
'user_id' => 'integer', 'user_id' => 'integer',
@ -64,7 +48,6 @@ 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)
@ -77,7 +60,6 @@ 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)
@ -89,7 +71,6 @@ 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

@ -20,23 +20,12 @@ use App\Model\BaseModel;
* @property string $created_at 创建时间 * @property string $created_at 创建时间
* @property string $updated_at 更新时间 * @property string $updated_at 更新时间
* @property string $deleted_at 删除时间 * @property string $deleted_at 删除时间
*
* @package App\Model\Group * @package App\Model\Group
*/ */
class GroupNotice extends BaseModel class GroupNotice extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'group_notice'; protected $table = 'group_notice';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'group_id', 'group_id',
'creator_id', 'creator_id',
@ -51,11 +40,6 @@ class GroupNotice extends BaseModel
'deleted_at' 'deleted_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'group_id' => 'integer', 'group_id' => 'integer',
'creator_id' => 'integer', 'creator_id' => 'integer',

View File

@ -14,31 +14,22 @@ namespace App\Model;
* @property string $avatar 头像 * @property string $avatar 头像
* @property integer $gender 性别 * @property integer $gender 性别
* @property integer $created_at 注册时间 * @property integer $created_at 注册时间
*
* @package App\Model * @package App\Model
*/ */
class User extends BaseModel class User extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'users'; protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'mobile', 'nickname', 'avatar', 'gender', 'password', 'motto', 'email', 'created_at' 'mobile',
'nickname',
'avatar',
'gender',
'password',
'motto',
'email',
'created_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = []; protected $casts = [];
} }

View File

@ -17,23 +17,12 @@ namespace App\Model;
* @property int $not_disturb 是否消息免打扰 * @property int $not_disturb 是否消息免打扰
* @property string $created_at 创建时间 * @property string $created_at 创建时间
* @property string $updated_at 更新时间 * @property string $updated_at 更新时间
*
* @package App\Model * @package App\Model
*/ */
class UsersChatList extends BaseModel class UsersChatList extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'users_chat_list'; protected $table = 'users_chat_list';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'type', 'type',
'uid', 'uid',
@ -46,11 +35,6 @@ class UsersChatList extends BaseModel
'updated_at' 'updated_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'type' => 'integer', 'type' => 'integer',
@ -70,7 +54,6 @@ 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)
@ -115,7 +98,6 @@ 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)
@ -132,7 +114,6 @@ 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)
@ -154,7 +135,6 @@ 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

@ -10,42 +10,24 @@ namespace App\Model;
* @property int $id 收藏ID * @property int $id 收藏ID
* @property int $user_id 用户ID * @property int $user_id 用户ID
* @property string $emoticon_ids 表情包ID多个用英文逗号拼接 * @property string $emoticon_ids 表情包ID多个用英文逗号拼接
*
* @package App\Model * @package App\Model
*/ */
class UsersEmoticon extends BaseModel class UsersEmoticon extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'users_emoticon'; protected $table = 'users_emoticon';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'user_id', 'user_id',
'emoticon_ids' 'emoticon_ids'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'user_id' => 'integer' 'user_id' => 'integer'
]; ];
/** /**
*
* @param string $value * @param string $value
*
* @return string * @return string
*/ */
public function getEmoticonIdsAttribute($value) public function getEmoticonIdsAttribute($value)

View File

@ -18,23 +18,12 @@ use Hyperf\DbConnection\Db;
* @property int $status 好友状态[1:好友状态;0:已解除好友关系] * @property int $status 好友状态[1:好友状态;0:已解除好友关系]
* @property string $agree_time 成为好友时间 * @property string $agree_time 成为好友时间
* @property string $created_at 创建时间 * @property string $created_at 创建时间
*
* @package App\Model * @package App\Model
*/ */
class UsersFriend extends BaseModel class UsersFriend extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'users_friends'; protected $table = 'users_friends';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'user1', 'user1',
'user2', 'user2',
@ -46,11 +35,6 @@ class UsersFriend extends BaseModel
'created_at' 'created_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'user1' => 'integer', 'user1' => 'integer',
@ -64,7 +48,6 @@ 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)
@ -95,7 +78,6 @@ 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)
@ -122,7 +104,6 @@ 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

@ -14,23 +14,12 @@ namespace App\Model;
* @property string $remarks 备注说明 * @property string $remarks 备注说明
* @property string $created_at 创建时间 * @property string $created_at 创建时间
* @property string $updated_at 更新时间 * @property string $updated_at 更新时间
*
* @package App\Model * @package App\Model
*/ */
class UsersFriendsApply extends BaseModel class UsersFriendsApply extends BaseModel
{ {
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'users_friends_apply'; protected $table = 'users_friends_apply';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'user_id', 'user_id',
'friend_id', 'friend_id',
@ -40,11 +29,6 @@ class UsersFriendsApply extends BaseModel
'updated_at' 'updated_at'
]; ];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'user_id' => 'integer', 'user_id' => 'integer',

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\Process; namespace App\Process;
use Hyperf\AsyncQueue\Process\ConsumerProcess; use Hyperf\AsyncQueue\Process\ConsumerProcess;

View File

@ -24,7 +24,6 @@ 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)
@ -43,15 +42,14 @@ class ArticleService extends BaseService
* 获取用户文章标签列表 * 获取用户文章标签列表
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* * @return array
* @return mixed
*/ */
public function getUserTags(int $user_id) public function getUserTags(int $user_id)
{ {
$items = ArticleTag::where('user_id', $user_id)->orderBy('id', 'desc')->get(['id', 'tag_name', Db::raw('0 as count')])->toArray(); $items = ArticleTag::where('user_id', $user_id)->orderBy('id', 'desc')->get(['id', 'tag_name', Db::raw('0 as count')])->toArray();
array_walk($items, function ($item) use ($user_id) { foreach ($items as $k => $item) {
$item['count'] = (int)Article::where('user_id', $user_id)->whereRaw("FIND_IN_SET({$item['id']},tags_id)")->count(); $items[$k]['count'] = (int)Article::where('user_id', $user_id)->whereRaw("FIND_IN_SET({$item['id']},tags_id)")->count();
}); }
return $items; return $items;
} }
@ -63,7 +61,6 @@ 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 = [])
@ -117,7 +114,6 @@ 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)
@ -158,7 +154,6 @@ 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)
@ -176,7 +171,6 @@ 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)
@ -203,18 +197,14 @@ class ArticleService extends BaseService
ArticleClass::where('id', $val['id'])->update(['sort' => $val['sort']]); ArticleClass::where('id', $val['id'])->update(['sort' => $val['sort']]);
} }
$insRes = ArticleClass::create(['user_id' => $uid, 'class_name' => $class_name, 'sort' => 1, 'created_at' => time()]); $res = ArticleClass::create(['user_id' => $uid, 'class_name' => $class_name, 'sort' => 1, 'created_at' => time()]);
if (!$insRes) {
throw new Exception('笔记分类添加失败..,.');
}
Db::commit(); Db::commit();
return $res->id;
} catch (Exception $e) { } catch (Exception $e) {
Db::rollBack(); Db::rollBack();
return false; return false;
} }
return $insRes->id;
} }
/** /**
@ -222,7 +212,6 @@ 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)
@ -245,7 +234,6 @@ 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)
@ -254,7 +242,7 @@ class ArticleService extends BaseService
return false; return false;
} }
//向下排序 // 向下排序
if ($sort_type == 1) { if ($sort_type == 1) {
$maxSort = ArticleClass::where('user_id', $user_id)->max('sort'); $maxSort = ArticleClass::where('user_id', $user_id)->max('sort');
if ($maxSort == $info->sort) { if ($maxSort == $info->sort) {
@ -310,7 +298,6 @@ 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)
@ -320,7 +307,7 @@ class ArticleService extends BaseService
return false; return false;
} }
return (boolean)Article::where('class_id', $class_id)->where('user_id', $user_id)->update([ return (bool)Article::where('class_id', $class_id)->where('user_id', $user_id)->update([
'class_id' => $to_class_id 'class_id' => $to_class_id
]); ]);
} }
@ -331,7 +318,6 @@ 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)
@ -344,10 +330,8 @@ class ArticleService extends BaseService
return ArticleTag::where('id', $tag_id)->where('user_id', $uid)->update(['tag_name' => $tag_name]) ? $tag_id : false; return ArticleTag::where('id', $tag_id)->where('user_id', $uid)->update(['tag_name' => $tag_name]) ? $tag_id : false;
} else { } else {
//判断新添加的标签名是否存在 // 判断新添加的标签名是否存在
if ($id) { if ($id) return false;
return false;
}
$insRes = ArticleTag::create(['user_id' => $uid, 'tag_name' => $tag_name, 'sort' => 1, 'created_at' => time()]); $insRes = ArticleTag::create(['user_id' => $uid, 'tag_name' => $tag_name, 'sort' => 1, 'created_at' => time()]);
if (!$insRes) { if (!$insRes) {
@ -363,7 +347,6 @@ 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)
@ -373,11 +356,13 @@ class ArticleService extends BaseService
} }
$count = Article::where('user_id', $uid)->whereRaw("FIND_IN_SET({$tag_id},tags_id)")->count(); $count = Article::where('user_id', $uid)->whereRaw("FIND_IN_SET({$tag_id},tags_id)")->count();
if ($count > 0) { if ($count > 0) return false;
try {
return (bool)ArticleTag::where('id', $tag_id)->where('user_id', $uid)->delete();
} catch (Exception $e) {
return false; return false;
} }
return (bool)ArticleTag::where('id', $tag_id)->where('user_id', $uid)->delete();
} }
/** /**
@ -386,13 +371,12 @@ 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 = [])
{ {
if ($article_id) { if ($article_id) {
if (!$info = Article::where('id', $article_id)->where('user_id', $user_id)->first()) { if (!Article::where('id', $article_id)->where('user_id', $user_id)->first()) {
return false; return false;
} }
@ -452,7 +436,6 @@ 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)
@ -471,12 +454,11 @@ 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)
{ {
return (boolean)Article::where('id', $article_id)->where('user_id', $user_id)->update(['class_id' => $class_id]); return (bool)Article::where('id', $article_id)->where('user_id', $user_id)->update(['class_id' => $class_id]);
} }
/** /**
@ -485,12 +467,11 @@ 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)
{ {
return (boolean)Article::where('id', $article_id)->where('user_id', $user_id)->update([ return (bool)Article::where('id', $article_id)->where('user_id', $user_id)->update([
'is_asterisk' => $type == 1 ? 1 : 0 'is_asterisk' => $type == 1 ? 1 : 0
]); ]);
} }
@ -501,7 +482,6 @@ 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)
@ -514,7 +494,6 @@ 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
*/ */
@ -551,9 +530,9 @@ class ArticleService extends BaseService
} }
// 从磁盘中永久删除文件附件 // 从磁盘中永久删除文件附件
foreach ($annex_files as $item) { //foreach ($annex_files as $item) {
//Storage::disk('uploads')->delete($item['save_dir']); //Storage::disk('uploads')->delete($item['save_dir']);
} //}
return true; return true;
} }
@ -564,7 +543,6 @@ 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)
@ -574,14 +552,13 @@ class ArticleService extends BaseService
$data['deleted_at'] = date('Y-m-d H:i:s'); $data['deleted_at'] = date('Y-m-d H:i:s');
} }
return ArticleAnnex::where('id', $annex_id)->where('user_id', $user_id)->update($data) ? true : false; return (bool)ArticleAnnex::where('id', $annex_id)->where('user_id', $user_id)->update($data);
} }
/** /**
* 回收站附件列表 * 回收站附件列表
* *
* @param int $uid 用户ID * @param int $uid 用户ID
*
* @return array * @return array
*/ */
public function recoverAnnexList(int $uid) public function recoverAnnexList(int $uid)
@ -603,15 +580,7 @@ class ArticleService extends BaseService
* *
* @param int $uid 用户ID * @param int $uid 用户ID
* @param int $annex_id 笔记附件ID * @param int $annex_id 笔记附件ID
* * @return mixed
* @return bool|int|mixed|null
*/
/**
* @param int $uid
* @param int $annex_id
*
* @return bool|int|mixed|null
* @throws Exception * @throws Exception
*/ */
public function foreverDelAnnex(int $uid, int $annex_id) public function foreverDelAnnex(int $uid, int $annex_id)
@ -622,9 +591,9 @@ class ArticleService extends BaseService
} }
// 将文件从磁盘中删除 // 将文件从磁盘中删除
// if (!Storage::disk('uploads')->delete($info->save_dir)) { //if (!Storage::disk('uploads')->delete($info->save_dir)) {
// return false; // return false;
// } //}
return $info->delete(); return $info->delete();
} }
@ -635,7 +604,6 @@ 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

@ -1,8 +1,6 @@
<?php <?php
/** /**
*
* This is my open source code, please do not use it for commercial applications. * This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information, * For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code * please view the LICENSE file that was distributed with this source code
* *
@ -33,7 +31,6 @@ 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
@ -64,7 +61,6 @@ 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
@ -92,7 +88,7 @@ SQL;
'updated_at' => date('Y-m-d H:i:s') 'updated_at' => date('Y-m-d H:i:s')
]); ]);
return $result ? true : false; return (bool)$result;
} }
} }
@ -101,7 +97,6 @@ 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
@ -126,7 +121,6 @@ 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
@ -189,12 +183,11 @@ 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
{ {
$result = UsersFriendsApply::where([ return (bool)UsersFriendsApply::where([
['id', '=', $apply_id], ['id', '=', $apply_id],
['user_id', '=', $user_id], ['user_id', '=', $user_id],
['status', '=', 2], ['status', '=', 2],
@ -203,8 +196,6 @@ SQL;
'remarks' => $remarks, 'remarks' => $remarks,
'updated_at' => date('Y-m-d H:i:s') 'updated_at' => date('Y-m-d H:i:s')
]); ]);
return $result ? true : false;
} }
/** /**
@ -213,7 +204,6 @@ 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
@ -233,7 +223,6 @@ SQL;
* 搜索联系人 * 搜索联系人
* *
* @param string $mobile 用户手机号/登录账号 * @param string $mobile 用户手机号/登录账号
*
* @return array * @return array
*/ */
public function findContact(string $mobile): array public function findContact(string $mobile): array
@ -249,7 +238,6 @@ 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
@ -283,8 +271,8 @@ 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
* @throws Exception
*/ */
public function delContactApplyRecord(int $user_id, int $apply_id): bool public function delContactApplyRecord(int $user_id, int $apply_id): bool
{ {

View File

@ -10,7 +10,6 @@ use App\Model\UsersEmoticon;
/** /**
* 表情服务层 * 表情服务层
*
* Class EmoticonService * Class EmoticonService
* *
* @package App\Services * @package App\Services
@ -22,14 +21,13 @@ 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 mixed
*/ */
public function installSysEmoticon(int $user_id, int $emoticon_id) public function installSysEmoticon(int $user_id, int $emoticon_id)
{ {
$info = UsersEmoticon::select(['id', 'user_id', 'emoticon_ids'])->where('user_id', $user_id)->first(); $info = UsersEmoticon::select(['id', 'user_id', 'emoticon_ids'])->where('user_id', $user_id)->first();
if (!$info) { if (!$info) {
return UsersEmoticon::create(['user_id' => $user_id, 'emoticon_ids' => $emoticon_id]) ? true : false; return (bool)UsersEmoticon::create(['user_id' => $user_id, 'emoticon_ids' => $emoticon_id]);
} }
$emoticon_ids = $info->emoticon_ids; $emoticon_ids = $info->emoticon_ids;
@ -38,9 +36,10 @@ class EmoticonService extends BaseService
} }
$emoticon_ids[] = $emoticon_id; $emoticon_ids[] = $emoticon_id;
return UsersEmoticon::where('user_id', $user_id)->update([
return (bool)UsersEmoticon::where('user_id', $user_id)->update([
'emoticon_ids' => implode(',', $emoticon_ids) 'emoticon_ids' => implode(',', $emoticon_ids)
]) ? true : false; ]);
} }
/** /**
@ -48,7 +47,6 @@ 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)
@ -60,25 +58,22 @@ class EmoticonService extends BaseService
$emoticon_ids = $info->emoticon_ids; $emoticon_ids = $info->emoticon_ids;
foreach ($emoticon_ids as $k => $id) { foreach ($emoticon_ids as $k => $id) {
if ($id == $emoticon_id) { if ($id == $emoticon_id) unset($emoticon_ids[$k]);
unset($emoticon_ids[$k]);
}
} }
if (count($info->emoticon_ids) == count($emoticon_ids)) { if (count($info->emoticon_ids) == count($emoticon_ids)) {
return false; return false;
} }
return UsersEmoticon::where('user_id', $user_id)->update([ return (bool)UsersEmoticon::where('user_id', $user_id)->update([
'emoticon_ids' => implode(',', $emoticon_ids) 'emoticon_ids' => implode(',', $emoticon_ids)
]) ? true : false; ]);
} }
/** /**
* 获取用户安装的表情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)
@ -92,7 +87,6 @@ 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)
@ -148,8 +142,8 @@ class EmoticonService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param array $ids 表情包详情ID * @param array $ids 表情包详情ID
* * @return bool
* @return * @throws \Exception
*/ */
public function deleteCollect(int $user_id, array $ids) public function deleteCollect(int $user_id, array $ids)
{ {
@ -160,17 +154,15 @@ class EmoticonService extends BaseService
* 获取表情包列表 * 获取表情包列表
* *
* @param array $where * @param array $where
* * @return array
* @return mixed
*/ */
public function getDetailsAll(array $where = []) public function getDetailsAll(array $where = [])
{ {
$list = EmoticonDetail::where($where)->get(['id as media_id', 'url as src'])->toArray(); $items = EmoticonDetail::where($where)->get(['id as media_id', 'url as src'])->toArray();
foreach ($items as $k => $item) {
foreach ($list as $k => $value) { $items[$k]['src'] = get_media_url($item['src']);
$list[$k]['src'] = get_media_url($value['src']);
} }
return $list; return $items;
} }
} }

View File

@ -23,7 +23,6 @@ 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
@ -60,7 +59,6 @@ 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 = [])
@ -146,7 +144,6 @@ 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)
@ -177,7 +174,6 @@ 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 = [])
@ -282,7 +278,6 @@ 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)
@ -337,7 +332,6 @@ 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

@ -25,7 +25,6 @@ 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)
@ -43,7 +42,6 @@ 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)
@ -61,7 +59,6 @@ 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
*/ */
@ -70,10 +67,10 @@ class MailerService
$config = config('mail'); $config = config('mail');
$mail = new PHPMailer(); $mail = new PHPMailer();
$mail->CharSet = 'UTF-8'; $mail->CharSet = 'UTF-8';
$mail->IsSMTP(); // 设定使用SMTP服务 $mail->IsSMTP(); // 设定使用SMTP服务
$mail->SMTPDebug = 0; // 关闭SMTP调试功能 $mail->SMTPDebug = 0; // 关闭SMTP调试功能
$mail->SMTPAuth = true; // 启用 SMTP 验证功能 $mail->SMTPAuth = true; // 启用 SMTP 验证功能
$mail->SMTPSecure = 'ssl'; // 使用安全协议 $mail->SMTPSecure = 'ssl'; // 使用安全协议
$mail->Host = $config['host']; $mail->Host = $config['host'];
$mail->Port = $config['port']; $mail->Port = $config['port'];
$mail->Username = $config['username']; $mail->Username = $config['username'];

View File

@ -40,8 +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 void
* @return bool|void
*/ */
public function onTalk($server, Frame $frame, $data) public function onTalk($server, Frame $frame, $data)
{ {
@ -109,8 +108,6 @@ 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
*/ */
public function onKeyboard($server, Frame $frame, $data) public function onKeyboard($server, Frame $frame, $data)
{ {

View File

@ -5,8 +5,6 @@ namespace App\Service;
/** /**
* 短信发送服务 * 短信发送服务
* *
* Class SmsCodeService
*
* @package App\Services * @package App\Services
*/ */
class SmsCodeService class SmsCodeService
@ -35,7 +33,6 @@ 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)
@ -49,7 +46,6 @@ 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)
@ -64,7 +60,6 @@ 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)
@ -103,7 +98,6 @@ class SmsCodeService
* 获取缓存的验证码 * 获取缓存的验证码
* *
* @param string $key * @param string $key
*
* @return mixed * @return mixed
*/ */
public function getCode(string $key) public function getCode(string $key)
@ -117,7 +111,6 @@ 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)
@ -130,7 +123,6 @@ 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)
@ -143,18 +135,17 @@ 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)
{ {
// ... 省略处理 // ... 省略处理
if (false) { //if (false) {
return [false, [ // return [false, [
'msg' => '过滤原因...', // 'msg' => '过滤原因...',
'data' => [] // 'data' => []
]]; // ]];
} //}
return [true, [ return [true, [
'msg' => 'ok', 'msg' => 'ok',
@ -166,7 +157,6 @@ class SmsCodeService
* 判断验证码用途渠道是否注册 * 判断验证码用途渠道是否注册
* *
* @param string $usage * @param string $usage
*
* @return bool * @return bool
*/ */
public function isUsages(string $usage) public function isUsages(string $usage)

View File

@ -42,8 +42,6 @@ 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
*/ */
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)
{ {
@ -72,12 +70,11 @@ 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
{ {
return $this->redis->scard(sprintf('%s:%s:%s', self::BIND_USER_TO_FDS, $run_id, $user_id)) ? true : false; return (bool)$this->redis->scard(sprintf('%s:%s:%s', self::BIND_USER_TO_FDS, $run_id, $user_id));
} }
/** /**
@ -85,7 +82,6 @@ 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 = [])
@ -104,7 +100,6 @@ 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)
@ -117,7 +112,6 @@ 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)
@ -132,7 +126,6 @@ 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

@ -5,8 +5,6 @@ namespace App\Service;
/** /**
* 聊天室房间服务 * 聊天室房间服务
* *
* Class SocketRoomService
*
* @package App\Service * @package App\Service
*/ */
class SocketRoomService class SocketRoomService
@ -17,7 +15,6 @@ class SocketRoomService
* 获取房间名 * 获取房间名
* *
* @param string|integer $room 房间名 * @param string|integer $room 房间名
*
* @return string * @return string
*/ */
public function getRoomName($room) public function getRoomName($room)
@ -29,7 +26,6 @@ class SocketRoomService
* 获取房间成员 * 获取房间成员
* *
* @param string $room 房间名 * @param string $room 房间名
*
* @return array * @return array
*/ */
public function getRoomMembers(string $room) public function getRoomMembers(string $room)
@ -42,7 +38,6 @@ 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)
@ -55,7 +50,6 @@ 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)
@ -67,7 +61,6 @@ class SocketRoomService
* 删除房间 * 删除房间
* *
* @param string|int $room 房间名 * @param string|int $room 房间名
*
* @return int * @return int
*/ */
public function delRoom($room) public function delRoom($room)

View File

@ -9,8 +9,6 @@ use Hyperf\HttpMessage\Upload\UploadedFile;
/** /**
* 文件拆分上传服务 * 文件拆分上传服务
* *
* Class SplitUploadService
*
* @package App\Service * @package App\Service
*/ */
class SplitUploadService class SplitUploadService
@ -26,7 +24,6 @@ class SplitUploadService
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $fileName 上传的文件名 * @param string $fileName 上传的文件名
* @param string $fileSize 上传文件大小 * @param string $fileSize 上传文件大小
*
* @return array|bool * @return array|bool
*/ */
public function create(int $user_id, string $fileName, string $fileSize) public function create(int $user_id, string $fileName, string $fileSize)
@ -43,7 +40,7 @@ class SplitUploadService
$data['file_size'] = $fileSize; $data['file_size'] = $fileSize;
$data['upload_at'] = time(); $data['upload_at'] = time();
//文件拆分数量 // 文件拆分数量
$data['split_num'] = $split_num; $data['split_num'] = $split_num;
$data['split_index'] = $split_num; $data['split_index'] = $split_num;
@ -58,7 +55,6 @@ class SplitUploadService
* @param string $hashName 上传临时问价hash名 * @param string $hashName 上传临时问价hash名
* @param int $split_index 当前拆分文件索引 * @param int $split_index 当前拆分文件索引
* @param int $fileSize 文件大小 * @param int $fileSize 文件大小
*
* @return bool * @return bool
*/ */
public function upload(int $user_id, UploadedFile $file, string $hashName, int $split_index, int $fileSize) public function upload(int $user_id, UploadedFile $file, string $hashName, int $split_index, int $fileSize)
@ -106,7 +102,6 @@ class SplitUploadService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $hash_name 上传临时问价hash名 * @param string $hash_name 上传临时问价hash名
*
* @return array|bool * @return array|bool
*/ */
public function merge(int $user_id, string $hash_name) public function merge(int $user_id, string $hash_name)

View File

@ -26,7 +26,6 @@ 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)
@ -51,7 +50,7 @@ class TalkService extends BaseService
$socketFDService = make(SocketClientService::class); $socketFDService = make(SocketClientService::class);
$runIdAll = $socketFDService->getServerRunIdAll(); $runIdAll = $socketFDService->getServerRunIdAll();
$rows = array_map(function ($item) use ($user_id, $socketFDService, $runIdAll) { return array_map(function ($item) use ($user_id, $socketFDService, $runIdAll) {
$data['id'] = $item['id']; $data['id'] = $item['id'];
$data['type'] = $item['type']; $data['type'] = $item['type'];
$data['friend_id'] = $item['friend_id']; $data['friend_id'] = $item['friend_id'];
@ -98,8 +97,6 @@ class TalkService extends BaseService
return $data; return $data;
}, $rows); }, $rows);
return $rows;
} }
/** /**
@ -127,7 +124,6 @@ class TalkService extends BaseService
* 处理聊天记录信息 * 处理聊天记录信息
* *
* @param array $rows 聊天记录 * @param array $rows 聊天记录
*
* @return array * @return array
*/ */
public function handleChatRecords(array $rows) public function handleChatRecords(array $rows)
@ -234,7 +230,6 @@ 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 = [])
@ -295,7 +290,6 @@ 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)
@ -340,7 +334,6 @@ 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)
@ -379,7 +372,6 @@ 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)
@ -413,8 +405,8 @@ 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)
@ -506,8 +498,8 @@ class TalkService extends BaseService
* @param int $receive_id 当前转发消息的所属者(好友ID或者群聊ID) * @param int $receive_id 当前转发消息的所属者(好友ID或者群聊ID)
* @param int $source 消息来源 1:好友消息 2:群聊消息 * @param int $source 消息来源 1:好友消息 2:群聊消息
* @param array $records_ids 转发消息的记录ID * @param array $records_ids 转发消息的记录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|bool * @return array|bool
*/ */
public function mergeForwardRecords(int $user_id, int $receive_id, int $source, $records_ids, array $receive_ids) public function mergeForwardRecords(int $user_id, int $receive_id, int $source, $records_ids, array $receive_ids)
@ -517,16 +509,16 @@ class TalkService extends BaseService
$sqlObj = ChatRecord::whereIn('id', $records_ids); $sqlObj = ChatRecord::whereIn('id', $records_ids);
//验证是否有权限转发 // 验证是否有权限转发
if ($source == 2) {//群聊消息 if ($source == 2) {// 群聊消息
//判断是否是群聊成员 // 判断是否是群聊成员
if (!Group::isMember($receive_id, $user_id)) { if (!Group::isMember($receive_id, $user_id)) {
return false; return false;
} }
$sqlObj = $sqlObj->where('receive_id', $receive_id)->whereIn('msg_type', $msg_type)->where('source', 2)->where('is_revoke', 0); $sqlObj = $sqlObj->where('receive_id', $receive_id)->whereIn('msg_type', $msg_type)->where('source', 2)->where('is_revoke', 0);
} else {//私聊消息 } else {// 私聊消息
//判断是否存在好友关系 // 判断是否存在好友关系
if (!UsersFriend::isFriend($user_id, $receive_id)) { if (!UsersFriend::isFriend($user_id, $receive_id)) {
return []; return [];
} }
@ -544,7 +536,7 @@ class TalkService extends BaseService
$result = $sqlObj->get(); $result = $sqlObj->get();
//判断消息记录是否存在 // 判断消息记录是否存在
if (count($result) != count($records_ids)) { if (count($result) != count($records_ids)) {
return []; return [];
} }
@ -628,8 +620,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 array
* @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)
{ {
@ -685,7 +676,6 @@ 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)
@ -719,7 +709,6 @@ 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)
@ -752,7 +741,6 @@ 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)
@ -785,7 +773,6 @@ 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

@ -7,8 +7,6 @@ use Hyperf\HttpMessage\Upload\UploadedFile;
/** /**
* 文件上传服务 * 文件上传服务
* *
* Class UploadService
*
* @package App\Service * @package App\Service
*/ */
class UploadService extends BaseService class UploadService extends BaseService
@ -23,7 +21,7 @@ class UploadService extends BaseService
* *
* @param string $dir 文件夹路径 * @param string $dir 文件夹路径
*/ */
public function makeDirectory($dir) public function makeDirectory(string $dir)
{ {
if (!file_exists($dir)) @mkdir($dir, 0777, true); if (!file_exists($dir)) @mkdir($dir, 0777, true);
} }
@ -34,7 +32,6 @@ class UploadService extends BaseService
* @param UploadedFile $file * @param UploadedFile $file
* @param string $dir 文件夹路径 * @param string $dir 文件夹路径
* @param string $filename 文件名称 * @param string $filename 文件名称
*
* @return bool|string * @return bool|string
*/ */
public function media(UploadedFile $file, string $dir, string $filename) public function media(UploadedFile $file, string $dir, string $filename)
@ -46,7 +43,6 @@ class UploadService extends BaseService
$file->moveTo(sprintf('%s/%s', $save_dir, $filename)); $file->moveTo(sprintf('%s/%s', $save_dir, $filename));
if ($file->isMoved()) { if ($file->isMoved()) {
// 修改文件权限
@chmod(sprintf('%s/%s', $save_dir, $filename), 0644); @chmod(sprintf('%s/%s', $save_dir, $filename), 0644);
} }

View File

@ -16,8 +16,7 @@ class UserService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param array $field 查询字段 * @param array $field 查询字段
* * @return User
* @return mixed
*/ */
public function findById(int $user_id, $field = ['*']) public function findById(int $user_id, $field = ['*'])
{ {
@ -29,7 +28,6 @@ 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)
@ -49,7 +47,6 @@ class UserService extends BaseService
* 账号注册逻辑 * 账号注册逻辑
* *
* @param array $data 用户数据 * @param array $data 用户数据
*
* @return bool * @return bool
*/ */
public function register(array $data) public function register(array $data)
@ -71,12 +68,11 @@ class UserService extends BaseService
]); ]);
Db::commit(); Db::commit();
return true;
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollBack(); Db::rollBack();
$result = false; return false;
} }
return $result ? true : false;
} }
/** /**
@ -84,12 +80,11 @@ class UserService extends BaseService
* *
* @param string $mobile 用户手机好 * @param string $mobile 用户手机好
* @param string $password 新密码 * @param string $password 新密码
* * @return bool
* @return mixed
*/ */
public function resetPassword(string $mobile, string $password) public function resetPassword(string $mobile, string $password)
{ {
return User::where('mobile', $mobile)->update(['password' => Hash::make($password)]); return (bool)User::where('mobile', $mobile)->update(['password' => Hash::make($password)]);
} }
/** /**
@ -97,8 +92,7 @@ class UserService extends BaseService
* *
* @param int $user_id 用户ID * @param int $user_id 用户ID
* @param string $mobile 换绑手机号 * @param string $mobile 换绑手机号
* * @return array
* @return array|bool
*/ */
public function changeMobile(int $user_id, string $mobile) public function changeMobile(int $user_id, string $mobile)
{ {
@ -115,7 +109,6 @@ 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

@ -18,7 +18,6 @@ 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)
@ -40,24 +39,23 @@ 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
*/ */
private function mail(string $address, string $subject, string $view): bool private function mail(string $address, string $subject, string $view): bool
{ {
$config = config('mail'); $config = config('mail');
$mail = new PHPMailer(); //PHPMailer对象 $mail = new PHPMailer(); // PHPMailer对象
$mail->CharSet = 'UTF-8'; //设定邮件编码默认ISO-8859-1如果发中文此项必须设置否则乱码 $mail->CharSet = 'UTF-8'; // 设定邮件编码默认ISO-8859-1如果发中文此项必须设置否则乱码
$mail->IsSMTP(); // 设定使用SMTP服务 $mail->IsSMTP(); // 设定使用SMTP服务
$mail->SMTPDebug = 0; // 关闭SMTP调试功能 $mail->SMTPDebug = 0; // 关闭SMTP调试功能
$mail->SMTPAuth = true; // 启用 SMTP 验证功能 $mail->SMTPAuth = true; // 启用 SMTP 验证功能
$mail->SMTPSecure = 'ssl'; // 使用安全协议 $mail->SMTPSecure = 'ssl'; // 使用安全协议
$mail->Host = $config['host']; // SMTP 服务器 $mail->Host = $config['host']; // SMTP 服务器
$mail->Port = $config['port']; // SMTP服务器的端口号 $mail->Port = $config['port']; // SMTP服务器的端口号
$mail->Username = $config['username']; // SMTP; // SMTP服务器用户名 $mail->Username = $config['username']; // SMTP服务器用户名
$mail->Password = $config['password']; // SMTP服务器密码 $mail->Password = $config['password']; // SMTP服务器密码
$mail->SetFrom($config['from'], $config['name']); // 邮箱,昵称 $mail->SetFrom($config['from'], $config['name']); // 邮箱,昵称
$mail->Subject = $subject; $mail->Subject = $subject;
$mail->MsgHTML($view); $mail->MsgHTML($view);
$mail->AddAddress($address); // 收件人 $mail->AddAddress($address); // 收件人
@ -68,7 +66,6 @@ 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

@ -4,7 +4,6 @@ namespace App\Support;
/** /**
* 邮件视图模板 * 邮件视图模板
* Class MailerViewTemplate
* *
* @package App\Support * @package App\Support
*/ */
@ -16,7 +15,6 @@ 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
@ -29,7 +27,6 @@ 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

@ -107,7 +107,6 @@ class Packet
* Get socket packet type of a raw payload. * Get socket packet type of a raw payload.
* *
* @param string $packet * @param string $packet
*
* @return int|null * @return int|null
*/ */
public static function getSocketType(string $packet) public static function getSocketType(string $packet)
@ -125,13 +124,12 @@ class Packet
* Get data packet from a raw payload. * Get data packet from a raw payload.
* *
* @param string $packet * @param string $packet
*
* @return array|null * @return array|null
*/ */
public static function getPayload(string $packet) public static function getPayload(string $packet)
{ {
$packet = trim($packet); $packet = trim($packet);
$start = strpos($packet, '['); $start = strpos($packet, '[');
if ($start === false || substr($packet, -1) !== ']') { if ($start === false || substr($packet, -1) !== ']') {
return null; return null;
@ -146,16 +144,15 @@ class Packet
return [ return [
'event' => $data[0], 'event' => $data[0],
'data' => $data[1] ?? null, 'data' => $data[1] ?? null,
]; ];
} }
/** /**
* Return if a socket packet belongs to specific type. * Return if a socket packet belongs to specific type.
* *
* @param $packet * @param $packet
* @param string $typeName * @param string $typeName
*
* @return bool * @return bool
*/ */
public static function isSocketType($packet, string $typeName) public static function isSocketType($packet, string $typeName)

View File

@ -35,7 +35,6 @@ 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
*/ */
@ -69,7 +68,6 @@ 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)
@ -93,7 +91,6 @@ 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

@ -16,8 +16,9 @@ class Response
private $response; private $response;
/** /**
* @param $data * 处理json数据
* *
* @param $data
* @return PsrResponseInterface * @return PsrResponseInterface
*/ */
public function json($data) public function json($data)
@ -30,7 +31,6 @@ 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')
@ -45,7 +45,6 @@ class Response
* @param array $data 响应数据 * @param array $data 响应数据
* @param string $message 响应提示 * @param string $message 响应提示
* @param int $code 错误码 * @param int $code 错误码
*
* @return PsrResponseInterface * @return PsrResponseInterface
*/ */
public function fail($message = 'fail', $data = [], $code = ResponseCode::FAIL) public function fail($message = 'fail', $data = [], $code = ResponseCode::FAIL)
@ -54,9 +53,10 @@ class Response
} }
/** /**
* @param string $message * 处理错误信息返回
* @param int $code
* *
* @param string $message 响应提示
* @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

@ -2,7 +2,6 @@
namespace App\Support; namespace App\Support;
class SendEmailCode class SendEmailCode
{ {
const FORGET_PASSWORD = 'forget_password'; const FORGET_PASSWORD = 'forget_password';
@ -15,7 +14,6 @@ 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)
@ -29,7 +27,6 @@ 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)
@ -48,8 +45,7 @@ class SendEmailCode
* @param string $type 类型 * @param string $type 类型
* @param string $title 邮件标题 * @param string $title 邮件标题
* @param string $email 邮箱地址 * @param string $email 邮箱地址
* * @return bool
* @return boolean
*/ */
public function send(string $type, string $title, string $email) public function send(string $type, string $title, string $email)
{ {
@ -70,7 +66,6 @@ class SendEmailCode
* 获取缓存的验证码 * 获取缓存的验证码
* *
* @param string $key * @param string $key
*
* @return mixed * @return mixed
*/ */
public function getCode(string $key) public function getCode(string $key)
@ -84,8 +79,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 bool
* @return mixed
*/ */
public function setCode(string $key, string $sms_code, $exp = 60 * 15) public function setCode(string $key, string $sms_code, $exp = 60 * 15)
{ {
@ -97,8 +91,7 @@ class SendEmailCode
* *
* @param string $type 类型 * @param string $type 类型
* @param string $email 邮箱地址 * @param string $email 邮箱地址
* * @return int
* @return mixed
*/ */
public function delCode(string $type, string $email) public function delCode(string $type, string $email)
{ {

View File

@ -9,7 +9,6 @@ class SocketIOParser extends Packet
* *
* @param string $event * @param string $event
* @param mixed $data * @param mixed $data
*
* @return mixed * @return mixed
*/ */
public static function encode(string $event, $data) public static function encode(string $event, $data)
@ -26,7 +25,6 @@ class SocketIOParser extends Packet
* Decode message from websocket client. * Decode message from websocket client.
* *
* @param string $string * @param string $string
*
* @return array * @return array
*/ */
public static function decode($string) public static function decode($string)

View File

@ -14,7 +14,6 @@ trait PagingTrait
* *
* @param int $total 总记录数 * @param int $total 总记录数
* @param int $page_size 分页大小 * @param int $page_size 分页大小
*
* @return int 分页总数 * @return int 分页总数
*/ */
protected function getPagingTotal(int $total, int $page_size) protected function getPagingTotal(int $total, int $page_size)
@ -30,7 +29,6 @@ trait PagingTrait
* @param int $page 当前分页 * @param int $page 当前分页
* @param int $page_size 分页大小 * @param int $page_size 分页大小
* @param array $params 额外参数 * @param array $params 额外参数
*
* @return array * @return array
*/ */
protected function getPagingRows(array $rows, int $total, int $page, int $page_size, array $params = []) protected function getPagingRows(array $rows, int $total, int $page, int $page_size, array $params = [])

View File

@ -1,15 +1,4 @@
<?php <?php
/**
*
* This is my open source code, please do not use it for commercial applications.
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code
*
* @author Yuandong<837215079@qq.com>
* @link https://github.com/gzydong/hyperf-chat
*/
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Common function method | Common function method
@ -132,7 +121,6 @@ function response()
* 从HTML文本中提取所有图片 * 从HTML文本中提取所有图片
* *
* @param string $content HTML文本 * @param string $content HTML文本
*
* @return array * @return array
*/ */
function get_html_images($content) function get_html_images($content)
@ -155,7 +143,6 @@ function get_html_images($content)
* *
* @param string $day1 日期1 * @param string $day1 日期1
* @param string $day2 日期2 * @param string $day2 日期2
*
* @return float|int * @return float|int
*/ */
function diff_date($day1, $day2) function diff_date($day1, $day2)
@ -174,21 +161,19 @@ function diff_date($day1, $day2)
* 获取媒体文件url * 获取媒体文件url
* *
* @param string $path 文件相对路径 * @param string $path 文件相对路径
*
* @return string * @return string
*/ */
function get_media_url(string $path) function get_media_url(string $path)
{ {
return sprintf('%s/%s', rtrim(config('domain.img_url'), '/'), ltrim($path,'/')); return sprintf('%s/%s', rtrim(config('domain.img_url'), '/'), ltrim($path, '/'));
} }
/** /**
* 随机生成图片名 * 随机生成图片名
* *
* @param string $ext 图片后缀名 * @param string $ext 图片后缀名
* @param int $width 图片宽度 * @param int $width 图片宽度
* @param int $height 图片高度 * @param int $height 图片高度
*
* @return string * @return string
*/ */
function create_image_name(string $ext, int $width, int $height) function create_image_name(string $ext, int $width, int $height)
@ -200,7 +185,6 @@ function create_image_name(string $ext, int $width, int $height)
* 替换文本中的url a标签 * 替换文本中的url a标签
* *
* @param string $str 字符串 * @param string $str 字符串
*
* @return null|string|string[] * @return null|string|string[]
*/ */
function replace_url_link(string $str) function replace_url_link(string $str)
@ -214,10 +198,9 @@ function replace_url_link(string $str)
/** /**
* 二维数组排序 * 二维数组排序
* *
* @param array $array 数组 * @param array $array 数组
* @param string $field 排序字段 * @param string $field 排序字段
* @param int $sort 排序方式 * @param int $sort 排序方式
*
* @return array * @return array
*/ */
function arraysSort(array $array, $field, $sort = SORT_DESC) function arraysSort(array $array, $field, $sort = SORT_DESC)
@ -229,9 +212,8 @@ function arraysSort(array $array, $field, $sort = SORT_DESC)
/** /**
* 判断0或正整数 * 判断0或正整数
* *
* @param string $int 验证字符串 * @param string $int 验证字符串
* @param bool $isZero 判断是否可为0 * @param bool $isZero 判断是否可为0
*
* @return bool * @return bool
*/ */
function check_int($int, $isZero = false) function check_int($int, $isZero = false)
@ -244,7 +226,6 @@ function check_int($int, $isZero = false)
* 解析英文逗号',' 拼接的 ID 字符串 * 解析英文逗号',' 拼接的 ID 字符串
* *
* @param string $ids 字符串(例如; "1,2,3,4,5,6") * @param string $ids 字符串(例如; "1,2,3,4,5,6")
*
* @return array * @return array
*/ */
function parse_ids($ids) function parse_ids($ids)

View File

@ -48,7 +48,7 @@ return [
], ],
'settings' => [ 'settings' => [
'enable_coroutine' => true, 'enable_coroutine' => true,
'worker_num' => swoole_cpu_num(), 'worker_num' => 1,
'pid_file' => BASE_PATH . '/runtime/hyperf.pid', 'pid_file' => BASE_PATH . '/runtime/hyperf.pid',
'open_tcp_nodelay' => true, 'open_tcp_nodelay' => true,
'max_coroutine' => 100000, 'max_coroutine' => 100000,