From 52410df8a6cdc808600b495e75c5cab02c801676 Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Thu, 22 Apr 2021 16:14:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Amqp/Consumer/ChatMessageConsumer.php | 20 ++--- app/Amqp/Producer/ChatMessageProducer.php | 4 +- app/Bootstrap/ServerStart.php | 4 - app/Cache/ApplyNumCache.php | 3 - app/Cache/FriendRemarkCache.php | 1 - app/Cache/LastMsgCache.php | 3 - app/Cache/UnreadTalkCache.php | 6 -- app/Command/RemoveWsCacheCommand.php | 2 - app/Constants/ResponseCode.php | 12 --- app/Constants/SocketConstants.php | 12 --- app/Controller/AbstractController.php | 2 - app/Controller/Api/V1/ArticleController.php | 74 ++++++++++------ app/Controller/Api/V1/AuthController.php | 9 -- app/Controller/Api/V1/CController.php | 4 - app/Controller/Api/V1/ContactsController.php | 33 ++++---- app/Controller/Api/V1/DownloadController.php | 7 -- app/Controller/Api/V1/EmoticonController.php | 20 ++--- app/Controller/Api/V1/GroupController.php | 46 ++++++---- app/Controller/Api/V1/TalkController.php | 55 +++++++----- app/Controller/Api/V1/UploadController.php | 15 ++-- app/Controller/Api/V1/UsersController.php | 31 ++++--- app/Controller/IndexController.php | 8 +- app/Controller/WebSocketController.php | 2 - app/Exception/Handler/AppExceptionHandler.php | 1 - .../Handler/JwtAuthExceptionHandler.php | 1 - .../Handler/ValidateExceptionHandler.php | 3 - app/Exception/ValidateException.php | 4 - app/Helper/Hash.php | 4 - app/Helper/HashIdsHelper.php | 4 - app/Helper/StringHelper.php | 5 -- app/Middleware/CorsMiddleware.php | 2 - app/Middleware/JWTAuthMiddleware.php | 2 - app/Middleware/WebSocketAuthMiddleware.php | 2 - app/Model/Article/Article.php | 40 +++------ app/Model/Article/ArticleAnnex.php | 16 ---- app/Model/Article/ArticleClass.php | 16 ---- app/Model/Article/ArticleDetail.php | 16 ---- app/Model/Article/ArticleTag.php | 22 ++--- app/Model/Chat/ChatRecord.php | 16 ---- app/Model/Chat/ChatRecordsCode.php | 16 ---- app/Model/Chat/ChatRecordsDelete.php | 16 ---- app/Model/Chat/ChatRecordsFile.php | 16 ---- app/Model/Chat/ChatRecordsForward.php | 22 ++--- app/Model/Chat/ChatRecordsInvite.php | 16 ---- app/Model/Emoticon.php | 16 ---- app/Model/EmoticonDetail.php | 16 ---- app/Model/FileSplitUpload.php | 16 ---- app/Model/Group/Group.php | 23 +---- app/Model/Group/GroupMember.php | 19 ----- app/Model/Group/GroupNotice.php | 16 ---- app/Model/User.php | 25 ++---- app/Model/UsersChatList.php | 20 ----- app/Model/UsersEmoticon.php | 18 ---- app/Model/UsersFriend.php | 19 ----- app/Model/UsersFriendsApply.php | 16 ---- app/Process/AsyncQueueConsumer.php | 1 + app/Service/ArticleService.php | 84 ++++++------------- app/Service/ContactsService.php | 18 +--- app/Service/EmoticonService.php | 38 ++++----- app/Service/GroupService.php | 6 -- app/Service/MailerService.php | 11 +-- app/Service/MessageHandleService.php | 5 +- app/Service/SmsCodeService.php | 22 ++--- app/Service/SocketClientService.php | 9 +- app/Service/SocketRoomService.php | 7 -- app/Service/SplitUploadService.php | 7 +- app/Service/TalkService.php | 37 +++----- app/Service/UploadService.php | 6 +- app/Service/UserService.php | 19 ++--- app/Support/Mail.php | 25 +++--- app/Support/MailerTemplate.php | 3 - app/Support/Packet.php | 9 +- app/Support/RedisLock.php | 3 - app/Support/Response.php | 10 +-- app/Support/SendEmailCode.php | 13 +-- app/Support/SocketIOParser.php | 2 - app/Traits/PagingTrait.php | 2 - app/helper.php | 35 ++------ config/autoload/server.php | 2 +- 79 files changed, 310 insertions(+), 881 deletions(-) diff --git a/app/Amqp/Consumer/ChatMessageConsumer.php b/app/Amqp/Consumer/ChatMessageConsumer.php index 88a90b1..59892af 100644 --- a/app/Amqp/Consumer/ChatMessageConsumer.php +++ b/app/Amqp/Consumer/ChatMessageConsumer.php @@ -1,9 +1,7 @@ $this->uuid(),// 自定义消息ID + 'uuid' => $this->uuid(), 'event' => $event, 'data' => $data, 'options' => $options diff --git a/app/Bootstrap/ServerStart.php b/app/Bootstrap/ServerStart.php index 7d6d9f2..a17eeaa 100644 --- a/app/Bootstrap/ServerStart.php +++ b/app/Bootstrap/ServerStart.php @@ -1,8 +1,6 @@ - * @link https://github.com/gzydong/hyperf-chat - */ namespace App\Constants; /** * HTTP 响应状态码枚举 * - * Class ResponseCode - * * @package App\Constants */ class ResponseCode diff --git a/app/Constants/SocketConstants.php b/app/Constants/SocketConstants.php index 17fe9f3..6f312f7 100644 --- a/app/Constants/SocketConstants.php +++ b/app/Constants/SocketConstants.php @@ -1,22 +1,10 @@ - * @link https://github.com/gzydong/hyperf-chat - */ namespace App\Constants; /** * WebSocket 消息事件枚举 * - * Class SocketConstants - * * @package App\Constants */ class SocketConstants diff --git a/app/Controller/AbstractController.php b/app/Controller/AbstractController.php index 9ef50b0..29c475f 100644 --- a/app/Controller/AbstractController.php +++ b/app/Controller/AbstractController.php @@ -1,9 +1,7 @@ delete(); + + var_dump($res); + $user = $this->request->input('user', 'Hyperf'); $method = $this->request->getMethod(); diff --git a/app/Controller/WebSocketController.php b/app/Controller/WebSocketController.php index 5121294..3f1d0ab 100644 --- a/app/Controller/WebSocketController.php +++ b/app/Controller/WebSocketController.php @@ -1,9 +1,7 @@ 'integer', 'user_id' => 'integer', diff --git a/app/Model/Article/ArticleAnnex.php b/app/Model/Article/ArticleAnnex.php index 67ec149..b0ffa41 100644 --- a/app/Model/Article/ArticleAnnex.php +++ b/app/Model/Article/ArticleAnnex.php @@ -19,23 +19,12 @@ use App\Model\BaseModel; * @property integer $status 文件状态 * @property string $created_at 上传时间 * @property string $deleted_at 删除时间 - * * @package App\Model\Article */ class ArticleAnnex extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'article_annex'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'user_id', 'article_id', @@ -48,11 +37,6 @@ class ArticleAnnex extends BaseModel 'deleted_at' ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'user_id' => 'integer', diff --git a/app/Model/Article/ArticleClass.php b/app/Model/Article/ArticleClass.php index f69ae87..9ea0e88 100644 --- a/app/Model/Article/ArticleClass.php +++ b/app/Model/Article/ArticleClass.php @@ -15,23 +15,12 @@ use App\Model\BaseModel; * @property integer $sort 排序[值越小越靠前] * @property integer $is_default 默认分类[1:是;0:不是] * @property string $created_at 创建时间 - * * @package App\Model\Article */ class ArticleClass extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'article_class'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'user_id', 'class_name', @@ -40,11 +29,6 @@ class ArticleClass extends BaseModel 'created_at', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'user_id' => 'integer', diff --git a/app/Model/Article/ArticleDetail.php b/app/Model/Article/ArticleDetail.php index 30d9d61..30bab71 100644 --- a/app/Model/Article/ArticleDetail.php +++ b/app/Model/Article/ArticleDetail.php @@ -13,34 +13,18 @@ use App\Model\BaseModel; * @property integer $article_id 笔记ID * @property string $md_content 笔记MD格式内容 * @property string $content 笔记html格式内容 - * * @package App\Model\Article */ class ArticleDetail extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'article_detail'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'article_id', 'md_content', 'content', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'article_id' => 'integer' diff --git a/app/Model/Article/ArticleTag.php b/app/Model/Article/ArticleTag.php index 21bdcae..0b56ad7 100644 --- a/app/Model/Article/ArticleTag.php +++ b/app/Model/Article/ArticleTag.php @@ -7,6 +7,8 @@ namespace App\Model\Article; use App\Model\BaseModel; /** + * 笔记标签数据表模型 + * * @property integer $id 标签ID * @property integer $user_id 用户ID * @property string $tag_name 标签名称 @@ -15,27 +17,15 @@ use App\Model\BaseModel; */ class ArticleTag extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'article_tags'; - /** - * The attributes that are mass assignable. - * - * @var array - */ 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 = [ 'id' => 'integer', 'user_id' => 'integer', diff --git a/app/Model/Chat/ChatRecord.php b/app/Model/Chat/ChatRecord.php index 501dbc9..d802408 100644 --- a/app/Model/Chat/ChatRecord.php +++ b/app/Model/Chat/ChatRecord.php @@ -17,23 +17,12 @@ use App\Model\BaseModel; * @property string $content 文本消息 * @property int $is_revoke 是否撤回消息[0:否;1:是] * @property string $created_at 创建时间 - * * @package App\Model\Chat */ class ChatRecord extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'chat_records'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'source', 'msg_type', @@ -44,11 +33,6 @@ class ChatRecord extends BaseModel 'created_at', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'source' => 'integer', diff --git a/app/Model/Chat/ChatRecordsCode.php b/app/Model/Chat/ChatRecordsCode.php index 0f22ddc..e9b0d25 100644 --- a/app/Model/Chat/ChatRecordsCode.php +++ b/app/Model/Chat/ChatRecordsCode.php @@ -15,23 +15,12 @@ use App\Model\BaseModel; * @property string $code_lang 代码语言 * @property string $code 代码详情 * @property string $created_at 创建时间 - * * @package App\Model\Chat */ class ChatRecordsCode extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'chat_records_code'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'record_id', 'user_id', @@ -40,11 +29,6 @@ class ChatRecordsCode extends BaseModel 'created_at' ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'record_id' => 'integer', diff --git a/app/Model/Chat/ChatRecordsDelete.php b/app/Model/Chat/ChatRecordsDelete.php index d18fa34..09e701d 100644 --- a/app/Model/Chat/ChatRecordsDelete.php +++ b/app/Model/Chat/ChatRecordsDelete.php @@ -13,30 +13,14 @@ use App\Model\BaseModel; * @property int $record_id 聊天记录ID * @property int $user_id 用户ID * @property string $created_at 删除时间 - * * @package App\Model\Chat */ class ChatRecordsDelete extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'chat_records_delete'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = []; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'record_id' => 'integer', diff --git a/app/Model/Chat/ChatRecordsFile.php b/app/Model/Chat/ChatRecordsFile.php index 011cce0..58e3325 100644 --- a/app/Model/Chat/ChatRecordsFile.php +++ b/app/Model/Chat/ChatRecordsFile.php @@ -21,23 +21,12 @@ use App\Model\BaseModel; * @property string $save_dir 文件保存路径 * @property int $is_delete 是否已删除 * @property string $created_at 上传时间 - * * @package App\Model\Chat */ class ChatRecordsFile extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'chat_records_file'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'record_id', 'user_id', @@ -52,11 +41,6 @@ class ChatRecordsFile extends BaseModel 'created_at' ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'record_id' => 'integer', diff --git a/app/Model/Chat/ChatRecordsForward.php b/app/Model/Chat/ChatRecordsForward.php index 67d019f..ce5a149 100644 --- a/app/Model/Chat/ChatRecordsForward.php +++ b/app/Model/Chat/ChatRecordsForward.php @@ -15,32 +15,20 @@ use App\Model\BaseModel; * @property string $records_id 聊天记录ID,多个用英文','拼接 * @property string $text 缓存信息 * @property int $created_at 转发时间 - * * @package App\Model\Chat */ class ChatRecordsForward extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'chat_records_forward'; - /** - * The attributes that are mass assignable. - * - * @var array - */ 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 = [ 'id' => 'integer', 'record_id' => 'integer', diff --git a/app/Model/Chat/ChatRecordsInvite.php b/app/Model/Chat/ChatRecordsInvite.php index 9631b85..77119bf 100644 --- a/app/Model/Chat/ChatRecordsInvite.php +++ b/app/Model/Chat/ChatRecordsInvite.php @@ -14,23 +14,12 @@ use App\Model\BaseModel; * @property int $type 通知类型[1:入群通知;2:自动退群;3:管理员踢群] * @property int $operate_user_id 操作人的用户ID[邀请人OR管理员ID] * @property string $user_ids 用户ID(多个用 , 分割) - * * @package App\Model\Chat */ class ChatRecordsInvite extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'chat_records_invite'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'record_id', 'type', @@ -38,11 +27,6 @@ class ChatRecordsInvite extends BaseModel 'user_ids', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'record_id' => 'integer', diff --git a/app/Model/Emoticon.php b/app/Model/Emoticon.php index 75f7eea..2492411 100644 --- a/app/Model/Emoticon.php +++ b/app/Model/Emoticon.php @@ -11,30 +11,14 @@ namespace App\Model; * @property string $name 分组名称 * @property string $url 默认表情 * @property string $created_at 创建时间 - * * @package App\Model */ class Emoticon extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'emoticon'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = []; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'created_at' => 'datetime' diff --git a/app/Model/EmoticonDetail.php b/app/Model/EmoticonDetail.php index 0eb242e..ca16666 100644 --- a/app/Model/EmoticonDetail.php +++ b/app/Model/EmoticonDetail.php @@ -15,23 +15,12 @@ namespace App\Model; * @property string $file_suffix 文件前缀 * @property int $file_size 表情包文件大小 * @property string $created_at 创建时间 - * * @package App\Model */ class EmoticonDetail extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'emoticon_details'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'emoticon_id', 'user_id', @@ -42,11 +31,6 @@ class EmoticonDetail extends BaseModel 'created_at', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'emoticon_id' => 'integer', diff --git a/app/Model/FileSplitUpload.php b/app/Model/FileSplitUpload.php index fc22431..66bd92f 100644 --- a/app/Model/FileSplitUpload.php +++ b/app/Model/FileSplitUpload.php @@ -19,23 +19,12 @@ namespace App\Model; * @property int $file_size 临时文件大小 * @property int $is_delete 文件是否已被删除[1:是;0:否;] * @property int $upload_at 文件上传时间 - * * @package App\Model */ class FileSplitUpload extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'file_split_upload'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'file_type', 'user_id', @@ -50,11 +39,6 @@ class FileSplitUpload extends BaseModel 'upload_at' ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'file_type' => 'integer', diff --git a/app/Model/Group/Group.php b/app/Model/Group/Group.php index 5ace5a9..71eea82 100644 --- a/app/Model/Group/Group.php +++ b/app/Model/Group/Group.php @@ -19,26 +19,17 @@ use App\Model\BaseModel; * @property integer $is_dismiss 是否已解散[0:否;1:是;] * @property string $created_at 创建时间 * @property string $dismissed_at 解散时间 - * * @package App\Model\Group */ class Group extends BaseModel { - // 最大成员数量 + /** + * 最大成员数量 + */ const MAX_MEMBER_NUM = 200; - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'group'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'creator_id', 'group_name', @@ -52,11 +43,6 @@ class Group extends BaseModel 'dismissed_at', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'creator_id' => 'integer', 'max_num' => 'integer', @@ -80,7 +66,6 @@ class Group extends BaseModel * @param int $user_id 用户ID * @param int $group_id 群ID * @param int|array $leader 管理员类型[0:普通成员;1:管理员;2:群主;] - * * @return bool */ public static function isManager(int $user_id, int $group_id, $leader = 2) @@ -92,7 +77,6 @@ class Group extends BaseModel * 判断群组是否已解散 * * @param int $group_id 群ID - * * @return bool */ public static function isDismiss(int $group_id) @@ -105,7 +89,6 @@ class Group extends BaseModel * * @param int $group_id 群ID * @param int $user_id 用户ID - * * @return bool */ public static function isMember(int $group_id, int $user_id) diff --git a/app/Model/Group/GroupMember.php b/app/Model/Group/GroupMember.php index a05441a..15f4333 100644 --- a/app/Model/Group/GroupMember.php +++ b/app/Model/Group/GroupMember.php @@ -17,23 +17,12 @@ use App\Model\BaseModel; * @property string $user_card 群名片 * @property string $created_at 入群时间 * @property string $deleted_at 退群时间 - * * @package App\Model\Group */ class GroupMember extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'group_member'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'group_id', 'user_id', @@ -45,11 +34,6 @@ class GroupMember extends BaseModel 'deleted_at', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'group_id' => 'integer', 'user_id' => 'integer', @@ -64,7 +48,6 @@ class GroupMember extends BaseModel * 获取聊天群成员ID * * @param int $group_id 群聊ID - * * @return array */ public static function getGroupMemberIds(int $group_id) @@ -77,7 +60,6 @@ class GroupMember extends BaseModel * * @param int $user_id 用户ID * @param int $group_id 群ID - * * @return string */ public static function visitCard(int $user_id, int $group_id) @@ -89,7 +71,6 @@ class GroupMember extends BaseModel * 获取用户的所有群ID * * @param int $user_id 用户ID - * * @return array */ public static function getUserGroupIds(int $user_id) diff --git a/app/Model/Group/GroupNotice.php b/app/Model/Group/GroupNotice.php index 5371042..e8ef94b 100644 --- a/app/Model/Group/GroupNotice.php +++ b/app/Model/Group/GroupNotice.php @@ -20,23 +20,12 @@ use App\Model\BaseModel; * @property string $created_at 创建时间 * @property string $updated_at 更新时间 * @property string $deleted_at 删除时间 - * * @package App\Model\Group */ class GroupNotice extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'group_notice'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'group_id', 'creator_id', @@ -51,11 +40,6 @@ class GroupNotice extends BaseModel 'deleted_at' ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'group_id' => 'integer', 'creator_id' => 'integer', diff --git a/app/Model/User.php b/app/Model/User.php index 25a2245..3671de1 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -14,31 +14,22 @@ namespace App\Model; * @property string $avatar 头像 * @property integer $gender 性别 * @property integer $created_at 注册时间 - * * @package App\Model */ class User extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'users'; - /** - * The attributes that are mass assignable. - * - * @var array - */ 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 = []; } diff --git a/app/Model/UsersChatList.php b/app/Model/UsersChatList.php index 78dcec6..4b30aa2 100644 --- a/app/Model/UsersChatList.php +++ b/app/Model/UsersChatList.php @@ -17,23 +17,12 @@ namespace App\Model; * @property int $not_disturb 是否消息免打扰 * @property string $created_at 创建时间 * @property string $updated_at 更新时间 - * * @package App\Model */ class UsersChatList extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'users_chat_list'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'type', 'uid', @@ -46,11 +35,6 @@ class UsersChatList extends BaseModel 'updated_at' ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'type' => 'integer', @@ -70,7 +54,6 @@ class UsersChatList extends BaseModel * @param int $user_id 用户ID * @param int $receive_id 接收者ID * @param int $type 创建类型 1:私聊 2:群聊 - * * @return array */ public static function addItem(int $user_id, int $receive_id, int $type) @@ -115,7 +98,6 @@ class UsersChatList extends BaseModel * @param int $user_id 用户ID * @param int $list_id 对话列表ID * @param bool $is_top 是否置顶(true:是 false:否) - * * @return bool */ public static function topItem(int $user_id, int $list_id, $is_top = true) @@ -132,7 +114,6 @@ class UsersChatList extends BaseModel * @param int $user_id 用户ID * @param int $id 聊天列表ID、好友ID或群聊ID * @param int $type ID类型 (1:聊天列表ID 2:好友ID 3:群聊ID) - * * @return bool */ public static function delItem(int $user_id, int $id, $type = 1) @@ -154,7 +135,6 @@ class UsersChatList extends BaseModel * @param int $receive_id 接收者ID * @param int $type 接收者类型(1:好友 2:群组) * @param int $not_disturb 是否免打扰 - * * @return boolean */ public static function notDisturbItem(int $user_id, int $receive_id, int $type, int $not_disturb) diff --git a/app/Model/UsersEmoticon.php b/app/Model/UsersEmoticon.php index 138c2f6..3a9747c 100644 --- a/app/Model/UsersEmoticon.php +++ b/app/Model/UsersEmoticon.php @@ -10,42 +10,24 @@ namespace App\Model; * @property int $id 收藏ID * @property int $user_id 用户ID * @property string $emoticon_ids 表情包ID,多个用英文逗号拼接 - * * @package App\Model */ class UsersEmoticon extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'users_emoticon'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'user_id', 'emoticon_ids' ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'user_id' => 'integer' ]; /** - * * @param string $value - * * @return string */ public function getEmoticonIdsAttribute($value) diff --git a/app/Model/UsersFriend.php b/app/Model/UsersFriend.php index 1cf6e27..7767368 100644 --- a/app/Model/UsersFriend.php +++ b/app/Model/UsersFriend.php @@ -18,23 +18,12 @@ use Hyperf\DbConnection\Db; * @property int $status 好友状态[1:好友状态;0:已解除好友关系] * @property string $agree_time 成为好友时间 * @property string $created_at 创建时间 - * * @package App\Model */ class UsersFriend extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'users_friends'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'user1', 'user2', @@ -46,11 +35,6 @@ class UsersFriend extends BaseModel 'created_at' ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'user1' => 'integer', @@ -64,7 +48,6 @@ class UsersFriend extends BaseModel * 获取用户所有好友 * * @param int $uid 用户ID - * * @return mixed */ public static function getUserFriends(int $uid) @@ -95,7 +78,6 @@ SQL; * @param int $user_id1 用户1 * @param int $user_id2 用户2 * @param bool $cache 是否读取缓存 - * * @return bool */ public static function isFriend(int $user_id1, int $user_id2, bool $cache = false) @@ -122,7 +104,6 @@ SQL; * 获取指定用户的所有朋友的用户ID * * @param int $user_id 指定用户ID - * * @return array */ public static function getFriendIds(int $user_id) diff --git a/app/Model/UsersFriendsApply.php b/app/Model/UsersFriendsApply.php index 813a898..9534750 100644 --- a/app/Model/UsersFriendsApply.php +++ b/app/Model/UsersFriendsApply.php @@ -14,23 +14,12 @@ namespace App\Model; * @property string $remarks 备注说明 * @property string $created_at 创建时间 * @property string $updated_at 更新时间 - * * @package App\Model */ class UsersFriendsApply extends BaseModel { - /** - * The table associated with the model. - * - * @var string - */ protected $table = 'users_friends_apply'; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'user_id', 'friend_id', @@ -40,11 +29,6 @@ class UsersFriendsApply extends BaseModel 'updated_at' ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'id' => 'integer', 'user_id' => 'integer', diff --git a/app/Process/AsyncQueueConsumer.php b/app/Process/AsyncQueueConsumer.php index b2f0318..34a149a 100644 --- a/app/Process/AsyncQueueConsumer.php +++ b/app/Process/AsyncQueueConsumer.php @@ -9,6 +9,7 @@ declare(strict_types=1); * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace App\Process; use Hyperf\AsyncQueue\Process\ConsumerProcess; diff --git a/app/Service/ArticleService.php b/app/Service/ArticleService.php index f033ebf..7d4178f 100644 --- a/app/Service/ArticleService.php +++ b/app/Service/ArticleService.php @@ -24,7 +24,6 @@ class ArticleService extends BaseService * 获取用户文章分类列表 * * @param int $user_id 用户ID - * * @return array */ public function getUserClass(int $user_id) @@ -43,15 +42,14 @@ class ArticleService extends BaseService * 获取用户文章标签列表 * * @param int $user_id 用户ID - * - * @return mixed + * @return array */ 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(); - array_walk($items, function ($item) use ($user_id) { - $item['count'] = (int)Article::where('user_id', $user_id)->whereRaw("FIND_IN_SET({$item['id']},tags_id)")->count(); - }); + foreach ($items as $k => $item) { + $items[$k]['count'] = (int)Article::where('user_id', $user_id)->whereRaw("FIND_IN_SET({$item['id']},tags_id)")->count(); + } return $items; } @@ -63,7 +61,6 @@ class ArticleService extends BaseService * @param int $page 分页 * @param int $page_size 分页大小 * @param array $params 查询参数 - * * @return array */ public function getUserArticleList(int $user_id, int $page, int $page_size, $params = []) @@ -117,7 +114,6 @@ class ArticleService extends BaseService * * @param int $article_id 文章ID * @param int $user_id 用户ID - * * @return array */ public function getArticleDetail(int $article_id, $user_id = 0) @@ -158,7 +154,6 @@ class ArticleService extends BaseService * * @param int $user_id 用户ID * @param int $article_id 笔记ID - * * @return mixed */ public function findArticleAnnexAll(int $user_id, int $article_id) @@ -176,7 +171,6 @@ class ArticleService extends BaseService * @param int $uid 用户ID * @param int|string $class_id 分类ID * @param string $class_name 分类名 - * * @return bool|int */ public function editArticleClass(int $uid, $class_id, string $class_name) @@ -203,18 +197,14 @@ class ArticleService extends BaseService ArticleClass::where('id', $val['id'])->update(['sort' => $val['sort']]); } - $insRes = ArticleClass::create(['user_id' => $uid, 'class_name' => $class_name, 'sort' => 1, 'created_at' => time()]); - if (!$insRes) { - throw new Exception('笔记分类添加失败..,.'); - } + $res = ArticleClass::create(['user_id' => $uid, 'class_name' => $class_name, 'sort' => 1, 'created_at' => time()]); Db::commit(); + return $res->id; } catch (Exception $e) { Db::rollBack(); return false; } - - return $insRes->id; } /** @@ -222,7 +212,6 @@ class ArticleService extends BaseService * * @param int $uid 用户ID * @param int $class_id 分类ID - * * @return bool */ public function delArticleClass(int $uid, int $class_id) @@ -245,7 +234,6 @@ class ArticleService extends BaseService * @param int $user_id 用户ID * @param int $class_id 文集分类ID * @param int $sort_type 排序方式 - * * @return bool */ public function articleClassSort(int $user_id, int $class_id, int $sort_type) @@ -254,7 +242,7 @@ class ArticleService extends BaseService return false; } - //向下排序 + // 向下排序 if ($sort_type == 1) { $maxSort = ArticleClass::where('user_id', $user_id)->max('sort'); if ($maxSort == $info->sort) { @@ -310,7 +298,6 @@ class ArticleService extends BaseService * @param int $user_id 用户ID * @param int $class_id 笔记分类ID * @param int $to_class_id 笔记分类ID - * * @return bool */ public function mergeArticleClass(int $user_id, int $class_id, int $to_class_id) @@ -320,7 +307,7 @@ class ArticleService extends BaseService 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 ]); } @@ -331,7 +318,6 @@ class ArticleService extends BaseService * @param int $uid 用户ID * @param int $tag_id 标签ID * @param string $tag_name 标签名 - * * @return bool|int */ public function editArticleTag(int $uid, int $tag_id, string $tag_name) @@ -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; } else { - //判断新添加的标签名是否存在 - if ($id) { - return false; - } + // 判断新添加的标签名是否存在 + if ($id) return false; $insRes = ArticleTag::create(['user_id' => $uid, 'tag_name' => $tag_name, 'sort' => 1, 'created_at' => time()]); if (!$insRes) { @@ -363,7 +347,6 @@ class ArticleService extends BaseService * * @param int $uid 用户ID * @param int $tag_id 标签ID - * * @return bool */ 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(); - 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 (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 $article_id 文章ID * @param array $data 文章数据 - * * @return bool */ public function editArticle(int $user_id, int $article_id, $data = []) { 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; } @@ -452,7 +436,6 @@ class ArticleService extends BaseService * @param int $user_id 用户ID * @param int $article_id 笔记ID * @param int $status 笔记状态 1:正常 2:已删除 - * * @return bool */ public function updateArticleStatus(int $user_id, int $article_id, int $status) @@ -471,12 +454,11 @@ class ArticleService extends BaseService * @param int $user_id 用户ID * @param int $article_id 笔记ID * @param int $class_id 笔记分类ID - * * @return bool */ public function moveArticle(int $user_id, int $article_id, int $class_id) { - 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 $article_id 笔记ID * @param int $type 1:标记星号 2:取消星号标记 - * * @return bool */ 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 ]); } @@ -501,7 +482,6 @@ class ArticleService extends BaseService * @param int $uid 用户ID * @param int $article_id 笔记ID * @param array $tags 关联标签ID - * * @return bool */ public function updateArticleTag(int $uid, int $article_id, array $tags) @@ -514,7 +494,6 @@ class ArticleService extends BaseService * * @param int $uid 用户ID * @param int $article_id 笔记ID - * * @return bool|int|mixed|null * @throws Exception */ @@ -551,9 +530,9 @@ class ArticleService extends BaseService } // 从磁盘中永久删除文件附件 - foreach ($annex_files as $item) { - //Storage::disk('uploads')->delete($item['save_dir']); - } + //foreach ($annex_files as $item) { + //Storage::disk('uploads')->delete($item['save_dir']); + //} return true; } @@ -564,7 +543,6 @@ class ArticleService extends BaseService * @param int $user_id 用户ID * @param int $annex_id 附件ID * @param int $status 附件状态 1:正常 2:已删除 - * * @return bool */ public function updateArticleAnnexStatus(int $user_id, int $annex_id, int $status) @@ -574,14 +552,13 @@ class ArticleService extends BaseService $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 - * * @return array */ public function recoverAnnexList(int $uid) @@ -603,15 +580,7 @@ class ArticleService extends BaseService * * @param int $uid 用户ID * @param int $annex_id 笔记附件ID - * - * @return bool|int|mixed|null - */ - - /** - * @param int $uid - * @param int $annex_id - * - * @return bool|int|mixed|null + * @return mixed * @throws Exception */ public function foreverDelAnnex(int $uid, int $annex_id) @@ -622,9 +591,9 @@ class ArticleService extends BaseService } // 将文件从磁盘中删除 -// if (!Storage::disk('uploads')->delete($info->save_dir)) { -// return false; -// } + //if (!Storage::disk('uploads')->delete($info->save_dir)) { + // return false; + //} return $info->delete(); } @@ -635,7 +604,6 @@ class ArticleService extends BaseService * @param int $user_id 用户id * @param int $article_id 笔记ID * @param array $annex 笔记附件信息 - * * @return bool */ public function insertArticleAnnex(int $user_id, int $article_id, array $annex) diff --git a/app/Service/ContactsService.php b/app/Service/ContactsService.php index ea6b96b..7a06e0f 100644 --- a/app/Service/ContactsService.php +++ b/app/Service/ContactsService.php @@ -1,8 +1,6 @@ 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 $friend_id 好友ID - * * @return bool */ public function deleteContact(int $user_id, int $friend_id): bool @@ -126,7 +121,6 @@ SQL; * @param int $user_id 用户ID * @param int $apply_id 联系人申请ID * @param string $remarks 联系人备注名称 - * * @return bool */ public function acceptInvitation(int $user_id, int $apply_id, string $remarks = ''): bool @@ -189,12 +183,11 @@ SQL; * @param int $user_id 用户ID * @param int $apply_id 联系人申请ID * @param string $remarks 拒绝申请备注信息 - * * @return bool */ public function declineInvitation(int $user_id, int $apply_id, string $remarks = ''): bool { - $result = UsersFriendsApply::where([ + return (bool)UsersFriendsApply::where([ ['id', '=', $apply_id], ['user_id', '=', $user_id], ['status', '=', 2], @@ -203,8 +196,6 @@ SQL; 'remarks' => $remarks, '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 $friend_id 朋友ID * @param string $remarks 好友备注名称 - * * @return bool */ public function editContactRemark(int $user_id, int $friend_id, string $remarks): bool @@ -233,7 +223,6 @@ SQL; * 搜索联系人 * * @param string $mobile 用户手机号/登录账号 - * * @return array */ public function findContact(string $mobile): array @@ -249,7 +238,6 @@ SQL; * @param int $user_id 用户ID * @param int $page 当前分页 * @param int $page_size 分页大小 - * * @return array */ public function getContactApplyRecords(int $user_id, $page = 1, $page_size = 30): array @@ -283,8 +271,8 @@ SQL; * * @param int $user_id 用户ID * @param int $apply_id 联系人好友申请ID - * * @return bool + * @throws Exception */ public function delContactApplyRecord(int $user_id, int $apply_id): bool { diff --git a/app/Service/EmoticonService.php b/app/Service/EmoticonService.php index bd90029..66a6588 100644 --- a/app/Service/EmoticonService.php +++ b/app/Service/EmoticonService.php @@ -10,7 +10,6 @@ use App\Model\UsersEmoticon; /** * 表情服务层 - * * Class EmoticonService * * @package App\Services @@ -22,14 +21,13 @@ class EmoticonService extends BaseService * * @param int $user_id 用户ID * @param int $emoticon_id 表情包ID - * - * @return mixed + * @return bool */ public function installSysEmoticon(int $user_id, int $emoticon_id) { $info = UsersEmoticon::select(['id', 'user_id', 'emoticon_ids'])->where('user_id', $user_id)->first(); 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; @@ -38,9 +36,10 @@ class EmoticonService extends BaseService } $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) - ]) ? true : false; + ]); } /** @@ -48,7 +47,6 @@ class EmoticonService extends BaseService * * @param int $user_id 用户ID * @param int $emoticon_id 表情包ID - * * @return bool */ public function removeSysEmoticon(int $user_id, int $emoticon_id) @@ -60,25 +58,22 @@ class EmoticonService extends BaseService $emoticon_ids = $info->emoticon_ids; foreach ($emoticon_ids as $k => $id) { - if ($id == $emoticon_id) { - unset($emoticon_ids[$k]); - } + if ($id == $emoticon_id) unset($emoticon_ids[$k]); } if (count($info->emoticon_ids) == count($emoticon_ids)) { return false; } - return UsersEmoticon::where('user_id', $user_id)->update([ + return (bool)UsersEmoticon::where('user_id', $user_id)->update([ 'emoticon_ids' => implode(',', $emoticon_ids) - ]) ? true : false; + ]); } /** * 获取用户安装的表情ID * * @param int $user_id 用户ID - * * @return array */ public function getInstallIds(int $user_id) @@ -92,7 +87,6 @@ class EmoticonService extends BaseService * * @param int $user_id 用户ID * @param int $record_id 聊天消息ID - * * @return array */ public function collect(int $user_id, int $record_id) @@ -148,8 +142,8 @@ class EmoticonService extends BaseService * * @param int $user_id 用户ID * @param array $ids 表情包详情ID - * - * @return + * @return bool + * @throws \Exception */ public function deleteCollect(int $user_id, array $ids) { @@ -160,17 +154,15 @@ class EmoticonService extends BaseService * 获取表情包列表 * * @param array $where - * - * @return mixed + * @return array */ public function getDetailsAll(array $where = []) { - $list = EmoticonDetail::where($where)->get(['id as media_id', 'url as src'])->toArray(); - - foreach ($list as $k => $value) { - $list[$k]['src'] = get_media_url($value['src']); + $items = EmoticonDetail::where($where)->get(['id as media_id', 'url as src'])->toArray(); + foreach ($items as $k => $item) { + $items[$k]['src'] = get_media_url($item['src']); } - return $list; + return $items; } } diff --git a/app/Service/GroupService.php b/app/Service/GroupService.php index 118fee5..b8ba705 100644 --- a/app/Service/GroupService.php +++ b/app/Service/GroupService.php @@ -23,7 +23,6 @@ class GroupService extends BaseService * 获取用户所在的群聊 * * @param int $user_id 用户ID - * * @return array */ public function getGroups(int $user_id): array @@ -60,7 +59,6 @@ class GroupService extends BaseService * @param int $user_id 用户ID * @param array $group_info 群聊名称 * @param array $friend_ids 好友的用户ID - * * @return array */ public function create(int $user_id, array $group_info, $friend_ids = []) @@ -146,7 +144,6 @@ class GroupService extends BaseService * * @param int $group_id 群ID * @param int $user_id 用户ID - * * @return bool */ public function dismiss(int $group_id, int $user_id) @@ -177,7 +174,6 @@ class GroupService extends BaseService * @param int $user_id 用户ID * @param int $group_id 聊天群ID * @param array $friend_ids 被邀请的用户ID - * * @return array */ public function invite(int $user_id, int $group_id, $friend_ids = []) @@ -282,7 +278,6 @@ class GroupService extends BaseService * * @param int $user_id 用户ID * @param int $group_id 群组ID - * * @return array */ public function quit(int $user_id, int $group_id) @@ -337,7 +332,6 @@ class GroupService extends BaseService * @param int $group_id 群ID * @param int $user_id 操作用户ID * @param array $member_ids 群成员ID - * * @return array */ public function removeMember(int $group_id, int $user_id, array $member_ids) diff --git a/app/Service/MailerService.php b/app/Service/MailerService.php index 8440ab3..b9055a2 100644 --- a/app/Service/MailerService.php +++ b/app/Service/MailerService.php @@ -25,7 +25,6 @@ class MailerService * @param string $email 邮箱 * @param string $subject 标题 * @param string $template 对应邮件模板 - * * @return bool */ public function send($email, $subject, $template) @@ -43,7 +42,6 @@ class MailerService * @param string $email 邮箱 * @param string $subject 标题 * @param string $template 对应邮件模板 - * * @return bool */ public function realSend($email, $subject, $template) @@ -61,7 +59,6 @@ class MailerService * @param string $address 收件人 * @param string $subject 邮件标题 * @param string $view 邮件内容 - * * @return bool * @throws Exception */ @@ -70,10 +67,10 @@ class MailerService $config = config('mail'); $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; - $mail->IsSMTP(); // 设定使用SMTP服务 - $mail->SMTPDebug = 0; // 关闭SMTP调试功能 - $mail->SMTPAuth = true; // 启用 SMTP 验证功能 - $mail->SMTPSecure = 'ssl'; // 使用安全协议 + $mail->IsSMTP(); // 设定使用SMTP服务 + $mail->SMTPDebug = 0; // 关闭SMTP调试功能 + $mail->SMTPAuth = true; // 启用 SMTP 验证功能 + $mail->SMTPSecure = 'ssl'; // 使用安全协议 $mail->Host = $config['host']; $mail->Port = $config['port']; $mail->Username = $config['username']; diff --git a/app/Service/MessageHandleService.php b/app/Service/MessageHandleService.php index 4e98cbf..9a6583f 100644 --- a/app/Service/MessageHandleService.php +++ b/app/Service/MessageHandleService.php @@ -40,8 +40,7 @@ class MessageHandleService * @param Response|Server $server * @param Frame $frame * @param array|string $data 解析后数据 - * - * @return bool|void + * @return void */ public function onTalk($server, Frame $frame, $data) { @@ -109,8 +108,6 @@ class MessageHandleService * @param Response|Server $server * @param Frame $frame * @param array|string $data 解析后数据 - * - * @return bool|void */ public function onKeyboard($server, Frame $frame, $data) { diff --git a/app/Service/SmsCodeService.php b/app/Service/SmsCodeService.php index 44059b3..bb89ccd 100644 --- a/app/Service/SmsCodeService.php +++ b/app/Service/SmsCodeService.php @@ -5,8 +5,6 @@ namespace App\Service; /** * 短信发送服务 * - * Class SmsCodeService - * * @package App\Services */ class SmsCodeService @@ -35,7 +33,6 @@ class SmsCodeService * * @param string $type 短信用途 * @param string $mobile 手机号 - * * @return string */ private function getKey(string $type, string $mobile) @@ -49,7 +46,6 @@ class SmsCodeService * @param string $type 发送类型 * @param string $mobile 手机号 * @param string $code 验证码 - * * @return bool */ public function check(string $type, string $mobile, string $code) @@ -64,7 +60,6 @@ class SmsCodeService * * @param string $usage 验证码用途 * @param string $mobile 手机号 - * * @return array|bool */ public function send(string $usage, string $mobile) @@ -103,7 +98,6 @@ class SmsCodeService * 获取缓存的验证码 * * @param string $key - * * @return mixed */ public function getCode(string $key) @@ -117,7 +111,6 @@ class SmsCodeService * @param string $key 缓存key * @param string $sms_code 验证码 * @param float|int $exp 过期时间(默认15分钟) - * * @return mixed */ public function setCode(string $key, string $sms_code, $exp = 60 * 15) @@ -130,7 +123,6 @@ class SmsCodeService * * @param string $usage 验证码用途 * @param string $mobile 手机号 - * * @return mixed */ public function delCode(string $usage, string $mobile) @@ -143,18 +135,17 @@ class SmsCodeService * * @param string $usage 验证码用途 * @param string $mobile 手机号 - * * @return array */ public function filter(string $usage, string $mobile) { // ... 省略处理 - if (false) { - return [false, [ - 'msg' => '过滤原因...', - 'data' => [] - ]]; - } + //if (false) { + // return [false, [ + // 'msg' => '过滤原因...', + // 'data' => [] + // ]]; + //} return [true, [ 'msg' => 'ok', @@ -166,7 +157,6 @@ class SmsCodeService * 判断验证码用途渠道是否注册 * * @param string $usage - * * @return bool */ public function isUsages(string $usage) diff --git a/app/Service/SocketClientService.php b/app/Service/SocketClientService.php index 5189e15..e1da813 100644 --- a/app/Service/SocketClientService.php +++ b/app/Service/SocketClientService.php @@ -42,8 +42,6 @@ class SocketClientService * @param int $fd 客户端fd * @param int $user_id 用户ID * @param string $run_id 服务运行ID(默认当前服务ID) - * - * @return mixed */ public function bindRelation(int $fd, int $user_id, $run_id = SERVER_RUN_ID) { @@ -72,12 +70,11 @@ class SocketClientService * * @param int $user_id 用户ID * @param string $run_id 服务运行ID(默认当前服务ID) - * * @return bool */ public function isOnline(int $user_id, $run_id = SERVER_RUN_ID): bool { - 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 array $run_ids 服务运行ID - * * @return bool */ public function isOnlineAll(int $user_id, array $run_ids = []) @@ -104,7 +100,6 @@ class SocketClientService * * @param int $fd 客户端ID * @param string $run_id 服务运行ID(默认当前服务ID) - * * @return int */ public function findFdUserId(int $fd, $run_id = SERVER_RUN_ID) @@ -117,7 +112,6 @@ class SocketClientService * * @param int $user_id 用户ID * @param string $run_id 服务运行ID(默认当前服务ID) - * * @return array */ public function findUserFds(int $user_id, $run_id = SERVER_RUN_ID) @@ -132,7 +126,6 @@ class SocketClientService * 获取服务ID列表 * * @param int $type 获取类型[1:正在运行;2:已超时;3:所有] - * * @return array */ public function getServerRunIdAll(int $type = 1) diff --git a/app/Service/SocketRoomService.php b/app/Service/SocketRoomService.php index be1e04f..6ed0c9b 100644 --- a/app/Service/SocketRoomService.php +++ b/app/Service/SocketRoomService.php @@ -5,8 +5,6 @@ namespace App\Service; /** * 聊天室房间服务 * - * Class SocketRoomService - * * @package App\Service */ class SocketRoomService @@ -17,7 +15,6 @@ class SocketRoomService * 获取房间名 * * @param string|integer $room 房间名 - * * @return string */ public function getRoomName($room) @@ -29,7 +26,6 @@ class SocketRoomService * 获取房间成员 * * @param string $room 房间名 - * * @return array */ public function getRoomMembers(string $room) @@ -42,7 +38,6 @@ class SocketRoomService * * @param int $usr_id 用户ID * @param string|array $room 房间名 - * * @return bool|int */ public function addRoomMember(int $usr_id, $room) @@ -55,7 +50,6 @@ class SocketRoomService * * @param string|array $room 房间名 * @param string|array $members 用户ID - * * @return int */ public function delRoomMember($room, $members) @@ -67,7 +61,6 @@ class SocketRoomService * 删除房间 * * @param string|int $room 房间名 - * * @return int */ public function delRoom($room) diff --git a/app/Service/SplitUploadService.php b/app/Service/SplitUploadService.php index 103626c..3027727 100644 --- a/app/Service/SplitUploadService.php +++ b/app/Service/SplitUploadService.php @@ -9,8 +9,6 @@ use Hyperf\HttpMessage\Upload\UploadedFile; /** * 文件拆分上传服务 * - * Class SplitUploadService - * * @package App\Service */ class SplitUploadService @@ -26,7 +24,6 @@ class SplitUploadService * @param int $user_id 用户ID * @param string $fileName 上传的文件名 * @param string $fileSize 上传文件大小 - * * @return array|bool */ public function create(int $user_id, string $fileName, string $fileSize) @@ -43,7 +40,7 @@ class SplitUploadService $data['file_size'] = $fileSize; $data['upload_at'] = time(); - //文件拆分数量 + // 文件拆分数量 $data['split_num'] = $split_num; $data['split_index'] = $split_num; @@ -58,7 +55,6 @@ class SplitUploadService * @param string $hashName 上传临时问价hash名 * @param int $split_index 当前拆分文件索引 * @param int $fileSize 文件大小 - * * @return bool */ 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 string $hash_name 上传临时问价hash名 - * * @return array|bool */ public function merge(int $user_id, string $hash_name) diff --git a/app/Service/TalkService.php b/app/Service/TalkService.php index eb4169f..fc97039 100644 --- a/app/Service/TalkService.php +++ b/app/Service/TalkService.php @@ -26,7 +26,6 @@ class TalkService extends BaseService * 获取用户的聊天列表 * * @param int $user_id 用户ID - * * @return array */ public function talks(int $user_id) @@ -51,7 +50,7 @@ class TalkService extends BaseService $socketFDService = make(SocketClientService::class); $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['type'] = $item['type']; $data['friend_id'] = $item['friend_id']; @@ -98,8 +97,6 @@ class TalkService extends BaseService return $data; }, $rows); - - return $rows; } /** @@ -127,7 +124,6 @@ class TalkService extends BaseService * 处理聊天记录信息 * * @param array $rows 聊天记录 - * * @return array */ public function handleChatRecords(array $rows) @@ -234,7 +230,6 @@ class TalkService extends BaseService * @param int $record_id 上一次查询的聊天记录ID * @param int $limit 查询数据长度 * @param array $msg_type 消息类型 - * * @return array */ public function getChatRecords(int $user_id, int $receive_id, int $source, int $record_id, $limit = 30, $msg_type = []) @@ -295,7 +290,6 @@ class TalkService extends BaseService * * @param int $user_id 用户ID * @param int $record_id 聊天记录ID - * * @return array */ public function getForwardRecords(int $user_id, int $record_id) @@ -340,7 +334,6 @@ class TalkService extends BaseService * @param int $source 消息来源 1:好友消息 2:群聊消息 * @param int $receive_id 好友ID或者群聊ID * @param array $record_ids 聊天记录ID - * * @return bool */ public function removeRecords(int $user_id, int $source, int $receive_id, array $record_ids) @@ -379,7 +372,6 @@ class TalkService extends BaseService * * @param int $user_id 用户ID * @param int $record_id 聊天记录ID - * * @return array */ public function revokeRecord(int $user_id, int $record_id) @@ -413,8 +405,8 @@ class TalkService extends BaseService * * @param int $user_id 转发的用户ID * @param int $record_id 转发消息的记录ID - * @param array $receive_ids 接受者数组 例如:[['source' => 1,'id' => 3045],['source' => 1,'id' => 3046],['source' => 1,'id' => 1658]] 二维数组 - * + * @param array $receive_ids 接受者数组 例如:[['source' => 1,'id' => 3045],['source' => 1,'id' => 3046],['source' => + * 1,'id' => 1658]] 二维数组 * @return array */ public function forwardRecords(int $user_id, int $record_id, array $receive_ids) @@ -506,8 +498,8 @@ class TalkService extends BaseService * @param int $receive_id 当前转发消息的所属者(好友ID或者群聊ID) * @param int $source 消息来源 1:好友消息 2:群聊消息 * @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 */ 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); - //验证是否有权限转发 - if ($source == 2) {//群聊消息 - //判断是否是群聊成员 + // 验证是否有权限转发 + if ($source == 2) {// 群聊消息 + // 判断是否是群聊成员 if (!Group::isMember($receive_id, $user_id)) { return false; } $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)) { return []; } @@ -544,7 +536,7 @@ class TalkService extends BaseService $result = $sqlObj->get(); - //判断消息记录是否存在 + // 判断消息记录是否存在 if (count($result) != count($records_ids)) { return []; } @@ -628,8 +620,7 @@ class TalkService extends BaseService * @param int $page 当前查询分页 * @param int $page_size 分页大小 * @param array $params 查询参数 - * - * @return mixed + * @return array */ 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 $fileInfo - * * @return bool|int */ public function createImgMessage($message, $fileInfo) @@ -719,7 +709,6 @@ class TalkService extends BaseService * * @param array $message * @param array $codeBlock - * * @return bool|int */ public function createCodeMessage(array $message, array $codeBlock) @@ -752,7 +741,6 @@ class TalkService extends BaseService * * @param array $message * @param array $emoticon - * * @return bool|int */ public function createEmoticonMessage(array $message, array $emoticon) @@ -785,7 +773,6 @@ class TalkService extends BaseService * * @param array $message * @param array $emoticon - * * @return bool|int */ public function createFileMessage(array $message, array $emoticon) diff --git a/app/Service/UploadService.php b/app/Service/UploadService.php index c220698..1c22430 100644 --- a/app/Service/UploadService.php +++ b/app/Service/UploadService.php @@ -7,8 +7,6 @@ use Hyperf\HttpMessage\Upload\UploadedFile; /** * 文件上传服务 * - * Class UploadService - * * @package App\Service */ class UploadService extends BaseService @@ -23,7 +21,7 @@ class UploadService extends BaseService * * @param string $dir 文件夹路径 */ - public function makeDirectory($dir) + public function makeDirectory(string $dir) { if (!file_exists($dir)) @mkdir($dir, 0777, true); } @@ -34,7 +32,6 @@ class UploadService extends BaseService * @param UploadedFile $file * @param string $dir 文件夹路径 * @param string $filename 文件名称 - * * @return bool|string */ 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)); if ($file->isMoved()) { - // 修改文件权限 @chmod(sprintf('%s/%s', $save_dir, $filename), 0644); } diff --git a/app/Service/UserService.php b/app/Service/UserService.php index c4adbc0..d6ef44e 100644 --- a/app/Service/UserService.php +++ b/app/Service/UserService.php @@ -16,8 +16,7 @@ class UserService extends BaseService * * @param int $user_id 用户ID * @param array $field 查询字段 - * - * @return mixed + * @return User */ public function findById(int $user_id, $field = ['*']) { @@ -29,7 +28,6 @@ class UserService extends BaseService * * @param string $mobile 手机号 * @param string $password 登录密码 - * * @return array|bool */ public function login(string $mobile, string $password) @@ -49,7 +47,6 @@ class UserService extends BaseService * 账号注册逻辑 * * @param array $data 用户数据 - * * @return bool */ public function register(array $data) @@ -71,12 +68,11 @@ class UserService extends BaseService ]); Db::commit(); + return true; } catch (\Exception $e) { Db::rollBack(); - $result = false; + return false; } - - return $result ? true : false; } /** @@ -84,12 +80,11 @@ class UserService extends BaseService * * @param string $mobile 用户手机好 * @param string $password 新密码 - * - * @return mixed + * @return bool */ 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 string $mobile 换绑手机号 - * - * @return array|bool + * @return array */ public function changeMobile(int $user_id, string $mobile) { @@ -115,7 +109,6 @@ class UserService extends BaseService * * @param int $friend_id 用户ID * @param int $me_user_id 当前登录用户的ID - * * @return array */ public function getUserCard(int $friend_id, int $me_user_id) diff --git a/app/Support/Mail.php b/app/Support/Mail.php index fbfce7c..aca917a 100644 --- a/app/Support/Mail.php +++ b/app/Support/Mail.php @@ -18,7 +18,6 @@ class Mail * @param string $email 邮箱地址 * @param string $sms_code 验证码 * @param string $title 邮件标题 - * * @return bool */ public function sendEmailCode(string $email, string $sms_code, string $title) @@ -40,24 +39,23 @@ class Mail * @param string $address * @param string $subject * @param string $view - * * @return bool * @throws \PHPMailer\PHPMailer\Exception */ private function mail(string $address, string $subject, string $view): bool { $config = config('mail'); - $mail = new PHPMailer(); //PHPMailer对象 - $mail->CharSet = 'UTF-8'; //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 - $mail->IsSMTP(); // 设定使用SMTP服务 - $mail->SMTPDebug = 0; // 关闭SMTP调试功能 - $mail->SMTPAuth = true; // 启用 SMTP 验证功能 - $mail->SMTPSecure = 'ssl'; // 使用安全协议 - $mail->Host = $config['host']; // SMTP 服务器 - $mail->Port = $config['port']; // SMTP服务器的端口号 - $mail->Username = $config['username']; // SMTP; // SMTP服务器用户名 - $mail->Password = $config['password']; // SMTP服务器密码 - $mail->SetFrom($config['from'], $config['name']); // 邮箱,昵称 + $mail = new PHPMailer(); // PHPMailer对象 + $mail->CharSet = 'UTF-8'; // 设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 + $mail->IsSMTP(); // 设定使用SMTP服务 + $mail->SMTPDebug = 0; // 关闭SMTP调试功能 + $mail->SMTPAuth = true; // 启用 SMTP 验证功能 + $mail->SMTPSecure = 'ssl'; // 使用安全协议 + $mail->Host = $config['host']; // SMTP 服务器 + $mail->Port = $config['port']; // SMTP服务器的端口号 + $mail->Username = $config['username']; // SMTP服务器用户名 + $mail->Password = $config['password']; // SMTP服务器密码 + $mail->SetFrom($config['from'], $config['name']); // 邮箱,昵称 $mail->Subject = $subject; $mail->MsgHTML($view); $mail->AddAddress($address); // 收件人 @@ -68,7 +66,6 @@ class Mail * @param string $engine * @param $template * @param array $params - * * @return string */ private function view(string $engine, $template, $params = []): string diff --git a/app/Support/MailerTemplate.php b/app/Support/MailerTemplate.php index 6c3a4ec..cd34875 100644 --- a/app/Support/MailerTemplate.php +++ b/app/Support/MailerTemplate.php @@ -4,7 +4,6 @@ namespace App\Support; /** * 邮件视图模板 - * Class MailerViewTemplate * * @package App\Support */ @@ -16,7 +15,6 @@ class MailerTemplate * @param string $engine 模板引擎 * @param string $template 模板名称 * @param array $params 模板参数 - * * @return string */ public function view(string $engine, string $template, $params = []): string @@ -29,7 +27,6 @@ class MailerTemplate * * @param string $sms_code 验证码 * @param array $params 模板参数 - * * @return string */ public function emailCode(string $sms_code, array $params = []) diff --git a/app/Support/Packet.php b/app/Support/Packet.php index c990245..5b94b09 100644 --- a/app/Support/Packet.php +++ b/app/Support/Packet.php @@ -107,7 +107,6 @@ class Packet * Get socket packet type of a raw payload. * * @param string $packet - * * @return int|null */ public static function getSocketType(string $packet) @@ -125,13 +124,12 @@ class Packet * Get data packet from a raw payload. * * @param string $packet - * * @return array|null */ public static function getPayload(string $packet) { $packet = trim($packet); - $start = strpos($packet, '['); + $start = strpos($packet, '['); if ($start === false || substr($packet, -1) !== ']') { return null; @@ -146,16 +144,15 @@ class Packet return [ 'event' => $data[0], - 'data' => $data[1] ?? null, + 'data' => $data[1] ?? null, ]; } /** * Return if a socket packet belongs to specific type. * - * @param $packet + * @param $packet * @param string $typeName - * * @return bool */ public static function isSocketType($packet, string $typeName) diff --git a/app/Support/RedisLock.php b/app/Support/RedisLock.php index e1c5844..c80fa10 100644 --- a/app/Support/RedisLock.php +++ b/app/Support/RedisLock.php @@ -35,7 +35,6 @@ class RedisLock * @param integer $lockSecond 锁定时间 单位(秒) * @param integer $timeout 取锁超时时间。单位(秒)。等于0,如果当前锁被占用,则立即返回失败。如果大于0,则反复尝试获取锁直到达到该超时时间。 * @param integer|float $sleep 取锁间隔时间 单位(秒)。当锁为占用状态时。每隔多久尝试去取锁。默认 0.1 秒一次取锁。 - * * @return bool * @throws \Exception */ @@ -69,7 +68,6 @@ class RedisLock * * @param string $key 被加锁的KEY * @param string|int $requestId 客户端请求唯一ID - * * @return bool */ public static function release(string $key, $requestId) @@ -93,7 +91,6 @@ LAU; * 获取锁 Key * * @param string $key 需要加锁的KEY - * * @return string */ public static function getLockKey(string $key) diff --git a/app/Support/Response.php b/app/Support/Response.php index ce99757..2af81af 100644 --- a/app/Support/Response.php +++ b/app/Support/Response.php @@ -16,8 +16,9 @@ class Response private $response; /** - * @param $data + * 处理json数据 * + * @param $data * @return PsrResponseInterface */ public function json($data) @@ -30,7 +31,6 @@ class Response * * @param array $data 响应数据 * @param string $message 响应提示 - * * @return PsrResponseInterface */ public function success(array $data = [], $message = 'success') @@ -45,7 +45,6 @@ class Response * @param array $data 响应数据 * @param string $message 响应提示 * @param int $code 错误码 - * * @return PsrResponseInterface */ 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 */ public function error($message = '', $code = ResponseCode::SERVER_ERROR) diff --git a/app/Support/SendEmailCode.php b/app/Support/SendEmailCode.php index 96485d8..3b02469 100644 --- a/app/Support/SendEmailCode.php +++ b/app/Support/SendEmailCode.php @@ -2,7 +2,6 @@ namespace App\Support; - class SendEmailCode { const FORGET_PASSWORD = 'forget_password'; @@ -15,7 +14,6 @@ class SendEmailCode * * @param string $type * @param string $mobile - * * @return string */ private function getKey(string $type, string $mobile) @@ -29,7 +27,6 @@ class SendEmailCode * @param string $type 发送类型 * @param string $email 手机号 * @param string $code 验证码 - * * @return bool */ public function check(string $type, string $email, string $code) @@ -48,8 +45,7 @@ class SendEmailCode * @param string $type 类型 * @param string $title 邮件标题 * @param string $email 邮箱地址 - * - * @return boolean + * @return bool */ public function send(string $type, string $title, string $email) { @@ -70,7 +66,6 @@ class SendEmailCode * 获取缓存的验证码 * * @param string $key - * * @return mixed */ public function getCode(string $key) @@ -84,8 +79,7 @@ class SendEmailCode * @param string $key 缓存key * @param string $sms_code 验证码 * @param float|int $exp 过期时间 - * - * @return mixed + * @return bool */ public function setCode(string $key, string $sms_code, $exp = 60 * 15) { @@ -97,8 +91,7 @@ class SendEmailCode * * @param string $type 类型 * @param string $email 邮箱地址 - * - * @return mixed + * @return int */ public function delCode(string $type, string $email) { diff --git a/app/Support/SocketIOParser.php b/app/Support/SocketIOParser.php index 4a185f5..9e9218d 100644 --- a/app/Support/SocketIOParser.php +++ b/app/Support/SocketIOParser.php @@ -9,7 +9,6 @@ class SocketIOParser extends Packet * * @param string $event * @param mixed $data - * * @return mixed */ public static function encode(string $event, $data) @@ -26,7 +25,6 @@ class SocketIOParser extends Packet * Decode message from websocket client. * * @param string $string - * * @return array */ public static function decode($string) diff --git a/app/Traits/PagingTrait.php b/app/Traits/PagingTrait.php index e568c15..4e1f7ae 100644 --- a/app/Traits/PagingTrait.php +++ b/app/Traits/PagingTrait.php @@ -14,7 +14,6 @@ trait PagingTrait * * @param int $total 总记录数 * @param int $page_size 分页大小 - * * @return int 分页总数 */ protected function getPagingTotal(int $total, int $page_size) @@ -30,7 +29,6 @@ trait PagingTrait * @param int $page 当前分页 * @param int $page_size 分页大小 * @param array $params 额外参数 - * * @return array */ protected function getPagingRows(array $rows, int $total, int $page, int $page_size, array $params = []) diff --git a/app/helper.php b/app/helper.php index 5da77b4..796fe7f 100644 --- a/app/helper.php +++ b/app/helper.php @@ -1,15 +1,4 @@ - * @link https://github.com/gzydong/hyperf-chat - */ - /* |-------------------------------------------------------------------------- | Common function method @@ -132,7 +121,6 @@ function response() * 从HTML文本中提取所有图片 * * @param string $content HTML文本 - * * @return array */ function get_html_images($content) @@ -155,7 +143,6 @@ function get_html_images($content) * * @param string $day1 日期1 * @param string $day2 日期2 - * * @return float|int */ function diff_date($day1, $day2) @@ -174,21 +161,19 @@ function diff_date($day1, $day2) * 获取媒体文件url * * @param string $path 文件相对路径 - * * @return string */ 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 int $width 图片宽度 - * @param int $height 图片高度 - * + * @param string $ext 图片后缀名 + * @param int $width 图片宽度 + * @param int $height 图片高度 * @return string */ 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标签 * * @param string $str 字符串 - * * @return null|string|string[] */ 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 int $sort 排序方式 - * + * @param int $sort 排序方式 * @return array */ function arraysSort(array $array, $field, $sort = SORT_DESC) @@ -229,9 +212,8 @@ function arraysSort(array $array, $field, $sort = SORT_DESC) /** * 判断0或正整数 * - * @param string $int 验证字符串 - * @param bool $isZero 判断是否可为0 - * + * @param string $int 验证字符串 + * @param bool $isZero 判断是否可为0 * @return bool */ function check_int($int, $isZero = false) @@ -244,7 +226,6 @@ function check_int($int, $isZero = false) * 解析英文逗号',' 拼接的 ID 字符串 * * @param string $ids 字符串(例如; "1,2,3,4,5,6") - * * @return array */ function parse_ids($ids) diff --git a/config/autoload/server.php b/config/autoload/server.php index bbf4fa0..681592b 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -48,7 +48,7 @@ return [ ], 'settings' => [ 'enable_coroutine' => true, - 'worker_num' => swoole_cpu_num(), + 'worker_num' => 1, 'pid_file' => BASE_PATH . '/runtime/hyperf.pid', 'open_tcp_nodelay' => true, 'max_coroutine' => 100000,