Compare commits

..

11 Commits

Author SHA1 Message Date
edd980f4c1 basket update 2022-12-22 23:01:11 +01:00
2e64d106aa basket update 2022-12-22 20:59:47 +01:00
cb2e0ac34e models update 2022-12-22 20:49:12 +01:00
735f2d668c basket update 2022-12-22 17:38:52 +01:00
2f71ff408d basket update 2022-12-22 17:33:58 +01:00
0c99855748 basket update 2022-12-22 17:31:32 +01:00
b63cf00c33 order update 2022-12-22 15:05:21 +01:00
e9d0fe8960 basket update 2022-12-22 14:05:52 +01:00
73ecb0aa7e basket update 2022-12-22 14:04:01 +01:00
d614a907b5 basket update 2022-12-22 13:59:08 +01:00
597e72169a basket update 2022-12-22 13:53:17 +01:00
4 changed files with 35 additions and 14 deletions

View File

@@ -10,7 +10,7 @@ type GetBasketResponse struct {
ID string `json:"id"` ID string `json:"id"`
State string `json:"state"` State string `json:"state"`
CreatedAt time.Duration `json:"created_at"` CreatedAt time.Duration `json:"created_at"`
UpdatedAt time.Duration `json:"updated_at"` UpdatedAt time.Duration `json:"updated_at,omitempty"`
} }
type GetBasketItemsRequest struct { type GetBasketItemsRequest struct {
@@ -23,7 +23,7 @@ type GetBasketItemsResponse struct {
Quantity int `json:"quantity"` Quantity int `json:"quantity"`
Price float64 `json:"price"` Price float64 `json:"price"`
CreatedAt time.Duration `json:"created_at"` CreatedAt time.Duration `json:"created_at"`
UpdatedAt time.Duration `json:"updated_at"` UpdatedAt time.Duration `json:"updated_at,omitempty"`
} }
type BasketCheckoutRequest struct { type BasketCheckoutRequest struct {
@@ -31,5 +31,5 @@ type BasketCheckoutRequest struct {
} }
type BasketCheckoutResponse struct { type BasketCheckoutResponse struct {
ID string `json:"order_id"` ID string `json:"basket_id"`
} }

View File

@@ -5,17 +5,18 @@ import (
) )
type BasketModel struct { type BasketModel struct {
ID string `db:"id"` ID string `db:"id" json:"id"`
CreatedAt pgtype.Timestamp `db:"created_at"` State string `db:"state" json:"state"`
UpdatedAt pgtype.Timestamp `db:"updated_at"` CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"`
UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"`
} }
type BasketItemModel struct { type BasketItemModel struct {
ID string `db:"id"` ID string `db:"id" json:"id"`
BasketID string `db:"basket_id"` BasketID string `db:"basket_id" json:"basket_id"`
ProductID string `db:"product_id"` ProductID int `db:"product_id" json:"product_id"`
Quantity int `db:"quantity"` Quantity int `db:"quantity" json:"quantity"`
Price float64 `db:"price"` Price float64 `db:"price" json:"price"`
CreatedAt pgtype.Timestamp `db:"created_at"` CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"`
UpdatedAt pgtype.Timestamp `db:"updated_at"` UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"`
} }

View File

@@ -8,5 +8,5 @@ type ProductModel struct {
Name string `db:"name"` Name string `db:"name"`
Price float64 `db:"price"` Price float64 `db:"price"`
CreatedAt pgtype.Timestamp `db:"created_at"` CreatedAt pgtype.Timestamp `db:"created_at"`
UpdatedAt pgtype.Timestamp `db:"updated_at"` UpdatedAt pgtype.Timestamp `db:"updated_at,omitempty"`
} }

20
model/order.go Normal file
View File

@@ -0,0 +1,20 @@
package model
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"`
}