From e4b8eeb3125fc6d4d80a4184a080de51f04720c0 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Sun, 1 Jan 2023 21:01:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=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/Console/Commands/TestCommand.php | 2 - .../Admin/NotificationController.php | 45 +++++++++---------- .../Controllers/Modules/ModuleController.php | 14 +++--- app/Jobs/Module/FetchModuleJob.php | 1 - app/Jobs/SendCommonNotificationsJob.php | 2 - app/Models/Admin.php | 1 - app/Models/Task.php | 1 - app/Models/UserGroup.php | 1 - app/Notifications/CommonNotification.php | 1 - app/Providers/AppServiceProvider.php | 1 - 10 files changed, 29 insertions(+), 40 deletions(-) diff --git a/app/Console/Commands/TestCommand.php b/app/Console/Commands/TestCommand.php index 5b1482c..f51a37b 100644 --- a/app/Console/Commands/TestCommand.php +++ b/app/Console/Commands/TestCommand.php @@ -3,7 +3,6 @@ namespace App\Console\Commands; use App\Models\Balance; -use App\Models\User; use Illuminate\Console\Command; use Symfony\Component\Console\Command\Command as CommandAlias; @@ -37,7 +36,6 @@ public function handle(): int ->get(); - // table $this->table(['支付方式', '数量', '日期'], $balances->toArray()); diff --git a/app/Http/Controllers/Admin/NotificationController.php b/app/Http/Controllers/Admin/NotificationController.php index ed58e72..1785163 100644 --- a/app/Http/Controllers/Admin/NotificationController.php +++ b/app/Http/Controllers/Admin/NotificationController.php @@ -4,7 +4,6 @@ use App\Http\Controllers\Controller; use App\Jobs\SendCommonNotificationsJob; -use App\Models\Host; use App\Models\Module; use App\Models\User; use GeneaLabs\LaravelModelCaching\CachedBuilder; @@ -29,28 +28,6 @@ public function create(Request $request) return view('admin.notifications.create', compact('modules', 'users')); } - /** - * Store a newly created resource in storage. - * - * @param Request $request - * - * @return RedirectResponse - */ - public function store(Request $request) - { - $request->validate([ - 'title' => 'required', - 'content' => 'required', - 'user_id' => 'nullable', - 'module_id' => 'nullable', - 'user' => 'nullable', - ]); - - dispatch(new SendCommonNotificationsJob($request->toArray(), $request->input('title'), $request->input('content'))); - - return back()->with('success', '通知发送成功。')->withInput(); - } - public function query(Request|array $request): User|CachedBuilder { if ($request instanceof Request) { @@ -85,4 +62,26 @@ public function query(Request|array $request): User|CachedBuilder return $users; } + + /** + * Store a newly created resource in storage. + * + * @param Request $request + * + * @return RedirectResponse + */ + public function store(Request $request) + { + $request->validate([ + 'title' => 'required', + 'content' => 'required', + 'user_id' => 'nullable', + 'module_id' => 'nullable', + 'user' => 'nullable', + ]); + + dispatch(new SendCommonNotificationsJob($request->toArray(), $request->input('title'), $request->input('content'))); + + return back()->with('success', '通知发送成功。')->withInput(); + } } diff --git a/app/Http/Controllers/Modules/ModuleController.php b/app/Http/Controllers/Modules/ModuleController.php index 1a2a1d4..a5a8161 100644 --- a/app/Http/Controllers/Modules/ModuleController.php +++ b/app/Http/Controllers/Modules/ModuleController.php @@ -33,6 +33,13 @@ public function call(Request $request, Module $module) return $this->moduleResponse($response['json'], $response['status']); } + private function fixPath(Request $request, Module $module, $prefix): string + { + $path = substr($request->path(), strlen("/{$prefix}/modules/{$module->id}")); + + return preg_replace('/[^a-zA-Z0-9\/]/', '', $path); + } + public function exportCall(Request $request, Module $module): Response|JsonResponse { $path = $this->fixPath($request, $module, 'modules'); @@ -46,11 +53,4 @@ public function exportCall(Request $request, Module $module): Response|JsonRespo return $this->moduleResponse($response['json'], $response['status']); } - - private function fixPath(Request $request, Module $module, $prefix): string - { - $path = substr($request->path(), strlen("/{$prefix}/modules/{$module->id}")); - - return preg_replace('/[^a-zA-Z0-9\/]/', '', $path); - } } diff --git a/app/Jobs/Module/FetchModuleJob.php b/app/Jobs/Module/FetchModuleJob.php index 124c9bc..3601f3b 100644 --- a/app/Jobs/Module/FetchModuleJob.php +++ b/app/Jobs/Module/FetchModuleJob.php @@ -2,7 +2,6 @@ namespace App\Jobs\Module; -use App\Events\ServerEvent; use App\Models\Module; use Exception; use Illuminate\Bus\Queueable; diff --git a/app/Jobs/SendCommonNotificationsJob.php b/app/Jobs/SendCommonNotificationsJob.php index 294e600..0855277 100644 --- a/app/Jobs/SendCommonNotificationsJob.php +++ b/app/Jobs/SendCommonNotificationsJob.php @@ -7,12 +7,10 @@ use App\Notifications\CommonNotification; use GeneaLabs\LaravelModelCaching\CachedBuilder; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; -use Illuminate\Support\Facades\Log; class SendCommonNotificationsJob implements ShouldQueue { diff --git a/app/Models/Admin.php b/app/Models/Admin.php index 175e3e7..81cca80 100644 --- a/app/Models/Admin.php +++ b/app/Models/Admin.php @@ -5,7 +5,6 @@ use Eloquent; use GeneaLabs\LaravelModelCaching\Traits\Cachable; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Support\Carbon; diff --git a/app/Models/Task.php b/app/Models/Task.php index f41406c..6821ff3 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -6,7 +6,6 @@ use App\Exceptions\CommonException; use Eloquent; use GeneaLabs\LaravelModelCaching\CachedBuilder; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Support\Carbon; diff --git a/app/Models/UserGroup.php b/app/Models/UserGroup.php index dbda1d9..b13a2fc 100644 --- a/app/Models/UserGroup.php +++ b/app/Models/UserGroup.php @@ -3,7 +3,6 @@ namespace App\Models; use Carbon\Carbon; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Support\Facades\Cache; diff --git a/app/Notifications/CommonNotification.php b/app/Notifications/CommonNotification.php index 99464b5..a590344 100644 --- a/app/Notifications/CommonNotification.php +++ b/app/Notifications/CommonNotification.php @@ -6,7 +6,6 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; -use Illuminate\Support\Facades\Log; class CommonNotification extends Notification implements ShouldQueue { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 6eb54eb..467e260 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,7 +4,6 @@ use App\Models\PersonalAccessToken; use Illuminate\Pagination\Paginator; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Http; use Illuminate\Support\ServiceProvider; use Laravel\Sanctum\Sanctum;