From d740fc5ab8f6564106f7f2fa8908605488624333 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Wed, 6 May 2026 15:47:58 +0800 Subject: [PATCH] =?UTF-8?q?[FEAT]=20=E5=AF=A6=E4=BD=9C=E6=A9=9F=E5=8F=B0?= =?UTF-8?q?=E7=89=A9=E7=90=86=E5=88=AA=E9=99=A4=E5=8A=9F=E8=83=BD=E8=88=87?= =?UTF-8?q?=E8=B3=87=E6=96=99=E5=BA=AB=E7=B5=90=E6=A7=8B=E5=84=AA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 於機台設定頁面新增刪除功能,並限制僅系統管理員 (Super Admin) 可操作。 2. 移除機台模型 (Machine) 的 SoftDeletes Trait,將刪除邏輯改為物理刪除。 3. 建立並執行 Migration 移除 machines 資料表的 deleted_at 欄位。 4. 清除資料庫中原有的 51 筆機台軟刪除紀錄。 5. 更新繁中、英文、日文語系檔,加入機台刪除成功與確認視窗之翻譯。 6. 更新 B000 管理員登入 API 之回應格式,統一包含 success 與 code 欄位。 7. 同步更新 API 技術規格文件 (SKILL.md) 與 api-docs.php 配置。 8. 微調商品新增/編輯頁面之 UI 元件 z-index 層級。 --- .agents/skills/api-technical-specs/SKILL.md | 6 ++-- .../MachineSettingController.php | 15 ++++++++++ .../Api/V1/App/MachineAuthController.php | 14 ++++++++-- app/Models/Machine/Machine.php | 1 - config/api-docs.php | 12 ++++++++ ...55_drop_deleted_at_from_machines_table.php | 28 +++++++++++++++++++ lang/en.json | 2 ++ lang/ja.json | 2 ++ lang/zh_TW.json | 6 ++-- .../machines/partials/tab-machines.blade.php | 20 +++++++++++++ .../views/admin/products/create.blade.php | 4 +-- resources/views/admin/products/edit.blade.php | 4 +-- routes/web.php | 1 + 13 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 database/migrations/2026_05_06_154655_drop_deleted_at_from_machines_table.php diff --git a/.agents/skills/api-technical-specs/SKILL.md b/.agents/skills/api-technical-specs/SKILL.md index 22dee58..24e0de7 100644 --- a/.agents/skills/api-technical-specs/SKILL.md +++ b/.agents/skills/api-technical-specs/SKILL.md @@ -45,13 +45,13 @@ description: 本技能規範定義了 Star Cloud 系統中所有機台 (IoT) 與 | ip | String | 否 | 機台本地 IP | 192.168.1.100 | - **Response Body:** -> [!IMPORTANT] -> 為了相容 Java APP 現有邏輯,這裡嚴格規定成功必須回傳字串 Success。 | 參數 | 類型 | 說明 | 範例 | | :--- | :--- | :--- | :--- | +| success | Boolean | 請求是否成功 | true | +| code | Integer | 業務狀態碼 | 200 | | message | String | 驗證結果 (Success 或 Failed) | Success | -| token | String | **臨時身份認證 Token** (可選,供未來擴充使用) | 1|abcdefg... | +| token | String | **臨時身份認證 Token** (可選,供未來擴充使用) | 1\|abcdefg... | --- diff --git a/app/Http/Controllers/Admin/BasicSettings/MachineSettingController.php b/app/Http/Controllers/Admin/BasicSettings/MachineSettingController.php index 383fc11..fa1dfc8 100644 --- a/app/Http/Controllers/Admin/BasicSettings/MachineSettingController.php +++ b/app/Http/Controllers/Admin/BasicSettings/MachineSettingController.php @@ -375,6 +375,21 @@ class MachineSettingController extends AdminController ]); } + /** + * 刪除機台 (僅限系統管理員) + */ + public function destroy(Machine $machine): RedirectResponse + { + if (!auth()->user()->isSystemAdmin()) { + abort(403); + } + + $machine->delete(); + + return redirect()->route('admin.basic-settings.machines.index') + ->with('success', __('Machine deleted successfully.')); + } + /** * 公開機台分布地圖 */ diff --git a/app/Http/Controllers/Api/V1/App/MachineAuthController.php b/app/Http/Controllers/Api/V1/App/MachineAuthController.php index 0820d2a..075f3d9 100644 --- a/app/Http/Controllers/Api/V1/App/MachineAuthController.php +++ b/app/Http/Controllers/Api/V1/App/MachineAuthController.php @@ -51,7 +51,11 @@ class MachineAuthController extends Controller 'login' ); - return response()->json(['message' => 'Failed']); + return response()->json([ + 'success' => false, + 'code' => 401, + 'message' => 'Failed' + ], 401); } // 5. RBAC 權限驗證 (遵循多租戶與機台授權規範) @@ -83,7 +87,11 @@ class MachineAuthController extends Controller 'login' ); - return response()->json(['message' => 'Forbidden']); + return response()->json([ + 'success' => false, + 'code' => 403, + 'message' => 'Forbidden' + ], 403); } // 6. 驗證完美通過! @@ -103,6 +111,8 @@ class MachineAuthController extends Controller ); return response()->json([ + 'success' => true, + 'code' => 200, 'message' => 'Success', 'token' => $user->createToken('technician-setup', ['*'], now()->addHours(8))->plainTextToken ]); diff --git a/app/Models/Machine/Machine.php b/app/Models/Machine/Machine.php index 42d1eca..0f17f40 100644 --- a/app/Models/Machine/Machine.php +++ b/app/Models/Machine/Machine.php @@ -10,7 +10,6 @@ use App\Traits\TenantScoped; class Machine extends Model { use HasFactory, TenantScoped; - use \Illuminate\Database\Eloquent\SoftDeletes; protected static function booted() { diff --git a/config/api-docs.php b/config/api-docs.php index 5ffe4c2..ac4dbfe 100644 --- a/config/api-docs.php +++ b/config/api-docs.php @@ -40,6 +40,16 @@ return [ ], ], 'response_parameters' => [ + 'success' => [ + 'type' => 'boolean', + 'description' => '請求是否成功', + 'example' => true + ], + 'code' => [ + 'type' => 'integer', + 'description' => '業務狀態碼', + 'example' => 200 + ], 'message' => [ 'type' => 'string', 'description' => '回應訊息', @@ -57,6 +67,8 @@ return [ 'ip' => '192.168.1.100' ], 'response' => [ + 'success' => true, + 'code' => 200, 'message' => 'Success', 'token' => '1|abcdefg...' ], diff --git a/database/migrations/2026_05_06_154655_drop_deleted_at_from_machines_table.php b/database/migrations/2026_05_06_154655_drop_deleted_at_from_machines_table.php new file mode 100644 index 0000000..f3f4083 --- /dev/null +++ b/database/migrations/2026_05_06_154655_drop_deleted_at_from_machines_table.php @@ -0,0 +1,28 @@ +dropColumn('deleted_at'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('machines', function (Blueprint $table) { + $table->softDeletes(); + }); + } +}; diff --git a/lang/en.json b/lang/en.json index 7e0147c..39a2fab 100644 --- a/lang/en.json +++ b/lang/en.json @@ -138,6 +138,7 @@ "Are you sure you want to remove this assignment?": "Are you sure you want to remove this assignment?", "Are you sure you want to send this command?": "Are you sure you want to send this command?", "Are you sure you want to start delivery?": "Are you sure you want to start delivery?", + "Are you sure you want to delete this machine? This action cannot be undone.": "Are you sure you want to delete this machine? This action cannot be undone.", "Are you sure?": "Are you sure?", "Assign": "Assign", "Assign Advertisement": "Assign Advertisement", @@ -715,6 +716,7 @@ "Machine to Warehouse": "Machine to Warehouse", "Machine to warehouse returns": "Machine to warehouse returns", "Machine updated successfully.": "Machine updated successfully.", + "Machine deleted successfully.": "Machine deleted successfully.", "Machines": "Machines", "Machines Online": "Machines Online", "Main": "Main", diff --git a/lang/ja.json b/lang/ja.json index bfda6ec..8984029 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -138,6 +138,7 @@ "Are you sure you want to remove this assignment?": "Are you sure you want to remove this assignment?", "Are you sure you want to send this command?": "Are you sure you want to send this command?", "Are you sure you want to start delivery?": "配送を開始しますか?", + "Are you sure you want to delete this machine? This action cannot be undone.": "この機台を削除してもよろしいですか?この操作は取り消せません。", "Are you sure?": "Are you sure?", "Assign": "Assign", "Assign Advertisement": "Assign Advertisement", @@ -714,6 +715,7 @@ "Machine to Warehouse": "機台から倉庫", "Machine to warehouse returns": "Machine to warehouse returns", "Machine updated successfully.": "Machine updated successfully.", + "Machine deleted successfully.": "機台が正常に削除されました。", "Machines": "Machines", "Machines Online": "Machines Online", "Main": "総倉庫", diff --git a/lang/zh_TW.json b/lang/zh_TW.json index a980ded..a27fb66 100644 --- a/lang/zh_TW.json +++ b/lang/zh_TW.json @@ -142,7 +142,8 @@ "Are you sure you want to resolve all recent issues for this machine?": "您確定要排除此機台目前所有的異常紀錄嗎?這將會恢復機台狀態為正常。", "Are you sure you want to send this command?": "確定要發送此指令嗎?", "Are you sure you want to start delivery?": "確定要開始配送嗎?", - "Are you sure?": "確定要執行此操作嗎?", + "Are you sure you want to delete this machine? This action cannot be undone.": "您確定要刪除此機台嗎?此操作將無法復原。", + "Are you sure?": "您確定嗎?", "Assign": "分配所屬機台", "Assign Advertisement": "投放廣告", "Assign Machines": "分配機台", @@ -815,7 +816,8 @@ "Machine to Warehouse": "機台對倉庫", "Machine to warehouse returns": "機台退回倉庫", "Machine updated successfully.": "機台更新成功。", - "Machines": "機台列表", + "Machine deleted successfully.": "機台已成功刪除。", + "Machines": "機台管理", "Machines Online": "在線機台數", "Main": "總倉", "Main Warehouses": "總倉數量", diff --git a/resources/views/admin/basic-settings/machines/partials/tab-machines.blade.php b/resources/views/admin/basic-settings/machines/partials/tab-machines.blade.php index acb9c71..6d44742 100644 --- a/resources/views/admin/basic-settings/machines/partials/tab-machines.blade.php +++ b/resources/views/admin/basic-settings/machines/partials/tab-machines.blade.php @@ -134,6 +134,16 @@ + @if(auth()->user()->isSystemAdmin()) + + @endif @@ -226,6 +236,16 @@ + @if(auth()->user()->isSystemAdmin()) + + @endif @empty diff --git a/resources/views/admin/products/create.blade.php b/resources/views/admin/products/create.blade.php index b4a7b4c..a3e8627 100644 --- a/resources/views/admin/products/create.blade.php +++ b/resources/views/admin/products/create.blade.php @@ -47,7 +47,7 @@