diff --git a/basket/dto/dto.go b/basket/dto/basket.go similarity index 100% rename from basket/dto/dto.go rename to basket/dto/basket.go diff --git a/basket/entity/entity.go b/basket/entity/basket.go similarity index 100% rename from basket/entity/entity.go rename to basket/entity/basket.go diff --git a/basket/model/basket.go b/basket/model/basket.go new file mode 100644 index 0000000..68605fd --- /dev/null +++ b/basket/model/basket.go @@ -0,0 +1,20 @@ +package basket + +import ( + "time" +) + +type BasketModel struct { + State string `db:"state" json:"state"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty"` +} + +type BasketItemModel struct { + BasketID string `db:"basket_id" json:"basket_id"` + ProductID int `db:"product_id" json:"product_id"` + Quantity int `db:"quantity" json:"quantity"` + Price float64 `db:"price" json:"price"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty"` +} diff --git a/basket/model/model.go b/basket/model/model.go deleted file mode 100644 index 6acffac..0000000 --- a/basket/model/model.go +++ /dev/null @@ -1,22 +0,0 @@ -package basket - -import ( - "github.com/jackc/pgtype" -) - -type BasketModel struct { - // ID string `db:"id" json:"id"` - State string `db:"state" json:"state"` - CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"` - UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"` -} - -type BasketItemModel struct { - // ID string `db:"id" json:"id"` - BasketID string `db:"basket_id" json:"basket_id"` - ProductID int `db:"product_id" json:"product_id"` - Quantity int `db:"quantity" json:"quantity"` - Price float64 `db:"price" json:"price"` - CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"` - UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"` -} diff --git a/catalog/dto/dto.go b/catalog/dto/product.go similarity index 63% rename from catalog/dto/dto.go rename to catalog/dto/product.go index b5ba12a..31a1322 100644 --- a/catalog/dto/dto.go +++ b/catalog/dto/product.go @@ -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"` } diff --git a/catalog/entity/entity.go b/catalog/entity/product.go similarity index 100% rename from catalog/entity/entity.go rename to catalog/entity/product.go diff --git a/catalog/model/model.go b/catalog/model/model.go deleted file mode 100644 index 383a068..0000000 --- a/catalog/model/model.go +++ /dev/null @@ -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"` -} diff --git a/catalog/model/product.go b/catalog/model/product.go new file mode 100644 index 0000000..164ee72 --- /dev/null +++ b/catalog/model/product.go @@ -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"` +} diff --git a/common/dto/error.go b/common/dto/error.go index 324a0c1..f6429ea 100644 --- a/common/dto/error.go +++ b/common/dto/error.go @@ -4,6 +4,6 @@ type ErrorResponseDTO struct { Error string `json:"error"` } -func Error(err string) *ErrorResponseDTO { // FIXME Can DTOs have functions? +func NewError(err string) *ErrorResponseDTO { // FIXME Can DTOs have functions? return &ErrorResponseDTO{err} } diff --git a/common/vo/currency.go b/common/vo/currency.go index 114d287..e1cfe01 100644 --- a/common/vo/currency.go +++ b/common/vo/currency.go @@ -34,7 +34,7 @@ func (c *Currency) Get() *Currency { return curr } - return c.getDefault() + return c.Default() } func (c *Currency) Equals(oc *Currency) bool { diff --git a/identity/dto/dto.go b/identity/dto/auth.go similarity index 100% rename from identity/dto/dto.go rename to identity/dto/auth.go diff --git a/order/dto/dto.go b/order/dto/order.go similarity index 100% rename from order/dto/dto.go rename to order/dto/order.go diff --git a/order/entity/entity.go b/order/entity/order.go similarity index 100% rename from order/entity/entity.go rename to order/entity/order.go diff --git a/order/model/model.go b/order/model/model.go deleted file mode 100644 index ce197e5..0000000 --- a/order/model/model.go +++ /dev/null @@ -1,20 +0,0 @@ -package order - -import "github.com/jackc/pgtype" - -type OrderModel struct { - // ID string `db:"id" json:"id"` - State string `db:"state" json:"state"` - CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"` - UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"` -} - -type OrderItemModel struct { - // ID string `db:"id" json:"id"` - OrderID string `db:"order_id" json:"order_id"` - ProductID int `db:"product_id" json:"product_id"` - Quantity int `db:"quantity" json:"quantity"` - Price float64 `db:"price" json:"price"` - CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"` - UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"` -} diff --git a/order/model/order.go b/order/model/order.go new file mode 100644 index 0000000..069ed30 --- /dev/null +++ b/order/model/order.go @@ -0,0 +1,18 @@ +package order + +import "time" + +type OrderModel struct { + State string `db:"state" json:"state"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty"` +} + +type OrderItemModel struct { + OrderID string `db:"order_id" json:"order_id"` + ProductID int `db:"product_id" json:"product_id"` + Quantity int `db:"quantity" json:"quantity"` + Price float64 `db:"price" json:"price"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty"` +} diff --git a/pricing/dto/dto.go b/pricing/dto/product_price.go similarity index 100% rename from pricing/dto/dto.go rename to pricing/dto/product_price.go diff --git a/pricing/entity/entity.go b/pricing/entity/product_price.go similarity index 100% rename from pricing/entity/entity.go rename to pricing/entity/product_price.go diff --git a/pricing/model/model.go b/pricing/model/product_price.go similarity index 79% rename from pricing/model/model.go rename to pricing/model/product_price.go index 852ecae..f21d2ac 100644 --- a/pricing/model/model.go +++ b/pricing/model/product_price.go @@ -1,7 +1,6 @@ package pricing type ProductPriceModel struct { - // ID int `db:"id"` PID string `db:"pid"` Price int `db:"price"` }