一時ウィッシュリストカテゴリ管理
説明
一時ウィッシュリストカテゴリ管理機能は、ユーザーが公式ウィッシュリストに変換する前に一時ウィッシュリストコンテキスト内でカテゴリアイテムを管理できるようにします。このモジュールは、モール固有の検証とカテゴリ階層サポートを伴う一時ウィッシュリストカテゴリの一覧表示、追加、削除機能を提供します。
アクティビティ図
---
config:
theme: base
flowchart:
curve: linear
htmlLabels: true
themeVariables:
edgeLabelBackground: "transparent"
---
flowchart TD
Start([ユーザーが一時ウィッシュリストにアクセス])
TempWishlistCategories[(temp_wishlist_categories)]
Malls[(malls)]
subgraph Controllers
CategoryController[TempWishlistCategoryController]
end
subgraph Services
CategoryService(TempWishlistCategoryService)
end
subgraph Models
CategoryModel[[TempWishlistCategory]]
MallModel[[Mall]]
end
Start --> CategoryController
CategoryController --- ListStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>1</span>
<p style='margin-top: 8px'>カテゴリ一覧</p>
</div>
]
ListStep --> CategoryService
CategoryController --- AddStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>2</span>
<p style='margin-top: 8px'>カテゴリ追加</p>
</div>
]
AddStep --> CategoryService
CategoryController --- DeleteStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>3</span>
<p style='margin-top: 8px'>カテゴリ削除</p>
</div>
]
DeleteStep --> CategoryService
CategoryService --> CategoryModel
CategoryModel --> TempWishlistCategories
CategoryModel -.-> MallModel
MallModel --> Malls
%% Styling
style CategoryController fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
style CategoryService fill:#f0f8e6,stroke:#339933,stroke-width:2px
style CategoryModel fill:#fff0f5,stroke:#cc6699,stroke-width:2px
style MallModel fill:#fff0f5,stroke:#cc6699,stroke-width:2px
style TempWishlistCategories fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
style Malls fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
style ListStep fill:transparent,stroke:transparent,stroke-width:1px
style AddStep fill:transparent,stroke:transparent,stroke-width:1px
style DeleteStep fill:transparent,stroke:transparent,stroke-width:1px
詳細データフロー依存関係
ステップバイステッププロセス
ステップ1: 一時ウィッシュリストカテゴリ取得
- 説明: システムが特定の一時ウィッシュリストグループに関連付けられたすべての一時ウィッシュリストカテゴリを取得
- アクション: 一時ウィッシュリストグループIDに関連付けられたすべてのカテゴリをデータベースからクエリ
- 入力: 一時ウィッシュリストグループID
- 出力: 詳細(カテゴリID、モールID、カテゴリパス)を含む一時ウィッシュリストカテゴリのリスト
- 依存関係: 一時ウィッシュリストグループがデータベースに存在する必要がある
ステップ2: モール固有カテゴリ検証
- 説明: システムがモール固有のカテゴリ階層に対してカテゴリ入力を検証
- アクション: カテゴリIDが選択されたモールに存在するかチェックし、カテゴリパスを検証
- 入力: カテゴリIDまたはパスとモールID
- 出力: 検証されたカテゴリデータまたは検証エラー
- 依存関係: システム内のモールとカテゴリ設定
ステップ3: カテゴリ階層解決
- 説明: システムがカテゴリIDに基づいて完全なカテゴリパスを解決
- アクション: モール固有のカテゴリデータベースからカテゴリ階層情報を取得
- 入力: カテゴリIDとモールID
- 出力: 完全なカテゴリパス情報
- 依存関係: モール固有のカテゴリデータベースが最新である必要がある
ステップ4: カテゴリ保存/削除
- 説明: システムが新しいカテゴリを保存または一時ウィッシュリストから既存カテゴリを削除
- アクション: データベースに新しいレコードを挿入または既存レコードを削除
- 入力: 検証されたカテゴリデータまたは削除するカテゴリID
- 出力: 成功メッセージまたはエラーメッセージ
- 依存関係: 有効なデータベース接続と適切な認可
データベース関連テーブル・フィールド
データベース: gb_console
erDiagram
temp_wishlist_to_groups {
bigint id PK
bigint user_id FK
bigint group_id FK
string name "ウィッシュリストの名前"
string slug "ウィッシュリストのスラッグ"
tinyInteger status "1: 一時保存, 2: CSVインポートドラフト"
}
temp_wishlist_categories {
bigint id PK
bigint temp_wishlist_to_group_id FK
string category_id "モール内のカテゴリID"
bigint mall_id FK
string category_url
}
malls {
bigint id PK
string name
string slug
}
temp_wishlist_to_groups ||--o{ temp_wishlist_categories : "持つ"
malls ||--o{ temp_wishlist_categories : "所属"
ケースドキュメント
ケース1: 一時ウィッシュリストカテゴリ一覧
API: 一時ウィッシュリストカテゴリ取得
シーケンス図
sequenceDiagram
participant Client
participant Controller as TempWishlistCategoryController
participant Service as TempWishlistCategoryService
participant Repository as TempWishlistCategoryRepository
participant Database
rect rgb(200, 255, 200)
Note right of Client: ハッピーケース - カテゴリ一覧
Client->>Controller: GET /api/v1/temp-wishlist-category?temp_wishlist_to_group_id={id}
Controller->>Service: list(params)
Service->>Repository: getByWishlistToGroupId(wishlistToGroupId)
Repository->>Database: Query WHERE temp_wishlist_to_group_id = ?
Database-->>Repository: カテゴリを返却
Repository-->>Service: カテゴリコレクションを返却
Service->>Service: カテゴリデータをフォーマット
Service-->>Controller: フォーマットされたカテゴリを返却
Controller-->>Client: カテゴリ付きJSONレスポンスを返却
end
rect rgb(255, 200, 200)
Note right of Client: エラーハンドリング
rect rgb(255, 230, 230)
alt 無効なウィッシュリストグループID
Client->>Controller: GET /api/v1/temp-wishlist-category?temp_wishlist_to_group_id=invalid
Controller->>Service: list(params)
Service->>Repository: getByWishlistToGroupId(wishlistToGroupId)
Repository->>Database: Query WHERE temp_wishlist_to_group_id = ?
Database-->>Repository: 空の結果を返却
Repository-->>Service: 空のコレクションを返却
Service-->>Controller: 空のコレクションを返却
Controller-->>Client: 空のデータ配列を返却
end
end
end
ステップ
- クライアントが特定のグループの一時ウィッシュリストカテゴリを取得するGETリクエストを送信
- コントローラーがリクエストを受信し、サービス層を呼び出し
- サービス層がウィッシュリストグループIDを使用してリポジトリからカテゴリを取得
- リポジトリがデータベースをクエリし、カテゴリコレクションを返却
- カテゴリがフォーマットされ、JSONレスポンスとしてクライアントに返却
エラーハンドリング
- ウィッシュリストグループIDが無効または見つからない場合、空のデータ配列が返却される
- ユーザーがウィッシュリストグループにアクセスする権限がない場合、403 Forbiddenエラーが返却される
- システムエラーが発生した場合、エラーメッセージ付きの500 Internal Server Errorが返却される
ケース2: 一時ウィッシュリストカテゴリ削除
API: 一時ウィッシュリストカテゴリ削除
シーケンス図
sequenceDiagram
participant Client
participant Controller as TempWishlistCategoryController
participant Service as TempWishlistCategoryService
participant Repository as TempWishlistCategoryRepository
participant Database
rect rgb(200, 255, 200)
Note right of Client: ハッピーケース - カテゴリ削除
Client->>Controller: DELETE /api/v1/temp-wishlist-category/{id}
Controller->>Service: delete(id)
Service->>Repository: findById(id)
Repository->>Database: Query WHERE id = ?
Database-->>Repository: カテゴリを返却
Repository-->>Service: カテゴリを返却
rect rgb(255, 255, 200)
Note right of Service: 認可チェック
Service->>Service: ユーザーがカテゴリを削除できるか検証
end
Service->>Repository: delete(id)
Repository->>Database: DELETE/Soft Delete WHERE id = ?
Database-->>Repository: 削除を確認
Repository-->>Service: 成功を返却
Service-->>Controller: 成功結果を返却
Controller-->>Client: 成功JSONレスポンスを返却
end
rect rgb(255, 200, 200)
Note right of Client: エラーハンドリング
rect rgb(255, 230, 230)
alt カテゴリが見つからない
Client->>Controller: DELETE /api/v1/temp-wishlist-category/999999
Controller->>Service: delete(id)
Service->>Repository: findById(id)
Repository->>Database: Query WHERE id = ?
Database-->>Repository: nullを返却
Repository-->>Service: nullを返却
Service-->>Controller: 見つからないエラーを返却
Controller-->>Client: 404 Not Foundを返却
else 未認可アクセス
Client->>Controller: DELETE /api/v1/temp-wishlist-category/{id}
Controller->>Service: delete(id)
Service->>Repository: findById(id)
Repository->>Database: Query WHERE id = ?
Database-->>Repository: カテゴリを返却
Repository-->>Service: カテゴリを返却
Service->>Service: ユーザーがカテゴリを削除できるか検証
Service-->>Controller: 未認可エラーを返却
Controller-->>Client: 403 Forbiddenを返却
end
end
end
ステップ
- クライアントがカテゴリIDを含むDELETEリクエストを送信
- コントローラーがリクエストを受信し、サービス層を呼び出し
- サービス層がカテゴリが存在し、ユーザーが削除権限を持つことを検証
- 認可されている場合、カテゴリが削除される(通常はソフト削除)
- 成功レスポンスがクライアントに返却される
エラーハンドリング
- カテゴリIDが見つからない場合、404 Not Foundエラーが返却される
- ユーザーがカテゴリを削除する権限がない場合、403 Forbiddenエラーが返却される
- 削除中にシステムエラーが発生した場合、エラーメッセージ付きの500 Internal Server Errorが返却される