基本製品(Base Product)

概要説明

基本製品(Base Product)機能は、指定されたデータセット履歴から製品一覧を取得して表示します。分析や比較に利用できる基礎的な製品情報を提供し、選択したデータセットに存在する「基礎製品データ」を提示することで、他の分析機能の土台となります。

この機能を利用するには、システム上に有効なデータセット履歴が存在し、かつユーザーがそれへアクセスする権限を持っている必要があります。

Swagger リンク

API: Base Products

ケース文書

ケース1: 基本製品リスト取得 成功

説明

有効なデータセット履歴から製品一覧を正常に取得します。

シーケンス図

sequenceDiagram
    participant User
    participant API as ProductAnalyzerController
    participant Service as ProductAnalyzerService
    participant Repo as WishlistDatasetHistoryRepository
    participant DB as Database

    Note over User,DB: Step 1: Request Base Products
    User->>API: GET /api/v1/general/analyzer/{wldh_slug}/products
    
    Note over API,Repo: Step 2: Validate Dataset
    API->>Repo: findBySlug(wldh_slug)
    Repo-->>API: wishlistDatasetHistory
    
    Note over API,Service: Step 3: Retrieve Product Details
    API->>Service: getProductDetailByDatasetId(dataset_id, wishlist_to_group_id, request_data)
    Service->>DB: Query last product details
    DB-->>Service: Product details
    
    Note over Service,API: Step 4: Format Response
    Service-->>API: Product data collection
    
    Note over API,User: Step 5: Return Response
    API-->>User: 200 OK (BaseProductResource collection)

ステップ

ステップ1: 基本製品のリクエスト

  • 説明: データセット履歴に対する基本製品(製品一覧)を要求します
  • リクエスト: GET /api/v1/general/analyzer/{wldh_slug}/products
  • パラメータ:
    • パス: wldh_slug
    • クエリ(任意):
      • search: キーワード
      • per_page: 整数
      • page: 整数

ステップ2: データセットの検証

  • 説明: 要求されたデータセット履歴が存在することを検証します
  • アクション: リポジトリで wldh_slug により履歴を検索
  • 潜在的エラー: Dataset not found

ステップ3: 製品詳細の取得

  • 説明: 対象データセット設定にスコープした最新の製品詳細を取得します
  • アクション: Service で最新の製品詳細を取得
  • 取得されるデータ:
    • 基本的な製品情報
    • 製品属性
    • 関連メタデータ

ステップ4: レスポンスのフォーマット

  • 説明: レスポンス用に製品データを整形します
  • アクション: 製品モデルを BaseProductResource コレクションへ変換
  • 変換内容:
    • 属性の正規化とデータセット固有のメタデータ付与
    • API リソース仕様に沿った構造化

ステップ5: レスポンスの返却

  • 説明: フォーマット済みの製品一覧を返却します
  • レスポンス:
    • 成功: 製品リソースのコレクションを含む 200 OK
    • エラー: 適切なメッセージとステータスコード

アクティビティ図

---
config:
  theme: base
  layout: dagre
  flowchart:
    curve: linear
    htmlLabels: true
  themeVariables:
    edgeLabelBackground: "transparent"
---
flowchart TB
    Client[Client Application]
    API[ProductAnalyzerController]
    Dataset[Dataset Validation]
    Service(ProductAnalyzerService)
    DB[(Database)]

    Client --- Step1[
      <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'>Send GET Request</p>
      </div>
    ]
    Step1 --> API

    API --- Step2[
      <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'>Validate Dataset</p>
      </div>
    ]
    Step2 --> Dataset

    API --- Step3[
      <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'>Query Products</p>
      </div>
    ]
    Step3 --> Service
    Service --> DB
    DB --> Service

    Service --- Step4[
      <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'>4</span>
        <p style='margin-top: 8px'>Format Response</p>
      </div>
    ]
    Step4 --> API

    API --- Step5[
      <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'>5</span>
        <p style='margin-top: 8px'>Send JSON Response</p>
      </div>
    ]
    Step5 --> Client

    %% Styling
    style Client fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style API fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style Dataset fill:#f0f8e6,stroke:#339933,stroke-width:2px
    style Service fill:#f0f8e6,stroke:#339933,stroke-width:2px
    style DB fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
    style Step1 fill:transparent,stroke:transparent,stroke-width:1px
    style Step2 fill:transparent,stroke:transparent,stroke-width:1px
    style Step3 fill:transparent,stroke:transparent,stroke-width:1px
    style Step4 fill:transparent,stroke:transparent,stroke-width:1px
    style Step5 fill:transparent,stroke:transparent,stroke-width:1px

エラーハンドリング

ステータスコード エラーメッセージ 説明
404 "Dataset not found" 指定された wldh_slug が存在しない場合
400 例外メッセージを含む一般的なエラー 処理中に予期しないエラーが発生した場合

追加メモ

  • クエリパラメータによる検索・ページネーションをサポート
  • データセットにスコープしたメタデータを含む BaseProductResource コレクションを返却

データベース関連テーブルとフィールド

erDiagram
    products {
        bigint id PK
        string mall_product_id "External product identifier (Amazon/Rakuten/JAN)"
        bigint category_id FK "Reference to category"
        timestamp created_at
        timestamp updated_at
    }
    product_details {
        bigint id PK
        bigint product_id FK "Reference to products"
        string title "Latest product title"
        string image "Main image URL"
        int price "Current price (nullable)"
        int num_reviews "Total review count (nullable)"
        timestamp crawl_created_at "Crawl timestamp for detail"
        timestamp created_at
        timestamp updated_at
    }

    products ||--o{ product_details : has

エラーハンドリング(補足)

  • ログ

    • 製品リスト取得失敗はアプリケーションログに記録
  • エラー詳細:

    ステータスコード エラーメッセージ 説明
    404 "Dataset not found" 指定されたデータセットスラグが存在しない場合
    400 例外メッセージを含む一般的なエラー 処理中に予期しないエラーが発生した場合

追加メモ(補足)

  • クエリでのフィルタ・ページネーションに対応
  • 大規模データセットではパフォーマンス最適化のためページネーション推奨
  • 本エンドポイントは詳細な製品分析機能の基盤となります