feat: Introduce UpdateVariantRequest DTO for updating product variants #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several updates to enhance the handling of product variants across the backend and frontend. The changes include the addition of a new
UpdateVariantRequeststructure, updates to request parameter handling, and improvements to error handling for variant-related operations.Backend Changes
Data Structures:
UpdateVariantRequeststruct to represent the data needed to update an existing product variant ininternal/dto/product.go. This includes fields forSKU,Price,Stock,Attributes,Images, andIsDefault.API Endpoint Logic:
UpdateVariantandDeleteVariantmethods ininternal/interfaces/api/handler/product_handler.goto useproductIdandvariantIdinstead ofidandvariant_idfor URL parameters. [1] [2] [3] [4]CreateVariantRequestwithUpdateVariantRequestin theUpdateVariantmethod and added conditional checks to handle optional fields (Price,Stock,IsDefault). [1] [2]AddVariant,UpdateVariant, andDeleteVariantmethods by removing seller-specific authorization checks and refining error messages for better clarity. [1] [2] [3]Frontend Changes
Type Definitions:
UpdateVariantRequestinterface inweb/types/api.tsto mirror the backend structure for updating product variants. This includes fields forsku,price,stock,attributes,images, andis_default.