Compare commits

..

16 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
4f1fdd447a basket update 2022-12-22 13:31:25 +01:00
fb63ea8b7d update 2022-12-20 16:09:44 +01:00
14fbd44668 update 2022-12-20 16:07:56 +01:00
20fe425aef basket item model 2022-12-20 12:43:24 +01:00
1e8a075d5d update 2022-12-20 11:22:24 +01:00
6 changed files with 69 additions and 8 deletions

View File

@@ -1,9 +1,35 @@
package http
import "time"
type GetBasketRequest struct {
BasketID string `json:"basket_id"`
}
type GetBasketResponse struct {
ID string `json:"id"`
State string `json:"state"`
CreatedAt time.Duration `json:"created_at"`
UpdatedAt time.Duration `json:"updated_at,omitempty"`
}
type GetBasketItemsRequest struct {
}
type GetBasketItemsResponse struct {
ID string `json:"id"`
BasketID string `json:"basket_id"`
ProductID int `json:"product_id"`
Quantity int `json:"quantity"`
Price float64 `json:"price"`
CreatedAt time.Duration `json:"created_at"`
UpdatedAt time.Duration `json:"updated_at,omitempty"`
}
type BasketCheckoutRequest struct {
BasketID string `json:"basket_id"`
}
type BasketCheckoutResponse struct {
ID string `json:"order_id"`
ID string `json:"basket_id"`
}

View File

@@ -2,16 +2,20 @@ package http
type AddProductToBasketRequest struct {
ProductID int `json:"product_id"`
Quantity int `json:"quantity"`
}
type AddProductToBasketResponse struct {
ProductID int `json:"product_id"`
BasketID string `json:"basket_id"`
}
type RemoveProductFromBasketRequest struct {
ProductID int `json:"product_id"`
Quantity int `json:"quantity"`
}
type RemoveProductFromBasketResponse struct {
ProductID int `json:"product_id"`
BasketID string `json:"basket_id"`
}

View File

@@ -5,7 +5,18 @@ import (
)
type BasketModel struct {
ID string `db:"id"`
CreatedAt pgtype.Timestamp `db:"created_at"`
UpdatedAt pgtype.Timestamp `db:"updated_at"`
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"`
}

View File

@@ -8,5 +8,5 @@ type ProductModel struct {
Name string `db:"name"`
Price float64 `db:"price"`
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"`
}

View File

@@ -2,6 +2,6 @@ package model
type ProductPriceModel struct {
ID int `db:"id"`
PID int `db:"pid"`
PID string `db:"pid"`
Price float64 `db:"price"`
}