一時ウィッシュリスト検索クエリ管理
説明
一時ウィッシュリスト検索クエリ管理機能は、ユーザーが公式ウィッシュリストに変換する前に一時ウィッシュリストコンテキスト内で検索クエリアイテムを管理できるようにします。このモジュールは、モール固有の検証とキーワード分析サポートを伴う一時ウィッシュリスト検索クエリの一覧表示、追加、削除機能を提供します。
アクティビティ図
---
config:
theme: base
flowchart:
curve: linear
htmlLabels: true
themeVariables:
edgeLabelBackground: "transparent"
---
flowchart TD
Start([ユーザーが一時ウィッシュリストにアクセス])
TempWishlistSearchQueries[(temp_wishlist_search_queries)]
Malls[(malls)]
subgraph Controllers
SearchQueryController[TempWishlistSearchQueryController]
end
subgraph Services
SearchQueryService(TempWishlistSearchQueryService)
end
subgraph Models
SearchQueryModel[[TempWishlistSearchQuery]]
MallModel[[Mall]]
end
Start --> SearchQueryController
SearchQueryController --- 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 --> SearchQueryService
SearchQueryController --- 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 --> SearchQueryService
SearchQueryController --- 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 --> SearchQueryService
SearchQueryService --> SearchQueryModel
SearchQueryModel --> TempWishlistSearchQueries
SearchQueryModel -.-> MallModel
MallModel --> Malls
%% Styling
style SearchQueryController fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
style SearchQueryService fill:#f0f8e6,stroke:#339933,stroke-width:2px
style SearchQueryModel fill:#fff0f5,stroke:#cc6699,stroke-width:2px
style MallModel fill:#fff0f5,stroke:#cc6699,stroke-width:2px
style TempWishlistSearchQueries 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)を含む一時ウィッシュリスト検索クエリのリスト
- 依存関係: 一時ウィッシュリストグループがデータベースに存在する必要がある
ステップ2: モール固有キーワード検証
- 説明: システムがモール固有の要件に対して検索キーワードを検証
- アクション: キーワード形式が選択されたモールに対して有効かチェック
- 入力: 検索キーワードとモールID
- 出力: 検証された検索クエリデータまたは検証エラー
- 依存関係: システム内のモール設定
ステップ3: キーワード分析と正規化
- 説明: システムが検索キーワードを分析し正規化
- アクション: 特殊文字を削除し、スペースを正規化し、最小長をチェック
- 入力: 生の検索キーワード
- 出力: 正規化された検索キーワード
- 依存関係: モール要件に基づくキーワード検証ルール
ステップ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_search_queries {
bigint id PK
bigint temp_wishlist_to_group_id FK
string keyword "検索するキーワード"
bigint mall_id FK
}
malls {
bigint id PK
string name
string slug
}
temp_wishlist_to_groups ||--o{ temp_wishlist_search_queries : "持つ"
malls ||--o{ temp_wishlist_search_queries : "所属"
ケースドキュメント
ケース1: 一時ウィッシュリスト検索クエリ一覧
API: 一時ウィッシュリスト検索クエリ取得
シーケンス図
sequenceDiagram
participant Client
participant Controller as TempWishlistSearchQueryController
participant Service as TempWishlistSearchQueryService
participant Repository as TempWishlistSearchQueryRepository
participant Database
rect rgb(200, 255, 200)
Note right of Client: ハッピーケース - 検索クエリ一覧
Client->>Controller: GET /api/v1/temp-wishlist-search-query?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-search-query?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 TempWishlistSearchQueryController
participant Service as TempWishlistSearchQueryService
participant Repository as TempWishlistSearchQueryRepository
participant Database
rect rgb(200, 255, 200)
Note right of Client: ハッピーケース - 検索クエリ削除
Client->>Controller: DELETE /api/v1/temp-wishlist-search-query/{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-search-query/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-search-query/{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が返却される