Temporary Wishlist Category Management
Description
The Temporary Wishlist Category Management feature enables users to manage category items within a temporary wishlist before converting them to official wishlists. This module provides functionality to list, add, and delete temporary wishlist categories with mall-specific validation and category hierarchy support.
Activity Diagram
---
config:
theme: base
flowchart:
curve: linear
htmlLabels: true
themeVariables:
edgeLabelBackground: "transparent"
---
flowchart TD
Start([User accesses temp wishlist])
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'>List Categories</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'>Add Category</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'>Delete Category</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
Detail Dataflow Dependency
Step-by-Step Process
Step 1: Retrieve Temporary Wishlist Categories
- Description: System retrieves all temporary wishlist categories associated with a specific temporary wishlist group
- Action: Query the database for all categories associated with the temporary wishlist group ID
- Input: Temporary wishlist group ID
- Output: List of temporary wishlist categories with their details (category ID, mall ID, category path)
- Dependencies: Temporary wishlist group must exist in the database
Step 2: Mall-Specific Category Validation
- Description: System validates the category input against mall-specific category hierarchy
- Action: Check if the category ID exists for the selected mall and validate the category path
- Input: Category ID or path and mall ID
- Output: Validated category data or validation error
- Dependencies: Mall and category configuration in the system
Step 3: Category Hierarchy Resolution
- Description: System resolves the full category path based on the category ID
- Action: Retrieve the category hierarchy information from the mall-specific category database
- Input: Category ID and mall ID
- Output: Complete category path information
- Dependencies: Mall-specific category database must be up to date
Step 4: Category Storage/Deletion
- Description: System stores new category or deletes existing category from the temporary wishlist
- Action: Insert new record or delete existing record from the database
- Input: Validated category data or category 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_categories {
bigint id PK
bigint temp_wishlist_to_group_id FK
string category_id "The id of the category in the mall"
bigint mall_id FK
string category_url
}
malls {
bigint id PK
string name
string slug
}
temp_wishlist_to_groups ||--o{ temp_wishlist_categories : "has many"
malls ||--o{ temp_wishlist_categories : "belongs to"
Case Documentation
Case 1: List Temporary Wishlist Categories
API: Get Temporary Wishlist Categories
Sequence Diagram
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: Happy Case - List Categories
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: Return categories
Repository-->>Service: Return categories collection
Service->>Service: Format categories data
Service-->>Controller: Return formatted categories
Controller-->>Client: Return JSON response with categories
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-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: Return empty result
Repository-->>Service: Return empty collection
Service-->>Controller: Return empty collection
Controller-->>Client: Return empty data array
end
end
end
Steps
- Client sends GET request to retrieve temporary wishlist categories for a specific group
- Controller receives the request and calls the service layer
- Service layer fetches categories from the repository using the wishlist group ID
- Repository queries the database and returns the categories collection
- Categories 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 Category
API: Delete Temporary Wishlist Category
Sequence Diagram
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: Happy Case - Delete Category
Client->>Controller: DELETE /api/v1/temp-wishlist-category/{id}
Controller->>Service: delete(id)
Service->>Repository: findById(id)
Repository->>Database: Query WHERE id = ?
Database-->>Repository: Return category
Repository-->>Service: Return category
rect rgb(255, 255, 200)
Note right of Service: Authorization Check
Service->>Service: Verify user can delete category
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 Category Not Found
Client->>Controller: DELETE /api/v1/temp-wishlist-category/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-category/{id}
Controller->>Service: delete(id)
Service->>Repository: findById(id)
Repository->>Database: Query WHERE id = ?
Database-->>Repository: Return category
Repository-->>Service: Return category
Service->>Service: Verify user can delete category
Service-->>Controller: Return unauthorized error
Controller-->>Client: Return 403 Forbidden
end
end
end
Steps
- Client sends DELETE request with the category ID
- Controller receives the request and calls the service layer
- Service layer verifies the category exists and the user has permission to delete it
- If authorized, the category is deleted (typically a soft delete)
- Success response is returned to the client
Error Handling
- If the category ID is not found, a 404 Not Found error is returned
- If the user doesn't have permission to delete the category, a 403 Forbidden error is returned
- If a system error occurs during deletion, a 500 Internal Server Error is returned with an error message