forked from ebhomengo/niki
48 lines
795 B
Go
48 lines
795 B
Go
package entity
|
|
|
|
import (
|
|
"git.gocasts.ir/ebhomengo/niki/types"
|
|
"time"
|
|
)
|
|
|
|
type CartStatus string
|
|
|
|
type Item struct {
|
|
ID types.ID
|
|
CartID types.ID
|
|
ProductID types.ID
|
|
UserID types.ID
|
|
Quantity int
|
|
Price float64
|
|
Name string
|
|
AddedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type Cart struct {
|
|
ID types.ID
|
|
UserID types.ID
|
|
Items []Item
|
|
Status CartStatus
|
|
TotalPrice float64
|
|
ExpireAt time.Time
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
const (
|
|
CartStatusActive CartStatus = "active"
|
|
CartStatusExpired CartStatus = "expired"
|
|
CartStatusCheckedOut CartStatus = "checked_out"
|
|
)
|
|
|
|
func (c CartStatus) IsValid() bool {
|
|
switch c {
|
|
case CartStatusExpired, CartStatusActive, CartStatusCheckedOut:
|
|
return true
|
|
|
|
default:
|
|
return false
|
|
}
|
|
}
|