first commit
This commit is contained in:
74
types/types.go
Normal file
74
types/types.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"sismedika.com/sas/westone/utils"
|
||||
)
|
||||
|
||||
type Product struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Description string `db:"description" json:"description"`
|
||||
Image string `db:"image" json:"image"`
|
||||
Price float64 `db:"price" json:"price"`
|
||||
Quantity int `db:"quantity" json:"quantity"`
|
||||
CreatedAt time.Time `db:"createdAt" json:"createdAt"`
|
||||
}
|
||||
|
||||
type CartCheckoutItem struct {
|
||||
ProductID int `db:"productID" json:"productID"`
|
||||
Quantity int `db:"quantity" json:"quantity"`
|
||||
}
|
||||
|
||||
type Order struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
UserID int `db:"userID" json:"userID"`
|
||||
Total float64 `db:"total" json:"total"`
|
||||
Status string `db:"status" json:"status"`
|
||||
Address string `db:"address" json:"address"`
|
||||
CreatedAt time.Time `db:"createdAt" json:"createdAt"`
|
||||
}
|
||||
|
||||
type OrderItem struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
OrderID int `db:"orderID" json:"orderID"`
|
||||
ProductID int `db:"productID" json:"productID"`
|
||||
Quantity int `db:"quantity" json:"quantity"`
|
||||
Price float64 `db:"price" json:"price"`
|
||||
CreatedAt time.Time `db:"createdAt" json:"createdAt"`
|
||||
}
|
||||
|
||||
type ProductStore interface {
|
||||
GetProductByID(id int) (*Product, error)
|
||||
GetProductsByID(ids []int) ([]Product, error)
|
||||
GetProducts() ([]*Product, error)
|
||||
CreateProduct(CreateProductPayload) error
|
||||
UpdateProduct(Product) error
|
||||
}
|
||||
|
||||
type OrderStore interface {
|
||||
CreateOrder(Order) (int, error)
|
||||
CreateOrderItem(OrderItem) error
|
||||
}
|
||||
type CreateProductPayload struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
Description string `json:"description"`
|
||||
Image string `json:"image"`
|
||||
Price float64 `json:"price" validate:"required"`
|
||||
Quantity int `json:"quantity" validate:"required"`
|
||||
}
|
||||
type CartCheckoutPayload struct {
|
||||
Items []CartCheckoutItem `json:"items" validate:"required"`
|
||||
}
|
||||
|
||||
type ErrorLogStore interface {
|
||||
CreateErrorLog(utils.LogError) error
|
||||
}
|
||||
type DataJWT struct {
|
||||
User
|
||||
Ip string `json:"ip"`
|
||||
Agent string `json:"agent"`
|
||||
Version string `json:"version"`
|
||||
LastLogin string `json:"last-login"`
|
||||
}
|
||||
Reference in New Issue
Block a user