2026-01-03 01:35:32 +08:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/cool"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 表名常量定义:商店配置表
|
|
|
|
|
|
const (
|
|
|
|
|
|
TableNameShopConfig = "shop_config" // 商店配置表(记录商品信息、价格、库存、分类等)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// ShopConfig 商店商品核心配置模型
|
|
|
|
|
|
type ShopConfig struct {
|
|
|
|
|
|
*cool.Model `json:"-" gorm:"embedded"` // 嵌入通用Model(ID/创建时间/更新时间,不参与json序列化)
|
|
|
|
|
|
|
|
|
|
|
|
// 核心字段
|
|
|
|
|
|
ProductName string `gorm:"not null;size:128;comment:'商品名称'" json:"product_name" description:"商品名称"`
|
2026-01-05 01:04:52 +08:00
|
|
|
|
//商品ID
|
|
|
|
|
|
ProductID uint32 `gorm:"not null;uniqueIndex;comment:'商品ID'" json:"product_id" description:"商品ID"`
|
2026-01-03 01:35:32 +08:00
|
|
|
|
Description string `gorm:"not null;size:512;comment:'商品描述'" json:"description" description:"商品描述"`
|
|
|
|
|
|
|
2026-01-05 01:04:52 +08:00
|
|
|
|
// 价格信息 -1代表不允许购买,0免费赠送
|
2026-01-03 01:35:32 +08:00
|
|
|
|
SeerdouPrice uint32 `gorm:"not null;default:0;comment:'骄阳豆价格'" json:"seerdou_price" description:"骄阳豆价格"`
|
|
|
|
|
|
JindouPrice uint32 `gorm:"not null;default:0;comment:'价格'" json:"jindou_price" description:"金豆价格"`
|
|
|
|
|
|
|
|
|
|
|
|
// 库存信息
|
|
|
|
|
|
Stock uint32 `gorm:"not null;default:0;comment:'商品库存数量(0表示无限库存)'" json:"stock" description:"库存数量"`
|
|
|
|
|
|
|
2026-01-05 01:04:52 +08:00
|
|
|
|
Category uint32 `gorm:"not null;size:64;comment:'商品分类名称'" json:"category" description:"分类名称"`
|
2026-01-03 01:35:32 +08:00
|
|
|
|
|
|
|
|
|
|
// 状态信息
|
|
|
|
|
|
IsOnSale uint32 `gorm:"not null;default:1;comment:'是否上架(0-下架 1-上架)'" json:"is_on_sale" description:"是否上架"`
|
|
|
|
|
|
|
|
|
|
|
|
// 限购信息
|
2026-01-05 01:04:52 +08:00
|
|
|
|
QuotaLimit uint32 `gorm:"not null;default:0;comment:'单位时间内的限购数量(0表示不限购)'" json:"quota_limit" description:"限购数量"`
|
|
|
|
|
|
QuotaCycle uint32 `gorm:"not null;default:0;comment:'限购周期(单位:小时,0表示不限购)'" json:"quota_cycle" description:"限购周期(小时)"`
|
2026-01-03 01:35:32 +08:00
|
|
|
|
|
|
|
|
|
|
// 备注信息
|
|
|
|
|
|
Remark string `gorm:"size:512;default:'';comment:'商品备注'" json:"remark" description:"备注信息"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------- 核心配套方法(遵循项目规范)--------------------------
|
|
|
|
|
|
func (*ShopConfig) TableName() string {
|
|
|
|
|
|
return TableNameShopConfig
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (*ShopConfig) GroupName() string {
|
|
|
|
|
|
return "default"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewShopConfig() *ShopConfig {
|
|
|
|
|
|
return &ShopConfig{
|
2026-01-05 01:04:52 +08:00
|
|
|
|
Model: cool.NewModel(),
|
2026-01-03 01:35:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------- 表结构自动同步 --------------------------
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
cool.CreateTable(&ShopConfig{})
|
2026-01-05 01:04:52 +08:00
|
|
|
|
}
|