Temporary Wishlist Product Management

Description

The Temporary Wishlist Product Management feature allows users to manage product items within a temporary wishlist context before converting them to official wishlists. This module provides capabilities to list, add, and delete temporary wishlist products with support for multiple input types (JAN code, ASIN, Rakuten ID) and mall-specific validation.

Activity Diagram

---
config:
  theme: base
  flowchart:
    curve: linear
    htmlLabels: true
  themeVariables:
    edgeLabelBackground: "transparent"
---
flowchart TD
    Start([User accesses temp wishlist])
    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'>List Products</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'>Add Product</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'>Delete Product</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

Detail Dataflow Dependency

Step-by-Step Process

Step 1: Retrieve Temporary Wishlist Products

  • Description: System retrieves all temporary wishlist products associated with a specific temporary wishlist group
  • Action: Query the database for all products associated with the temporary wishlist group ID
  • Input: Temporary wishlist group ID
  • Output: List of temporary wishlist products with their details (input, input type, mall ID, product URL)
  • Dependencies: Temporary wishlist group must exist in the database

Step 2: Product Input Processing

  • Description: System processes the product input based on the selected input type
  • Action: Validate and format the input according to the input type requirements
  • Input: Product input value (JAN, ASIN, Rakuten ID) and input type
  • Output: Validated product data
  • Dependencies: Valid input format for the selected input type

Step 3: Mall-Specific Validation

  • Description: System validates the product input against mall-specific requirements
  • Action: Check if the input matches the format requirements for the selected mall
  • Input: Validated product data and mall ID
  • Output: Mall-validated product data or validation error
  • Dependencies: Mall configuration in the system

Step 4: Product Storage/Deletion

  • Description: System stores new product or deletes existing product from the temporary wishlist
  • Action: Insert new record or delete existing record from the database
  • Input: Validated product data or product ID to delete
  • Output: Success message or error message
  • Dependencies: Valid database connection and proper authorization

Database Related Tables & Fields

Database: gb_console

erDiagram
    temp_wishlist_to_groups {
        bigint id PK
        bigint user_id FK
        bigint group_id FK
        string name "Name of the wishlist"
        string slug "Slug of the wishlist"
        tinyInteger status "1: Temporary Save, 2: CSV Import Draft"
    }
    
    temp_wishlist_products {
        bigint id PK
        bigint temp_wishlist_to_group_id FK
        string input "The input of the product"
        string input_type "The type of the input: jan, asin, rakuten_id"
        string product_url "The url of the product"
        bigint mall_id FK
        string pair_id
    }
    
    malls {
        bigint id PK
        string name
        string slug
    }

    temp_wishlist_to_groups ||--o{ temp_wishlist_products : "has many"
    malls ||--o{ temp_wishlist_products : "belongs to"

Case Documentation

Case 1: List Temporary Wishlist Products

API: Get Temporary Wishlist Products

Sequence Diagram

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: Happy Case - List Products
    
    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: Return products
    Repository-->>Service: Return products collection
    
    Service->>Service: Format products data
    Service-->>Controller: Return formatted products
    Controller-->>Client: Return JSON response with products
    end
    
    rect rgb(255, 200, 200)
    Note right of Client: Error Handling
    
    rect rgb(255, 230, 230)
    alt Invalid wishlist group 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: Return empty result
        Repository-->>Service: Return empty collection
        Service-->>Controller: Return empty collection
        Controller-->>Client: Return empty data array
    end
    end
    end

Steps

  1. Client sends GET request to retrieve temporary wishlist products for a specific group
  2. Controller receives the request and calls the service layer
  3. Service layer fetches products from the repository using the wishlist group ID
  4. Repository queries the database and returns the products collection
  5. Products are formatted and returned to the client as a JSON response

Error Handling

  • If the wishlist group ID is invalid or not found, an empty data array is returned
  • If the user doesn't have permission to access the wishlist group, a 403 Forbidden error is returned
  • If a system error occurs, a 500 Internal Server Error is returned with an error message

Case 2: Delete Temporary Wishlist Product

API: Delete Temporary Wishlist Product

Sequence Diagram

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: Happy Case - Delete Product
    
    Client->>Controller: DELETE /api/v1/temp-wishlist-product/{id}
    Controller->>Service: delete(id)
    
    Service->>Repository: findById(id)
    Repository->>Database: Query WHERE id = ?
    Database-->>Repository: Return product
    Repository-->>Service: Return product
    
    rect rgb(255, 255, 200)
    Note right of Service: Authorization Check
    Service->>Service: Verify user can delete product
    end
    
    Service->>Repository: delete(id)
    Repository->>Database: DELETE/Soft Delete WHERE id = ?
    Database-->>Repository: Confirm deletion
    Repository-->>Service: Return success
    
    Service-->>Controller: Return success result
    Controller-->>Client: Return success JSON response
    end
    
    rect rgb(255, 200, 200)
    Note right of Client: Error Handling
    
    rect rgb(255, 230, 230)
    alt Product Not Found
        Client->>Controller: DELETE /api/v1/temp-wishlist-product/999999
        Controller->>Service: delete(id)
        Service->>Repository: findById(id)
        Repository->>Database: Query WHERE id = ?
        Database-->>Repository: Return null
        Repository-->>Service: Return null
        Service-->>Controller: Return not found error
        Controller-->>Client: Return 404 Not Found
    else Unauthorized Access
        Client->>Controller: DELETE /api/v1/temp-wishlist-product/{id}
        Controller->>Service: delete(id)
        Service->>Repository: findById(id)
        Repository->>Database: Query WHERE id = ?
        Database-->>Repository: Return product
        Repository-->>Service: Return product
        Service->>Service: Verify user can delete product
        Service-->>Controller: Return unauthorized error
        Controller-->>Client: Return 403 Forbidden
    end
    end
    end

Steps

  1. Client sends DELETE request with the product ID
  2. Controller receives the request and calls the service layer
  3. Service layer verifies the product exists and the user has permission to delete it
  4. If authorized, the product is deleted (typically a soft delete)
  5. Success response is returned to the client

Error Handling

  • If the product ID is not found, a 404 Not Found error is returned
  • If the user doesn't have permission to delete the product, a 403 Forbidden error is returned
  • If a system error occurs during deletion, a 500 Internal Server Error is returned with an error message