Refactoring

This commit is contained in:
Piotr Biernat
2024-12-06 16:44:42 +01:00
parent 2cf4d4c25d
commit 5a5f643be8
18 changed files with 62 additions and 66 deletions

View File

@@ -4,11 +4,11 @@ import (
"time"
)
type GetProductRequest struct {
type GetProductRequestDTO struct {
ProductID int `json:"product_id"`
}
type GetProductResponse struct {
type GetProductResponseDTO struct {
ID int `json:"id"`
PID string `json:"pid"`
Name string `json:"name"`
@@ -17,30 +17,30 @@ type GetProductResponse struct {
UpdatedAt time.Duration `json:"updated_at,omitempty"`
}
type GetProductListRequest struct {
type GetProductListRequestDTO struct {
CategoryID int `json:"category_id"`
}
type GetProductListResponse struct {
Products []GetProductResponse `json:"products"`
type GetProductListResponseDTO struct {
Products []GetProductResponseDTO `json:"products"`
}
type AddProductToBasketRequest struct {
type AddProductToBasketRequestDTO struct {
ProductID int `json:"product_id"`
Quantity int `json:"quantity"`
}
type AddProductToBasketResponse struct {
type AddProductToBasketResponseDTO struct {
ProductID int `json:"product_id"`
BasketID string `json:"basket_id"`
}
type RemoveProductFromBasketRequest struct {
type RemoveProductFromBasketRequestDTO struct {
ProductID int `json:"product_id"`
Quantity int `json:"quantity"`
}
type RemoveProductFromBasketResponse struct {
type RemoveProductFromBasketResponseDTO struct {
ProductID int `json:"product_id"`
BasketID string `json:"basket_id"`
}

View File

@@ -1,12 +0,0 @@
package model
import "github.com/jackc/pgtype"
type ProductModel struct {
// ID int `db:"id"`
PID string `db:"pid"`
Name string `db:"name"`
Price float64 `db:"price"`
CreatedAt pgtype.Timestamp `db:"created_at"`
UpdatedAt pgtype.Timestamp `db:"updated_at,omitempty"`
}

13
catalog/model/product.go Normal file
View File

@@ -0,0 +1,13 @@
package model
import (
"time"
)
type ProductModel struct {
PID string `db:"pid"`
Name string `db:"name"`
Price float64 `db:"price"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at,omitempty"`
}