From c1bee9463a425e9d68e03c4fec321b0684cbfa71 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Fri, 21 Mar 2025 13:29:55 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/CustomerController.php | 4 ++-- app/controller/UserController.php | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index a2f97a6..aad9506 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -222,7 +222,7 @@ class CustomerController public function grade(Request $request) { $id = Util::getParam($request, 'id'); - $id = Util::getParam($request, 'grade'); + $grade = Util::getParam($request, 'grade'); if (Util::isEmpty($id)) { return Util::fail('', 'id' . trans('not_null')); } @@ -230,7 +230,7 @@ class CustomerController return Util::fail('', 'grade' . trans('not_null')); } $data = [ - 'grade' => Util::getParam($request, 'grade', 0), + 'grade' => $grade, ]; $res = Customer::where('id', $id) ->update($data); diff --git a/app/controller/UserController.php b/app/controller/UserController.php index ec1f9e8..c162a2d 100644 --- a/app/controller/UserController.php +++ b/app/controller/UserController.php @@ -19,6 +19,7 @@ class UserController public function login(Request $request) { $email = Util::getParam($request, 'email'); + $language = Util::getParam($request, 'language'); if (Util::isEmpty($email)) { return Util::fail([], 'email' . trans('not_null')); } @@ -26,6 +27,7 @@ class UserController if (Util::isEmpty($password)) { return Util::fail([], 'password' . trans('not_null')); } + $user = User::select(['id', 'name', 'sex', 'role', 'avatar', 'email', 'password']) ->where('status', 0) ->where('email', $request->post('email')) @@ -43,6 +45,7 @@ class UserController //验证密码 // if (!password_verify($userPassword, $hashedPassword)) { if ($userPassword == $hashedPassword) { + locale($language); return Util::fail([], trans('password_error')); } $userId = $user['id']; // 实际从数据库获取 @@ -56,6 +59,12 @@ class UserController unset($result['password']); $result['token'] = $token; + if (Util::isEmpty($language)) { + User::where('id', $userId) + ->update(['language' => $language]); + locale($language); + } + return Util::success($result, trans('login_success')); } @@ -163,11 +172,8 @@ class UserController */ public function language(Request $request) { - $id = Util::getParam($request, 'id'); + $id = $request->user['id']; $language = Util::getParam($request, 'language'); - if (Util::isEmpty($id)) { - return Util::fail([], 'id' . trans('not_null')); - } if (Util::isEmpty($language)) { return Util::fail([], 'language' . trans('not_null')); } From 754b6db8d484523bda8330227de74eb9821c0b20 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Fri, 21 Mar 2025 14:00:37 +0800 Subject: [PATCH 2/5] update --- composer.json | 2 +- composer.lock | 36 ++++++++++++------------------------ 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index 4bc81aa..2792e38 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "illuminate/database": "^11.44", "phpmailer/phpmailer": "^6.9", "shopwwi/webman-filesystem": "^2.0", - "iidestiny/flysystem-oss": "4", + "iidestiny/flysystem-oss": "^4", "vlucas/phpdotenv": "^5.6" }, "suggest": { diff --git a/composer.lock b/composer.lock index 4d9eb3d..6c3adf1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8d5fe425388a62621d55a80ee07c34e8", + "content-hash": "1a64bcf537bed214294c8043291f03f3", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -411,26 +411,20 @@ }, { "name": "iidestiny/flysystem-oss", - "version": "4.0", + "version": "4.5", "source": { "type": "git", "url": "https://github.com/iiDestiny/flysystem-oss.git", - "reference": "6b6cf6850be377c484c086505d942e61afa2875c" + "reference": "154ccb26075a20b350e2357289bfeabe3ca79ba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/iiDestiny/flysystem-oss/zipball/6b6cf6850be377c484c086505d942e61afa2875c", - "reference": "6b6cf6850be377c484c086505d942e61afa2875c", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/iiDestiny/flysystem-oss/zipball/154ccb26075a20b350e2357289bfeabe3ca79ba0", + "reference": "154ccb26075a20b350e2357289bfeabe3ca79ba0", + "shasum": "" }, "require": { - "aliyuncs/oss-sdk-php": "^2.4", + "aliyuncs/oss-sdk-php": "^2", "ext-curl": "*", "ext-json": "*", "ext-openssl": "*", @@ -438,8 +432,8 @@ "php": "^8.0.2" }, "require-dev": { - "mockery/mockery": "^1.2", - "phpunit/phpunit": "^6.5", + "mockery/mockery": "^1.5", + "phpunit/phpunit": "^9.5", "symfony/var-dumper": "^3.4" }, "type": "library", @@ -467,9 +461,9 @@ ], "support": { "issues": "https://github.com/iiDestiny/flysystem-oss/issues", - "source": "https://github.com/iiDestiny/flysystem-oss/tree/4.0" + "source": "https://github.com/iiDestiny/flysystem-oss/tree/4.5" }, - "time": "2022-04-19T06:23:50+00:00" + "time": "2025-02-12T05:54:03+00:00" }, { "name": "illuminate/bus", @@ -2025,13 +2019,7 @@ "type": "zip", "url": "https://api.github.com/repos/shopwwi/webman-filesystem/zipball/de33afdbfc56678323f1aafb8d011d79378d164a", "reference": "de33afdbfc56678323f1aafb8d011d79378d164a", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "league/flysystem": "^2.3|^3.0", From 14f67fa1b08acfbab6c3f484dfe1ad9796747693 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Fri, 21 Mar 2025 14:06:35 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=B7=A8=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/route.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/route.php b/config/route.php index 6851ca6..164829b 100644 --- a/config/route.php +++ b/config/route.php @@ -24,7 +24,7 @@ use Webman\Route; Route::any('/login', [app\controller\UserController::class, 'login'])->middleware([app\middleware\CrossDomain::class]); // 文件上传接口 -Route::post('/upload', [app\controller\UploadController::class, 'uploadImage']); +Route::post('/upload', [app\controller\UploadController::class, 'uploadImage'])->middleware([app\middleware\CrossDomain::class]); From 4998ccbc937c1a0f26ff91ede4dc74b4a71d8442 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Fri, 21 Mar 2025 14:18:05 +0800 Subject: [PATCH 4/5] update --- config/route.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/route.php b/config/route.php index 164829b..17514e0 100644 --- a/config/route.php +++ b/config/route.php @@ -24,7 +24,7 @@ use Webman\Route; Route::any('/login', [app\controller\UserController::class, 'login'])->middleware([app\middleware\CrossDomain::class]); // 文件上传接口 -Route::post('/upload', [app\controller\UploadController::class, 'uploadImage'])->middleware([app\middleware\CrossDomain::class]); +Route::any('/upload', [app\controller\UploadController::class, 'uploadImage'])->middleware([app\middleware\CrossDomain::class]); From 3014f31f439a9df65804a130e7117761b987e68d Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Fri, 21 Mar 2025 15:16:22 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/CustomerController.php | 6 +++--- app/controller/FollowController.php | 2 +- app/controller/UserController.php | 15 +++++++++------ resource/translations/en/messages.php | 5 +++++ resource/translations/zh_CN/messages.php | 5 +++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index aad9506..2ce3c6c 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -162,7 +162,7 @@ class CustomerController $id = Util::getParam($request, 'id'); $channel_id = Util::getParam($request, 'channel_id'); if (Util::isEmpty($channel_id)) { - return Util::fail([], 'channel_id' . trans('not_null')); + return Util::fail([], trans('channel_not_null')); } $country_id = Util::getParam($request, 'country_id', 0); if (Util::isEmpty($country_id)) { @@ -170,13 +170,13 @@ class CustomerController } $car_type_id = Util::getParam($request, 'car_type_id'); if (Util::isEmpty($car_type_id)) { - return Util::fail([], 'car_type_id' . trans('not_null')); + return Util::fail([], trans('car_type_not_null')); } $contacts = Util::getParam($request, 'contacts'); $email = Util::getParam($request, 'email'); $phone = Util::getParam($request, 'phone'); if (Util::isEmpty($contacts) && Util::isEmpty($email) && Util::isEmpty($phone)) { - return Util::fail([], 'country_id' . trans('not_null')); + return Util::fail([], trans('contacts_not_null')); } $data = [ diff --git a/app/controller/FollowController.php b/app/controller/FollowController.php index e01fa8b..c4bd59a 100644 --- a/app/controller/FollowController.php +++ b/app/controller/FollowController.php @@ -125,7 +125,7 @@ class FollowController } $picture = Util::getParam($request,'picture'); if(Util::isEmpty($picture)){ - return Util::fail([],'picture'.trans('not_null')); + return Util::fail([],trans('picture_not_null')); } $data = [ diff --git a/app/controller/UserController.php b/app/controller/UserController.php index c162a2d..d445dbf 100644 --- a/app/controller/UserController.php +++ b/app/controller/UserController.php @@ -21,11 +21,11 @@ class UserController $email = Util::getParam($request, 'email'); $language = Util::getParam($request, 'language'); if (Util::isEmpty($email)) { - return Util::fail([], 'email' . trans('not_null')); + return Util::fail([], trans('required_not_null')); } $password = Util::getParam($request, 'password'); if (Util::isEmpty($password)) { - return Util::fail([], 'password' . trans('not_null')); + return Util::fail([], trans('required_not_null')); } $user = User::select(['id', 'name', 'sex', 'role', 'avatar', 'email', 'password']) @@ -78,12 +78,15 @@ class UserController { $email = Util::getParam($request, 'email'); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { - return Util::fail([], 'email' . trans('not_null')); + return Util::fail([], trans('required_not_null')); } // 生成验证码 $code = str_pad(random_int(0, 999999), 6, '0', STR_PAD_LEFT); +// $verification_code = Redis::get("verification_code:{$email}"); +// $code = $verification_code?:$code; +// return Util::success($code, '验证码已发送'); // 发送邮件 $mailService = new MailService(); if ($mailService->sendVerificationCode($email, $code)) { @@ -106,14 +109,14 @@ class UserController $email = Util::getParam($request, 'email', 'asdf'); $code = Util::getParam($request, 'code'); $sex = Util::getParam($request, 'sex', 0); - $name = Util::getParam($request, 'name', 0); + $name = Util::getParam($request, 'name', ''); $password = Util::getParam($request, 'password'); $mobile = Util::getParam($request, 'mobile'); $id = Util::getParam($request, 'id'); $language = Util::getParam($request, 'language'); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { - return Util::fail([], 'email' . $email . trans('not_null')); + return Util::fail([], trans('required_not_null')); } $res = User::select('id', 'email') @@ -124,7 +127,7 @@ class UserController // } if (Util::isEmpty($name)) { - return Util::fail([], 'name' . trans('not_null')); +// return Util::fail([], trans('required_not_null')); } $verification_code = Redis::get("verification_code:{$email}"); diff --git a/resource/translations/en/messages.php b/resource/translations/en/messages.php index d039bc0..f989337 100644 --- a/resource/translations/en/messages.php +++ b/resource/translations/en/messages.php @@ -17,4 +17,9 @@ return [ 'language_success' => ' Successfully switched languages', 'language_fail' => ' Language switching failed', 'param_error' => ' param error', + 'required_not_null' => ' required not_ ull', + 'picture_not_null' => ' picture not null', + 'contacts_not_null' => ' Contact person, email, and phone cannot be empty at the same time', + 'car_type_not_null' => ' preference_not_null', + 'channel_not_null' => ' channel not null', ]; \ No newline at end of file diff --git a/resource/translations/zh_CN/messages.php b/resource/translations/zh_CN/messages.php index 2e124b0..f3d14b5 100644 --- a/resource/translations/zh_CN/messages.php +++ b/resource/translations/zh_CN/messages.php @@ -17,4 +17,9 @@ return [ 'language_success' => ' 切换语言成功', 'language_fail' => ' 切换语言失败', 'param_error' => ' 参数错误', + 'required_not_null' => ' 必填项不能为空', + 'picture_not_null' => ' 图片不能为空', + 'contacts_not_null' => ' 联系人,邮箱,电话不能同时为空', + 'car_type_not_null' => ' 偏好不能为空', + 'channel_not_null' => ' 渠道不能为空', ]; \ No newline at end of file