From 957e0aa13a57dc2f8b79a641644fbaffe8511937 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Sat, 8 Nov 2025 01:04:05 +0100 Subject: [PATCH] Refactored time.Duration to time.Time type --- basket/dto/basket.go | 22 +++++++++++----------- catalog/dto/product.go | 31 ++++++++----------------------- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/basket/dto/basket.go b/basket/dto/basket.go index eab4dfe..2d66931 100644 --- a/basket/dto/basket.go +++ b/basket/dto/basket.go @@ -7,23 +7,23 @@ type GetBasketRequestDTO struct { } type GetBasketResponseDTO struct { - ID string `json:"id"` - State string `json:"state"` - CreatedAt time.Duration `json:"created_at"` - UpdatedAt time.Duration `json:"updated_at,omitempty"` + ID string `json:"id"` + State string `json:"state"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` } type GetBasketItemsRequestDTO struct { } type GetBasketItemsResponseDTO struct { - ID string `json:"id"` - BasketID string `json:"basket_id"` - ProductID string `json:"product_id"` - Quantity int `json:"quantity"` - Price float64 `json:"price"` - CreatedAt time.Duration `json:"created_at"` - UpdatedAt time.Duration `json:"updated_at,omitempty"` + ID string `json:"id"` + BasketID string `json:"basket_id"` + ProductID string `json:"product_id"` + Quantity int `json:"quantity"` + Price float64 `json:"price"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` } type AddProductToBasketRequestDTO struct { diff --git a/catalog/dto/product.go b/catalog/dto/product.go index 5d35ea1..41807b0 100644 --- a/catalog/dto/product.go +++ b/catalog/dto/product.go @@ -14,33 +14,18 @@ type GetProductResponseDTO struct { Slug string `json:"slug"` Price float64 `json:"price"` CreatedAt time.Time `json:"created_at"` - UpdatedAt *time.Time `json:"updated_at"` -} - -type GetProductListRequestDTO struct { - CategoryID string `json:"category_id"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` } type GetProductListResponseDTO struct { Products []GetProductResponseDTO `json:"products"` } -type AddProductToBasketRequestDTO struct { - ProductID string `json:"product_id"` - Quantity int `json:"quantity"` -} - -type AddProductToBasketResponseDTO struct { - ProductID string `json:"product_id"` - BasketID string `json:"basket_id"` -} - -type RemoveProductFromBasketRequestDTO struct { - ProductID string `json:"product_id"` - Quantity int `json:"quantity"` -} - -type RemoveProductFromBasketResponseDTO struct { - ProductID string `json:"product_id"` - BasketID string `json:"basket_id"` +type GetProductDetailsResponseDTO struct { + ID string `json:"id"` + SLug string `json:"slug"` + Name string `json:"name"` + Price string `json:"price"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` }