From b174403a2ad31d88c431b66131ff821e049fcfb7 Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Thu, 1 Jul 2021 20:06:09 +0900 Subject: [PATCH] remove: soft delete --- app/Console/Commands/Test.php | 2 ++ app/Http/Controllers/Admin/UserController.php | 14 +------------- app/Http/Middleware/User.php | 6 ------ app/Http/Routes/AdminRoute.php | 1 - app/Models/User.php | 2 -- app/Services/UserService.php | 3 +++ database/install.sql | 5 ++--- database/update.sql | 10 +++++++--- 8 files changed, 15 insertions(+), 28 deletions(-) diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 667e616c..ea7964d1 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Models\Order; use Illuminate\Console\Command; class Test extends Command @@ -37,5 +38,6 @@ class Test extends Command */ public function handle() { + dd(Order::where('user_id', 4)->delete()); } } diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index d5cf5377..cf3798d3 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -7,10 +7,10 @@ use App\Http\Requests\Admin\UserGenerate; use App\Http\Requests\Admin\UserSendMail; use App\Http\Requests\Admin\UserUpdate; use App\Jobs\SendEmailJob; +use App\Services\UserService; use App\Utils\Helper; use Illuminate\Http\Request; use App\Http\Controllers\Controller; -use App\Models\Order; use App\Models\User; use App\Models\Plan; use Illuminate\Support\Facades\DB; @@ -277,16 +277,4 @@ class UserController extends Controller 'data' => true ]); } - - public function drop(Request $request) - { - $user = User::find($request->input('id')); - if (!$user) abort(500, '用户不存在'); - if (!$user->delete()) { - abort(500, '删除失败'); - } - return response([ - 'data' => true - ]); - } } diff --git a/app/Http/Middleware/User.php b/app/Http/Middleware/User.php index be411f90..2f3d8283 100755 --- a/app/Http/Middleware/User.php +++ b/app/Http/Middleware/User.php @@ -25,12 +25,6 @@ class User $request->session()->put('email', $user->email); $request->session()->put('id', $user->id); } -// if ($request->input('lang')) { -// $request->session()->put('lang', $request->input('lang')); -// } -// if ($request->session()->get('lang')) { -// App::setLocale($request->session()->get('lang')); -// } if (!$request->session()->get('id')) { abort(403, '未登录或登陆已过期'); } diff --git a/app/Http/Routes/AdminRoute.php b/app/Http/Routes/AdminRoute.php index 582fddf9..5b9640a2 100644 --- a/app/Http/Routes/AdminRoute.php +++ b/app/Http/Routes/AdminRoute.php @@ -75,7 +75,6 @@ class AdminRoute $router->post('/user/ban', 'Admin\\UserController@ban'); $router->post('/user/resetSecret', 'Admin\\UserController@resetSecret'); $router->post('/user/setInviteUser', 'Admin\\UserController@setInviteUser'); - $router->post('/user/drop', 'Admin\\UserController@drop'); // StatOrder $router->get ('/stat/getOverride', 'Admin\\StatController@getOverride'); $router->get ('/stat/getServerLastRank', 'Admin\\StatController@getServerLastRank'); diff --git a/app/Models/User.php b/app/Models/User.php index 6161e49f..cb118056 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,11 +3,9 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; class User extends Model { - use SoftDeletes; protected $table = 'v2_user'; protected $dateFormat = 'U'; protected $guarded = ['id']; diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 39269939..5d3f2f0f 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -2,9 +2,12 @@ namespace App\Services; +use App\Models\InviteCode; use App\Models\Order; use App\Models\Server; +use App\Models\Ticket; use App\Models\User; +use Illuminate\Support\Facades\DB; class UserService { diff --git a/database/install.sql b/database/install.sql index 5b7aeacb..ccf5ba31 100644 --- a/database/install.sql +++ b/database/install.sql @@ -342,10 +342,9 @@ CREATE TABLE `v2_user` ( `expired_at` bigint(20) DEFAULT '0', `created_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL, - `deleted_at` int(11) DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `email_deleted_at` (`email`,`deleted_at`) + UNIQUE KEY `email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- 2021-06-30 15:34:40 +-- 2021-07-01 11:00:48 diff --git a/database/update.sql b/database/update.sql index 8c7f32b6..156454be 100644 --- a/database/update.sql +++ b/database/update.sql @@ -412,9 +412,13 @@ ALTER TABLE `v2_order` ALTER TABLE `v2_payment` ADD `uuid` char(32) NOT NULL AFTER `id`; -ALTER TABLE `v2_user` - ADD `deleted_at` int(11) NULL AFTER `updated_at`; - ALTER TABLE `v2_user` ADD UNIQUE `email_deleted_at` (`email`, `deleted_at`), DROP INDEX `email`; + +ALTER TABLE `v2_user` +DROP `deleted_at`; + +ALTER TABLE `v2_user` + ADD UNIQUE `email` (`email`), +DROP INDEX `email_deleted_at`;