一時ウィッシュリスト商品管理
説明
一時ウィッシュリスト商品管理機能は、ユーザーが公式ウィッシュリストに変換する前に一時ウィッシュリストコンテキスト内で商品アイテムを管理できるようにします。このモジュールは、複数の入力タイプ(JANコード、ASIN、楽天ID)とモール固有の検証をサポートして、一時ウィッシュリスト商品の一覧表示、追加、削除機能を提供します。
アクティビティ図
---
config:
theme: base
flowchart:
curve: linear
htmlLabels: true
themeVariables:
edgeLabelBackground: "transparent"
---
flowchart TD
Start([ユーザーが一時ウィッシュリストにアクセス])
TempWishlistProducts[(temp_wishlist_products)]
Malls[(malls)]
subgraph Controllers
ProductController[TempWishlistProductController]
end
subgraph Services
ProductService(TempWishlistProductService)
end
subgraph Models
ProductModel[[TempWishlistProduct]]
MallModel[[Mall]]
end
Start --> ProductController
ProductController --- 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 --> ProductService
ProductController --- 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 --> ProductService
ProductController --- 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 --> ProductService
ProductService --> ProductModel
ProductModel --> TempWishlistProducts
ProductModel -.-> MallModel
MallModel --> Malls
%% Styling
style ProductController fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
style ProductService fill:#f0f8e6,stroke:#339933,stroke-width:2px
style ProductModel fill:#fff0f5,stroke:#cc6699,stroke-width:2px
style MallModel fill:#fff0f5,stroke:#cc6699,stroke-width:2px
style TempWishlistProducts 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、商品URL)を含む一時ウィッシュリスト商品のリスト
- 依存関係: 一時ウィッシュリストグループがデータベースに存在する必要がある
ステップ2: 商品入力処理
- 説明: システムが選択された入力タイプに基づいて商品入力を処理
- アクション: 入力タイプ要件に従って入力を検証・フォーマット
- 入力: 商品入力値(JAN、ASIN、楽天ID)と入力タイプ
- 出力: 検証された商品データ
- 依存関係: 選択された入力タイプの有効な入力形式
ステップ3: モール固有検証
- 説明: システムがモール固有要件に対して商品入力を検証
- アクション: 入力が選択されたモールの形式要件に一致するかチェック
- 入力: 検証された商品データとモール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_products {
bigint id PK
bigint temp_wishlist_to_group_id FK
string input "商品の入力"
string input_type "入力のタイプ: jan, asin, rakuten_id"
string product_url "商品のURL"
bigint mall_id FK
string pair_id
}
malls {
bigint id PK
string name
string slug
}
temp_wishlist_to_groups ||--o{ temp_wishlist_products : "持つ"
malls ||--o{ temp_wishlist_products : "所属"
ケースドキュメント
ケース1: 一時ウィッシュリスト商品一覧
API: 一時ウィッシュリスト商品取得
シーケンス図
sequenceDiagram
participant Client
participant Controller as TempWishlistProductController
participant Service as TempWishlistProductService
participant Repository as TempWishlistProductRepository
participant Database
rect rgb(200, 255, 200)
Note right of Client: ハッピーケース - 商品一覧
Client->>Controller: GET /api/v1/temp-wishlist-product?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-product?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 TempWishlistProductController
participant Service as TempWishlistProductService
participant Repository as TempWishlistProductRepository
participant Database
rect rgb(200, 255, 200)
Note right of Client: ハッピーケース - 商品削除
Client->>Controller: DELETE /api/v1/temp-wishlist-product/{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-product/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-product/{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が返却される