Aile 聊天室類型完整規格說明書
版本: v1.0
最後更新: 2026-06-13
服務核心: aile-service-room(策略工廠模式)
1. 概述
Aile 系統採用**策略工廠模式(Strategy Factory Pattern)**管理 12 種聊天室類型。每種類型由一個獨立的 RoomStrategy 實現類處理,透過 @Component(RoomType.XXX) 註冊到 RoomFactory.strategyMap,執行時依 RoomModel.type 動態分發。
1.1 架構設計
RoomFactory.strategyMap (Map<type, RoomStrategy>)
│
├── person → PersonRoomImpl
├── accountPerson → AccountPersonRoomImpl
├── friend → FriendRoomImpl
├── group → GroupRoomImpl
├── discuss → DiscussRoomImpl
├── services → ServiceRoomImpl
├── serviceMember → ServiceMemberRoomImpl
├── business → BusinessRoomImpl
├── aileSystem → AileSystemRoomImpl
├── aiwowSystem → AiwowSystemRoomImpl
├── system → SystemRoomImpl
└── lineGroup → LineGroupRoomImpl
2. RoomModel(聊天室通用模型)
MongoDB 集合:aile.room
@Document("aile.room")
public class RoomModel extends BaseModel {
String name; // 聊天室名稱
String type; // 聊天室類型(12 種之一)
String tenantId; // 租戶 ID
String accountId; // 帳號 ID(創建者)
String ownerId; // 擁有者 ID
Boolean isCustomName; // 是否自定義名稱
String avatarId; // 頭像 ID
String serviceNumberId; // 服務號 ID(服務號相關聊天室使用)
Boolean isExternal; // 服務號是否對外
Long lastSequence; // 最後消息序號
RoomStatus status; // 聊天室狀態
MessageVO lastMessage; // 最後一條消息快照
String homePagePicId; // 首頁背景圖 ID
// 物件(Business)相關
String businessId; // 業務物件 ID
String businessName; // 物件名稱
BusinessStatus businessStatus; // 物件狀態
String businessDescription; // 物件描述
Long businessEndTime; // 物件結束時間
Long businessCompleteTime; // 物件完成時間
String mainRoomId; // 主聊天室 ID(Business 子房用)
String mergeTargetRoomId; // 合併目標聊天室 ID(Saga 合併後使用)
String lineGroupId; // LINE 群組 ID(LineGroup 專用)
}
2.1 RoomStatus(聊天室狀態)
| 狀態 | 說明 |
|---|---|
Enable | 正常啟用 |
Disable | 被禁用(附禁用時長) |
Delete | 已刪除(軟刪除) |
Danger | 不安全,有風險 |
Complaint | 被檢舉 |
Forbid | 被禁言 |
Block | 被封鎖 |
2.2 BusinessStatus(物件狀態,Business 類聊天室使用)
| 狀態 | 說明 |
|---|---|
Pending | 尚未開始 |
Progress | 進行中 |
Revision | 返回修改 |
Complete | 已完成 |
3. 12 種聊天室類型詳解
3.1 person — 個人聊天室
| 屬性 | 值 |
|---|---|
| 策略實現 | PersonRoomImpl |
| 成員範圍 | 僅創建者本人 |
| 用途 | 個人筆記、草稿、待辦提醒、系統通知收納 |
| isMulti | ❌ |
| isAccountRoom | ❌ |
設計意圖: 每個 Account 有一個 person 聊天室(AccountModel.personRoomId 指向),用於系統向該帳號推送個人化消息。
消息發送規則: 僅向房間內的所有成員(即本人)發送。
3.2 accountPerson — 帳號 個人聊天室
| 屬性 | 值 |
|---|---|
| 策略實現 | AccountPersonRoomImpl |
| 成員範圍 | 僅帳號本人 |
| 用途 | 跨租戶的帳號級系統通知(如生態邀請、系統公告) |
| isMulti | ❌ |
| isAccountRoom | ✅ |
設計意圖: 比 person 更上層的帳號級聊天室,不依附於任何租戶。用於 Aile 生態級系統消息。
3.3 friend — 好友聊天室
| 屬性 | 值 |
|---|---|
| 策略實現 | FriendRoomImpl |
| 成員範圍 | 2 人 |
| 用途 | 員工之間的一對一私聊 |
| isMulti | ❌ |
| isAccountRoom | ❌ |
設計意圖: 租戶內部兩位員工之間的私聊頻道。固定雙人,不可擴充成員。
3.4 group — 群組聊天室
| 屬性 | 值 |
|---|---|
| 策略實現 | GroupRoomImpl |
| 成員範圍 | 多人(≥3) |
| 用途 |