Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
Street string `json:"street" bson:"street" validate:"required,min=1,max=200"`
City string `json:"city" bson:"city" validate:"required,min=1,max=100"`
State string `json:"state" bson:"state" validate:"required,min=1,max=100"`
ZipCode string `json:"zip_code" bson:"zip_code" validate:"required,min=1,max=20"`
Country string `json:"country" bson:"country" validate:"required,min=1,max=100"`
}
Address represents a physical address
type BaseModel ¶
type BaseModel struct {
ID string `json:"id" bson:"id"`
MongoID bson.ObjectID `json:"-" bson:"_id,omitempty"`
CreatedAt time.Time `json:"created_at" bson:"created_at"`
UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
}
BaseModel contains common fields for all models.
type Order ¶
type Order struct {
BaseModel `bson:",inline"`
UserID string `json:"user_id" bson:"user_id"`
Items []OrderItem `json:"items" bson:"items"`
Total float64 `json:"total" bson:"total"`
Status OrderStatus `json:"status" bson:"status"`
ShippingAddress Address `json:"shipping_address" bson:"shipping_address"`
}
Order represents a customer order.
func NewOrder ¶
func NewOrder(p OrderParams) *Order
NewOrder creates a new order with generated ID, calculated total, and timestamps.
type OrderItem ¶
type OrderItem struct {
RecordID string `json:"record_id" bson:"record_id"`
Title string `json:"title" bson:"title"`
Artist string `json:"artist" bson:"artist"`
Price float64 `json:"price" bson:"price"`
Quantity int `json:"quantity" bson:"quantity"`
}
OrderItem represents a single item in an order
type OrderParams ¶
OrderParams contains parameters for creating a new order.
type OrderStatus ¶
type OrderStatus string
OrderStatus represents the status of an order
const ( OrderStatusPending OrderStatus = "pending" OrderStatusConfirmed OrderStatus = "confirmed" OrderStatusShipped OrderStatus = "shipped" OrderStatusDelivered OrderStatus = "delivered" OrderStatusCancelled OrderStatus = "cancelled" )
type Record ¶
type Record struct {
BaseModel `bson:",inline"`
Title string `json:"title" bson:"title" validate:"required,min=1,max=200"`
Artist string `json:"artist" bson:"artist" validate:"required,min=1,max=100"`
Year int `json:"year" bson:"year" validate:"min=1900,max=2100"`
Label string `json:"label" bson:"label"`
CatalogNumber string `json:"catalog_number" bson:"catalog_number"`
Format Format `json:"format" bson:"format" validate:"required,oneof=lp 7in 10in 12in"`
Genre Genre `json:"genre" bson:"genre" validate:"required,oneof=jazz rock electronic hip-hop classical soul funk blues"`
Condition Condition `json:"condition" bson:"condition" validate:"required,oneof=mint nm- nm vg+ vg g+"`
Price float64 `json:"price" bson:"price" validate:"required,min=0"`
Stock int `json:"stock" bson:"stock" validate:"min=0"`
Description string `json:"description" bson:"description"`
Archived bool `json:"archived" bson:"archived"`
}
Record represents a vinyl record in the catalog.
func NewRecord ¶
func NewRecord(p RecordParams) *Record
NewRecord creates a new record with generated ID and timestamps.
type RecordParams ¶
type RecordParams struct {
Title string
Artist string
Year int
Label string
CatalogNumber string
Format Format
Genre Genre
Condition Condition
Price float64
Stock int
Description string
}
RecordParams contains parameters for creating a new record.
type User ¶
type User struct {
BaseModel `bson:",inline"`
Email string `json:"email" bson:"email" validate:"required,email,lowercase"`
Name string `json:"name" bson:"name" validate:"required,min=2,max=100"`
PasswordHash string `json:"-" bson:"password_hash"`
Address Address `json:"address" bson:"address"`
Active bool `json:"active" bson:"active"`
Role Role `json:"role" bson:"role"`
}
User represents a store user.
func NewUser ¶
func NewUser(p UserParams) (*User, error)
NewUser creates a new user with generated ID, hashed password, and timestamps.
func (*User) VerifyPassword ¶
VerifyPassword checks if the provided password matches the stored hash.