Files
web_template/internal/model/food.go
2026-07-10 10:06:07 +00:00

66 lines
3.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import "time"
// RestaurantCategory 餐厅分类
type RestaurantCategory struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:50;not null" json:"name"`
Icon string `gorm:"size:50" json:"icon"`
Sort int `gorm:"default:0" json:"sort"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Restaurant 餐厅模型(3 套外卖网站共用同一套数据)
type Restaurant struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;not null" json:"name"`
Description string `gorm:"type:text" json:"description"`
CategoryID uint `gorm:"index" json:"category_id"`
CategoryName string `gorm:"size:50" json:"category_name"`
Cover string `gorm:"size:255" json:"cover"` // 封面图URL
Logo string `gorm:"size:255" json:"logo"` // Logo URL
Rating float64 `gorm:"type:decimal(2,1);default:4.5" json:"rating"`
Sales int `gorm:"default:0" json:"sales"` // 月销量
DeliveryFee float64 `gorm:"type:decimal(6,2);default:0" json:"delivery_fee"` // 配送费
MinOrder float64 `gorm:"type:decimal(6,2);default:0" json:"min_order"` // 起送价
DeliveryTime int `json:"delivery_time"` // 配送时间(分钟)
Distance string `gorm:"size:50" json:"distance"` // 距离
Tags string `gorm:"type:text" json:"tags"` // JSON: 标签数组
Notice string `gorm:"type:text" json:"notice"` // 公告
Status int `gorm:"default:1;not null" json:"status"` // 1=营业 0=休息
Sort int `gorm:"default:0" json:"sort"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// MenuCategory 菜品分类(属于某个餐厅)
type MenuCategory struct {
ID uint `gorm:"primaryKey" json:"id"`
RestaurantID uint `gorm:"index;not null" json:"restaurant_id"`
Name string `gorm:"size:50;not null" json:"name"`
Sort int `gorm:"default:0" json:"sort"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// MenuItem 菜品模型
type MenuItem struct {
ID uint `gorm:"primaryKey" json:"id"`
RestaurantID uint `gorm:"index;not null" json:"restaurant_id"`
CategoryID uint `gorm:"index" json:"category_id"` // 菜品分类ID
Name string `gorm:"size:100;not null" json:"name"`
Description string `gorm:"type:text" json:"description"`
Price float64 `gorm:"type:decimal(8,2);not null" json:"price"`
OriginalPrice float64 `gorm:"type:decimal(8,2)" json:"original_price"`
Image string `gorm:"size:255" json:"image"`
Rating float64 `gorm:"type:decimal(2,1);default:5.0" json:"rating"`
Sales int `gorm:"default:0" json:"sales"`
Tags string `gorm:"type:text" json:"tags"` // JSON: 标签数组
Sort int `gorm:"default:0" json:"sort"`
Status int `gorm:"default:1;not null" json:"status"` // 1=上架
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}