From 3af4a1e298e20a3d315a280bda0d665f482f64ad Mon Sep 17 00:00:00 2001 From: sky121113 Date: Tue, 27 Jan 2026 09:15:05 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E9=96=8B=E7=99=BC?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E8=A6=8F=E7=AF=84=EF=BC=8C=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=9A=B4=E6=A0=BC=E6=A8=A1=E7=B5=84=E5=8C=96=E9=80=9A=E8=A8=8A?= =?UTF-8?q?=E8=A6=8F=E7=AF=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .agent/rules/framework.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.agent/rules/framework.md b/.agent/rules/framework.md index 0b57d23..af04ced 100644 --- a/.agent/rules/framework.md +++ b/.agent/rules/framework.md @@ -65,4 +65,13 @@ trigger: always_on * **執行 PHP 指令**: `./vendor/bin/sail php -v` * **執行 Artisan 指令**: `./vendor/bin/sail artisan route:list` * **執行 Composer**: `./vendor/bin/sail composer install` -* **執行 Node/NPM**: `./vendor/bin/sail npm run dev` \ No newline at end of file +* **執行 Node/NPM**: `./vendor/bin/sail npm run dev` + +## 8. 嚴格模組化通訊規範 (Strict Modular Communication) +為了確保系統的可維護性與獨立性,所有模組必須遵守以下「實體解耦」規範: + +* **禁止跨模組 Eloquent 關聯**:禁止在 Model 中定義指向其他模組的 `belongsTo`, `hasMany` 等關聯。 +* **介面化通訊 (Contracts)**:模組間的資料交換與功能調用必須透過 `app/Modules/{ModuleName}/Contracts/` 下定義的介面進行。 +* **禁止跨模組 Model 引用**:Controller 與 Service 禁止 `use` 其他模組的 Model (除非是該模組自身的 Contracts)。 +* **手動資料水和 (Manual Hydration)**:若頁面需要顯示跨模組資料(例:訂單顯示使用者名稱),Controller 應透過 Service 獲取基本資料,再手動組合成前端所需的 JSON/Props 結構。 +* **資料一致性**:跨模組的資料操作應由各模組的 Service 處理其內部的 transaction 完整性。 \ No newline at end of file