From afcf456d6026cb5da26a4e0c5ac5e03f4d076b21 Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Fri, 21 Jan 2022 22:19:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=85=BC=E5=AE=B9=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/Api/V1/AuthController.php | 9 +++++---- app/Service/UserService.php | 1 - .../2020_11_04_152602_create_users_table.php | 2 +- ...11_04_153251_create_article_annex_table.php | 11 ++++++----- ...11_04_153304_create_article_class_table.php | 3 ++- ...1_04_153316_create_article_detail_table.php | 4 ++-- ..._11_04_153327_create_article_tags_table.php | 9 ++++++--- ...11_04_153358_create_split_upload_table.php} | 18 ++++++++++-------- ...11_04_153421_create_talk_session_table.php} | 6 +++--- ...4_153442_create_talk_records_file_table.php | 13 +++++++------ ...4_153529_create_talk_records_code_table.php | 2 +- ...2020_11_04_153553_create_contact_table.php} | 6 +++--- ...1_04_153605_create_contact_apply_table.php} | 6 +++--- .../2020_11_04_153616_create_group_table.php | 1 + ...> 2021_07_02_165853_create_robot_table.php} | 8 ++++---- 15 files changed, 54 insertions(+), 45 deletions(-) rename migrations/{2020_11_04_153358_create_file_split_upload_table.php => 2020_11_04_153358_create_split_upload_table.php} (63%) rename migrations/{2020_11_04_153421_create_talk_list_table.php => 2020_11_04_153421_create_talk_session_table.php} (90%) rename migrations/{2020_11_04_153553_create_users_friends_table.php => 2020_11_04_153553_create_contact_table.php} (87%) rename migrations/{2020_11_04_153605_create_users_friends_apply_table.php => 2020_11_04_153605_create_contact_apply_table.php} (84%) rename migrations/{2021_07_02_165853_create_robots_table.php => 2021_07_02_165853_create_robot_table.php} (89%) diff --git a/app/Controller/Api/V1/AuthController.php b/app/Controller/Api/V1/AuthController.php index 4d1805c..61468d8 100644 --- a/app/Controller/Api/V1/AuthController.php +++ b/app/Controller/Api/V1/AuthController.php @@ -38,6 +38,7 @@ class AuthController extends CController public function login(): ResponseInterface { $params = $this->request->inputs(['mobile', 'password', 'platform']); + $this->validate($params, [ 'mobile' => "required|phone", 'password' => 'required', @@ -61,7 +62,7 @@ class AuthController extends CController 'type' => 'Bearer', 'access_token' => $token, 'expires_in' => $this->guard()->getJwtManager()->getTtl(), - ], '账号登录成功...'); + ]); } /** @@ -73,7 +74,7 @@ class AuthController extends CController { $this->guard()->check() && $this->guard()->logout(); - return $this->response->success([], '退出登录成功...'); + return $this->response->success(); } /** @@ -120,6 +121,7 @@ class AuthController extends CController public function forget(): ResponseInterface { $params = $this->request->inputs(['mobile', 'password', 'sms_code']); + $this->validate($params, [ 'mobile' => "required|phone", 'password' => 'required|max:16', @@ -135,10 +137,9 @@ class AuthController extends CController return $this->response->fail('重置密码失败!'); } - // 删除验证码缓存 $this->sms->delCode(SmsConstant::SmsForgetAccountChannel, $params['mobile']); - return $this->response->success([], '账号注册成功...'); + return $this->response->success(); } /** diff --git a/app/Service/UserService.php b/app/Service/UserService.php index ccddc24..ac27b48 100644 --- a/app/Service/UserService.php +++ b/app/Service/UserService.php @@ -38,7 +38,6 @@ class UserService extends BaseService */ public function login(string $mobile, string $password) { - $user = User::where('mobile', $mobile)->first(); if (!$user = User::where('mobile', $mobile)->first()) { return false; } diff --git a/migrations/2020_11_04_152602_create_users_table.php b/migrations/2020_11_04_152602_create_users_table.php index 1219567..fadf6da 100644 --- a/migrations/2020_11_04_152602_create_users_table.php +++ b/migrations/2020_11_04_152602_create_users_table.php @@ -21,7 +21,7 @@ class CreateUsersTable extends Migration $table->string('motto', 100)->default('')->comment('用户座右铭'); $table->string('email', 30)->default('')->comment('用户邮箱'); $table->unsignedTinyInteger('is_robot')->default(0)->comment('是否机器人[0:否;1:是;]'); - $table->dateTime('created_at')->nullable()->comment('注册时间'); + $table->dateTime('created_at')->nullable()->comment('创建时间'); $table->dateTime('updated_at')->nullable()->comment('更新时间'); $table->charset = 'utf8'; diff --git a/migrations/2020_11_04_153251_create_article_annex_table.php b/migrations/2020_11_04_153251_create_article_annex_table.php index 9a47088..4d67fc7 100644 --- a/migrations/2020_11_04_153251_create_article_annex_table.php +++ b/migrations/2020_11_04_153251_create_article_annex_table.php @@ -15,13 +15,14 @@ class CreateArticleAnnexTable extends Migration $table->unsignedBigInteger('id', true)->comment('文件ID'); $table->unsignedInteger('user_id')->unsigned()->comment('上传文件的用户ID'); $table->unsignedInteger('article_id')->default(0)->comment('笔记ID'); - $table->string('file_suffix', 10)->default('')->comment('文件后缀名'); - $table->unsignedBigInteger('file_size')->default(0)->comment('文件大小(单位字节)'); - $table->string('save_dir', 500)->nullable(false)->default('')->comment('文件保存地址(相对地址)'); + $table->string('suffix', 10)->default('')->comment('文件后缀名'); + $table->unsignedBigInteger('size')->default(0)->comment('文件大小(单位字节)'); + $table->string('path', 500)->nullable(false)->default('')->comment('文件保存地址(相对地址)'); $table->string('original_name', 100)->nullable(false)->default('')->comment('原文件名'); $table->unsignedTinyInteger('status')->default(1)->comment('附件状态[1:正常;2:已删除]'); - $table->dateTime('created_at')->nullable(true)->comment('附件上传时间'); - $table->dateTime('deleted_at')->nullable(true)->comment('附件删除时间'); + $table->dateTime('created_at')->nullable(true)->comment('创建时间'); + $table->dateTime('updated_at')->nullable(true)->comment('更新时间'); + $table->dateTime('deleted_at')->nullable(true)->comment('删除时间'); $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; diff --git a/migrations/2020_11_04_153304_create_article_class_table.php b/migrations/2020_11_04_153304_create_article_class_table.php index 5b62c89..60812a2 100644 --- a/migrations/2020_11_04_153304_create_article_class_table.php +++ b/migrations/2020_11_04_153304_create_article_class_table.php @@ -17,7 +17,8 @@ class CreateArticleClassTable extends Migration $table->string('class_name', 20)->default('')->comment('分类名'); $table->unsignedTinyInteger('sort')->default(0)->comment('排序'); $table->unsignedTinyInteger('is_default')->default(0)->comment('默认分类[1:是;0:不是]'); - $table->unsignedInteger('created_at')->nullable(true)->default(0)->comment('创建时间'); + $table->dateTime('created_at')->nullable(true)->comment('创建时间'); + $table->dateTime('updated_at')->nullable(true)->comment('更新时间'); $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; diff --git a/migrations/2020_11_04_153316_create_article_detail_table.php b/migrations/2020_11_04_153316_create_article_detail_table.php index d301deb..e5b8087 100644 --- a/migrations/2020_11_04_153316_create_article_detail_table.php +++ b/migrations/2020_11_04_153316_create_article_detail_table.php @@ -12,7 +12,7 @@ class CreateArticleDetailTable extends Migration public function up(): void { Schema::create('article_detail', function (Blueprint $table) { - $table->unsignedInteger('id', true)->comment('笔记详情ID'); + $table->unsignedInteger('id', true)->comment('自增ID'); $table->unsignedInteger('article_id')->nullable(false)->comment('笔记ID'); $table->longtext('md_content')->charset('utf8mb4')->comment('Markdown 内容'); $table->longtext('content')->charset('utf8mb4')->comment('Markdown 解析HTML内容'); @@ -21,7 +21,7 @@ class CreateArticleDetailTable extends Migration $table->collation = 'utf8_general_ci'; $table->engine = 'InnoDB'; - $table->unique('article_id', 'unique_article_id'); + $table->unique('article_id', 'uk_article_id'); $table->comment('笔记详情表'); }); diff --git a/migrations/2020_11_04_153327_create_article_tags_table.php b/migrations/2020_11_04_153327_create_article_tags_table.php index 8a8e330..e67b15f 100644 --- a/migrations/2020_11_04_153327_create_article_tags_table.php +++ b/migrations/2020_11_04_153327_create_article_tags_table.php @@ -11,17 +11,20 @@ class CreateArticleTagsTable extends Migration */ public function up(): void { - Schema::create('article_tags', function (Blueprint $table) { + Schema::create('article_tag', function (Blueprint $table) { $table->unsignedInteger('id', true)->comment('笔记标签ID'); $table->unsignedInteger('user_id')->default(0)->comment('用户ID'); $table->string('tag_name', 20)->default('')->comment('标签名'); $table->unsignedTinyInteger('sort')->default(0)->comment('排序'); - $table->unsignedInteger('created_at')->nullable(true)->default(0)->comment('创建时间'); + $table->dateTime('created_at')->nullable(true)->comment('创建时间'); + $table->dateTime('updated_at')->nullable(true)->comment('更新时间'); $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; $table->engine = 'InnoDB'; + $table->index(['user_id'], 'idx_user_id'); + $table->comment('笔记标签表'); }); } @@ -31,6 +34,6 @@ class CreateArticleTagsTable extends Migration */ public function down(): void { - Schema::dropIfExists('article_tags'); + Schema::dropIfExists('article_tag'); } } diff --git a/migrations/2020_11_04_153358_create_file_split_upload_table.php b/migrations/2020_11_04_153358_create_split_upload_table.php similarity index 63% rename from migrations/2020_11_04_153358_create_file_split_upload_table.php rename to migrations/2020_11_04_153358_create_split_upload_table.php index ef1a3c1..bf5c3f3 100644 --- a/migrations/2020_11_04_153358_create_file_split_upload_table.php +++ b/migrations/2020_11_04_153358_create_split_upload_table.php @@ -4,31 +4,33 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -class CreateFileSplitUploadTable extends Migration +class CreateSplitUploadTable extends Migration { /** * Run the migrations. */ public function up(): void { - Schema::create('file_split_upload', function (Blueprint $table) { + Schema::create('split_upload', function (Blueprint $table) { $table->unsignedInteger('id', true)->comment('临时文件ID'); - $table->unsignedTinyInteger('file_type')->default(2)->comment('数据类型[1:合并文件;2:拆分文件]'); + $table->unsignedTinyInteger('type')->default(2)->comment('数据类型[1:合并文件;2:拆分文件]'); $table->unsignedInteger('user_id')->default(0)->comment('上传的用户ID'); - $table->string('hash_name', 32)->default('')->comment('临时文件hash名'); + $table->string('upload_id', 32)->default('')->comment('上传文件ID'); $table->string('original_name', 100)->default('')->comment('原文件名'); $table->unsignedTinyInteger('split_index')->default(0)->comment('当前索引块'); $table->unsignedTinyInteger('split_num')->default(0)->comment('总上传索引块'); - $table->string('save_dir', 255)->default('')->comment('文件的临时保存路径'); + $table->string('path', 255)->default('')->comment('保存路径'); $table->string('file_ext', 10)->default('')->comment('文件后缀名'); $table->unsignedInteger('file_size')->default(0)->comment('临时文件大小'); $table->unsignedTinyInteger('is_delete')->default(0)->comment('文件是否已被删除[0:否;1:是]'); - $table->unsignedInteger('upload_at')->nullable(true)->comment('文件上传时间'); + $table->unsignedInteger('created_at')->nullable(true)->comment('创建时间'); + $table->unsignedInteger('updated_at')->nullable(true)->comment('更新时间'); $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; - $table->index(['user_id', 'hash_name'], 'idx_user_id_hash_name'); + $table->index(['user_id', 'upload_id'], 'idx_user_id_upload_id'); + $table->comment('文件拆分上传'); }); } @@ -38,6 +40,6 @@ class CreateFileSplitUploadTable extends Migration */ public function down(): void { - Schema::dropIfExists('file_split_upload'); + Schema::dropIfExists('split_upload'); } } diff --git a/migrations/2020_11_04_153421_create_talk_list_table.php b/migrations/2020_11_04_153421_create_talk_session_table.php similarity index 90% rename from migrations/2020_11_04_153421_create_talk_list_table.php rename to migrations/2020_11_04_153421_create_talk_session_table.php index fcc008e..2690df5 100644 --- a/migrations/2020_11_04_153421_create_talk_list_table.php +++ b/migrations/2020_11_04_153421_create_talk_session_table.php @@ -4,14 +4,14 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -class CreateTalkListTable extends Migration +class CreateTalkSessionTable extends Migration { /** * Run the migrations. */ public function up(): void { - Schema::create('talk_list', function (Blueprint $table) { + Schema::create('talk_session', function (Blueprint $table) { $table->unsignedInteger('id', true)->comment('聊天列表ID'); $table->unsignedTinyInteger('talk_type')->default(1)->comment('聊天类型[1:私信;2:群聊;]'); $table->unsignedInteger('user_id')->default(0)->comment('用户ID'); @@ -37,6 +37,6 @@ class CreateTalkListTable extends Migration */ public function down(): void { - Schema::dropIfExists('talk_list'); + Schema::dropIfExists('talk_session'); } } diff --git a/migrations/2020_11_04_153442_create_talk_records_file_table.php b/migrations/2020_11_04_153442_create_talk_records_file_table.php index 7e2a162..b2dff3a 100644 --- a/migrations/2020_11_04_153442_create_talk_records_file_table.php +++ b/migrations/2020_11_04_153442_create_talk_records_file_table.php @@ -15,13 +15,14 @@ class CreateTalkRecordsFileTable extends Migration $table->unsignedInteger('id', true)->comment('文件ID'); $table->unsignedInteger('record_id')->default(0)->comment('消息记录ID'); $table->unsignedInteger('user_id')->default(0)->comment('上传文件的用户ID'); - $table->tinyInteger('file_source')->default(1)->unsigned()->comment('文件来源[1:用户上传;2:表情包]'); - $table->tinyInteger('file_type')->default(1)->unsigned()->comment('消息类型[1:图片;2:视频;3:文件]'); - $table->tinyInteger('save_type')->default(0)->unsigned()->comment('文件保存方式(0:本地 1:第三方[阿里OOS、七牛云] )'); + $table->tinyInteger('source')->default(1)->unsigned()->comment('文件来源[1:用户上传;2:表情包]'); + $table->tinyInteger('type')->default(1)->unsigned()->comment('消息类型[1:图片;2:视频;3:文件]'); + $table->tinyInteger('drive')->default(1)->unsigned()->comment('驱动类型[1:local;2:cos;]'); $table->string('original_name', 100)->default('')->comment('原文件名'); - $table->string('file_suffix', 10)->default('')->comment('文件后缀名'); - $table->unsignedBigInteger('file_size')->default(0)->comment('文件大小(单位字节)'); - $table->string('save_dir', 300)->default('')->comment('文件保存地址(相对地址/第三方网络地址)'); + $table->string('suffix', 10)->default('')->comment('文件后缀名'); + $table->unsignedBigInteger('size')->default(0)->comment('文件大小(单位字节)'); + $table->string('path', 300)->default('')->comment('文件地址(相对地址)'); + $table->string('url', 300)->default('')->comment('网络地址(公开文件地址)'); $table->tinyInteger('is_delete')->default(0)->unsigned()->comment('文件是否已删除[0:否;1:已删除]'); $table->dateTime('created_at')->nullable(true)->comment('创建时间'); diff --git a/migrations/2020_11_04_153529_create_talk_records_code_table.php b/migrations/2020_11_04_153529_create_talk_records_code_table.php index 3dcc07f..4af0c53 100644 --- a/migrations/2020_11_04_153529_create_talk_records_code_table.php +++ b/migrations/2020_11_04_153529_create_talk_records_code_table.php @@ -16,7 +16,7 @@ class CreateTalkRecordsCodeTable extends Migration $table->unsignedInteger('id', true)->comment('入群或退群通知ID'); $table->unsignedInteger('record_id')->default(0)->comment('消息记录ID'); $table->unsignedInteger('user_id')->default(0)->comment('上传文件的用户ID'); - $table->string('code_lang', 20)->default('')->comment("代码片段类型(如:php,java,python)"); + $table->string('lang', 20)->default('')->comment("代码片段类型(如:php,java,python)"); $table->text('code')->charset('utf8mb4')->comment('代码片段内容'); $table->dateTime('created_at')->nullable(true)->comment('创建时间'); diff --git a/migrations/2020_11_04_153553_create_users_friends_table.php b/migrations/2020_11_04_153553_create_contact_table.php similarity index 87% rename from migrations/2020_11_04_153553_create_users_friends_table.php rename to migrations/2020_11_04_153553_create_contact_table.php index f44adf6..59edcd4 100644 --- a/migrations/2020_11_04_153553_create_users_friends_table.php +++ b/migrations/2020_11_04_153553_create_contact_table.php @@ -4,14 +4,14 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -class CreateUsersFriendsTable extends Migration +class CreateContactTable extends Migration { /** * Run the migrations. */ public function up(): void { - Schema::create('users_friends', function (Blueprint $table) { + Schema::create('contact', function (Blueprint $table) { $table->unsignedInteger('id', true)->comment('关系ID'); $table->unsignedInteger('user_id')->default(0)->comment('用户ID'); $table->unsignedInteger('friend_id')->default(0)->comment('好友ID'); @@ -34,6 +34,6 @@ class CreateUsersFriendsTable extends Migration */ public function down(): void { - Schema::dropIfExists('users_friends'); + Schema::dropIfExists('contact'); } } diff --git a/migrations/2020_11_04_153605_create_users_friends_apply_table.php b/migrations/2020_11_04_153605_create_contact_apply_table.php similarity index 84% rename from migrations/2020_11_04_153605_create_users_friends_apply_table.php rename to migrations/2020_11_04_153605_create_contact_apply_table.php index aa4c61e..7f901da 100644 --- a/migrations/2020_11_04_153605_create_users_friends_apply_table.php +++ b/migrations/2020_11_04_153605_create_contact_apply_table.php @@ -4,14 +4,14 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -class CreateUsersFriendsApplyTable extends Migration +class CreateContactApplyTable extends Migration { /** * Run the migrations. */ public function up(): void { - Schema::create('users_friends_apply', function (Blueprint $table) { + Schema::create('contact_apply', function (Blueprint $table) { $table->unsignedInteger('id', true)->comment('申请ID'); $table->unsignedInteger('user_id')->default(0)->comment('申请人ID'); $table->unsignedInteger('friend_id')->default(0)->comment('好友ID'); @@ -33,6 +33,6 @@ class CreateUsersFriendsApplyTable extends Migration */ public function down(): void { - Schema::dropIfExists('users_friends_apply'); + Schema::dropIfExists('contact_apply'); } } diff --git a/migrations/2020_11_04_153616_create_group_table.php b/migrations/2020_11_04_153616_create_group_table.php index 9773dca..78fb689 100644 --- a/migrations/2020_11_04_153616_create_group_table.php +++ b/migrations/2020_11_04_153616_create_group_table.php @@ -22,6 +22,7 @@ class CreateGroupTable extends Migration $table->tinyInteger('is_mute')->default(0)->comment('是否全员禁言 [0:否;1:是;],提示:不包含群主或管理员'); $table->tinyInteger('is_dismiss')->default(0)->comment('是否已解散[0:否;1:是;]'); $table->dateTime('created_at')->nullable()->comment('创建时间'); + $table->dateTime('updated_at')->nullable()->comment('更新时间'); $table->dateTime('dismissed_at')->nullable()->comment('解散时间'); $table->charset = 'utf8'; diff --git a/migrations/2021_07_02_165853_create_robots_table.php b/migrations/2021_07_02_165853_create_robot_table.php similarity index 89% rename from migrations/2021_07_02_165853_create_robots_table.php rename to migrations/2021_07_02_165853_create_robot_table.php index 56420c1..11eb962 100644 --- a/migrations/2021_07_02_165853_create_robots_table.php +++ b/migrations/2021_07_02_165853_create_robot_table.php @@ -4,14 +4,14 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -class CreateRobotsTable extends Migration +class CreateRobotTable extends Migration { /** * Run the migrations. */ public function up(): void { - Schema::create('robots', function (Blueprint $table) { + Schema::create('robot', function (Blueprint $table) { $table->unsignedInteger('id', true)->comment('机器人ID'); $table->unsignedInteger('user_id')->comment('关联用户ID'); $table->string('robot_name', 30)->default('')->comment('机器人名称'); @@ -20,7 +20,7 @@ class CreateRobotsTable extends Migration $table->unsignedTinyInteger('is_talk')->default(0)->unsigned()->comment('可发送消息[0:否;1:是;]'); $table->unsignedTinyInteger('status')->default(0)->unsigned()->comment('状态[-1:已删除;0:正常;1:已禁用;]'); $table->unsignedTinyInteger('type')->default(0)->unsigned()->comment('机器人类型'); - $table->dateTime('created_at')->nullable()->comment('注册时间'); + $table->dateTime('created_at')->nullable()->comment('创建时间'); $table->dateTime('updated_at')->nullable()->comment('更新时间'); $table->charset = 'utf8'; @@ -36,6 +36,6 @@ class CreateRobotsTable extends Migration */ public function down(): void { - Schema::dropIfExists('robots'); + Schema::dropIfExists('robot'); } }