test/backend/internal/models/models.go
2025-11-21 16:03:52 +08:00

68 lines
2.3 KiB
Go

package models
import "time"
type User struct {
ID uint `gorm:"primaryKey" json:"id"`
Username string `gorm:"uniqueIndex;size:64" json:"username"`
PasswordHash string `json:"-"`
Role string `gorm:"size:32" json:"role"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type Product struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:128" json:"name"`
Category string `gorm:"size:64" json:"category"`
Description string `gorm:"size:512" json:"description"`
Price float64 `json:"price"`
Inventory int `json:"inventory"`
ImageURL string `json:"imageUrl"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type Order struct {
ID uint `gorm:"primaryKey" json:"id"`
OrderNumber string `gorm:"size:64;uniqueIndex" json:"orderNumber"`
CustomerName string `gorm:"size:128" json:"customerName"`
ProductID uint `json:"productId"`
Product Product `json:"product"`
Quantity int `json:"quantity"`
Amount float64 `json:"amount"`
Status string `gorm:"size:32" json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type Member struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:128" json:"name"`
Email string `gorm:"size:128;uniqueIndex" json:"email"`
Phone string `gorm:"size:32" json:"phone"`
Tier string `gorm:"size:32" json:"tier"`
Points int `json:"points"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type PointTransaction struct {
ID uint `gorm:"primaryKey" json:"id"`
MemberID uint `json:"memberId"`
Member Member `json:"member"`
Change int `json:"change"`
Reason string `gorm:"size:128" json:"reason"`
CreatedAt time.Time `json:"createdAt"`
}
type Ticket struct {
ID uint `gorm:"primaryKey" json:"id"`
Title string `gorm:"size:128" json:"title"`
Description string `gorm:"size:512" json:"description"`
Status string `gorm:"size:32" json:"status"`
Priority string `gorm:"size:32" json:"priority"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}