1.0
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Banner 轮播图表
|
||||
type Banner struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
Title string `gorm:"type:varchar(200);not null;comment:轮播图标题" json:"title" binding:"required"`
|
||||
ImageUrl string `gorm:"type:varchar(500);not null;comment:轮播图图片URL" json:"image_url" binding:"required"`
|
||||
LinkUrl string `gorm:"type:varchar(500);comment:点击跳转链接" json:"link_url"`
|
||||
Description string `gorm:"type:text;comment:描述信息" json:"description"`
|
||||
SortOrder int `gorm:"type:int;not null;default:0;comment:排序序号" json:"sort_order"`
|
||||
Status uint8 `gorm:"type:tinyint;not null;default:1;comment:状态:0禁用,1启用" json:"status"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (Banner) TableName() string {
|
||||
return "banners"
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"awesomeProject/internal/common"
|
||||
"awesomeProject/internal/config"
|
||||
)
|
||||
|
||||
// AutoMigrateAll 自动迁移所有数据表
|
||||
func AutoMigrateAll() error {
|
||||
db := common.GetDB()
|
||||
|
||||
// 按依赖关系迁移表
|
||||
return db.AutoMigrate(
|
||||
&User{},
|
||||
&UserAddress{},
|
||||
&ProductCategory{},
|
||||
&PrimaryProduct{},
|
||||
&SecondaryProduct{},
|
||||
&UserWarehouse{},
|
||||
&PurchaseOrder{},
|
||||
&SalesOrder{},
|
||||
&OrderMessage{}, // 订单留言表
|
||||
&SystemConfig{},
|
||||
&ScoreRecord{},
|
||||
&Banner{}, // 轮播图表
|
||||
&config.ConfigChange{}, // 配置变更记录表
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderMessage 订单留言模型
|
||||
type OrderMessage struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
OrderID uint `gorm:"not null;index" json:"order_id"` // 订单ID
|
||||
OrderType string `gorm:"type:varchar(20);not null;default:'purchase'" json:"order_type"` // 订单类型:purchase(买单), sales(卖单)
|
||||
UserID uint `gorm:"not null;index" json:"user_id"` // 留言用户ID
|
||||
Content string `gorm:"type:text;not null" json:"content"` // 留言内容
|
||||
Images string `gorm:"type:text" json:"images"` // 留言图片,多个图片用逗号分隔
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
// 关联关系
|
||||
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (OrderMessage) TableName() string {
|
||||
return "order_messages"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// PrimaryProduct 一级商品表(管理员发布的官方商品)
|
||||
type PrimaryProduct struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
CategoryID uint `gorm:"type:int;not null;comment:分类ID" json:"category_id" binding:"required"`
|
||||
ProductName string `gorm:"type:varchar(200);not null;comment:商品名称" json:"product_name" binding:"required"`
|
||||
ProductDescription string `gorm:"type:text;comment:商品描述" json:"product_description"`
|
||||
ProductImages string `gorm:"type:text;comment:商品图片URLs,逗号分割" json:"product_images"`
|
||||
OriginalPrice float64 `gorm:"type:decimal(10,2);not null;comment:原价" json:"original_price" binding:"required"`
|
||||
CurrentPrice float64 `gorm:"type:decimal(10,2);not null;comment:现价" json:"current_price" binding:"required"`
|
||||
StockQuantity int `gorm:"type:int;not null;default:0;comment:库存数量" json:"stock_quantity"`
|
||||
SalesCount int `gorm:"type:int;not null;default:0;comment:销量" json:"sales_count"`
|
||||
ViewCount int `gorm:"type:int;not null;default:0;comment:浏览量" json:"view_count"`
|
||||
Status uint8 `gorm:"type:tinyint;not null;default:1;comment:状态:0下架,1上架" json:"status"`
|
||||
IsHot int8 `gorm:"type:tinyint;not null;default:0;comment:是否为热门商品:0否,1是" json:"is_hot"`
|
||||
SortOrder int `gorm:"type:int;not null;default:0;comment:排序序号" json:"sort_order"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
|
||||
// 关联关系 - 注意:不要在关联字段上加验证标签
|
||||
Category ProductCategory `gorm:"foreignKey:CategoryID" json:"category,omitempty"`
|
||||
}
|
||||
|
||||
func (PrimaryProduct) TableName() string {
|
||||
return "primary_products"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ProductCategory 商品分类表
|
||||
type ProductCategory struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
CategoryName string `gorm:"type:varchar(100);not null;comment:分类名称" json:"category_name" binding:"required"`
|
||||
CategoryIcon string `gorm:"type:varchar(255);comment:分类图标URL" json:"category_icon"`
|
||||
SortOrder int `gorm:"type:int;not null;default:0;comment:排序序号" json:"sort_order"`
|
||||
Status uint8 `gorm:"type:tinyint;not null;default:1;comment:状态:0禁用,1启用" json:"status"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (ProductCategory) TableName() string {
|
||||
return "product_categories"
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// PurchaseOrder 买单表
|
||||
type PurchaseOrder struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
OrderNo string `gorm:"type:varchar(50);not null;uniqueIndex;comment:订单编号" json:"order_no"`
|
||||
BuyerID uint `gorm:"type:int;not null;comment:买家用户ID" json:"buyer_id" binding:"required"`
|
||||
SellerID *uint `gorm:"type:int;comment:卖家用户ID(二级商品交易时使用)" json:"seller_id"`
|
||||
ProductID uint `gorm:"type:int;not null;comment:商品ID" json:"product_id" binding:"required"`
|
||||
ProductType uint8 `gorm:"type:tinyint;not null;comment:商品类型:1一级商品,2二级商品" json:"product_type" binding:"required"`
|
||||
ProductName string `gorm:"type:varchar(200);not null;comment:商品名称" json:"product_name" binding:"required"`
|
||||
ProductImages string `gorm:"type:text;comment:商品图片URLs,逗号分割" json:"product_images"`
|
||||
UnitPrice float64 `gorm:"type:decimal(10,2);not null;comment:单价" json:"unit_price" binding:"required"`
|
||||
Quantity int `gorm:"type:int;not null;default:1;comment:数量" json:"quantity"`
|
||||
TotalAmount float64 `gorm:"type:decimal(10,2);not null;comment:总金额" json:"total_amount" binding:"required"`
|
||||
AddressID *uint `gorm:"type:int;comment:收货地址ID" json:"address_id"`
|
||||
OrderStatus uint8 `gorm:"type:tinyint;not null;default:0;comment:订单状态:0待付款,1待确认,2已完成,3已取消" json:"order_status"`
|
||||
ConfirmTime *time.Time `gorm:"type:timestamp;null;comment:确认时间" json:"confirm_time"`
|
||||
Remark string `gorm:"type:text;comment:备注" json:"remark"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
PaymentProofImage string `gorm:"type:varchar(255)" json:"payment_proof_image"`
|
||||
// 关联关系
|
||||
Buyer User `gorm:"foreignKey:BuyerID" json:"buyer,omitempty"`
|
||||
Seller *User `gorm:"foreignKey:SellerID" json:"seller,omitempty"`
|
||||
Address *UserAddress `gorm:"foreignKey:AddressID" json:"address,omitempty"`
|
||||
}
|
||||
|
||||
func (PurchaseOrder) TableName() string {
|
||||
return "purchase_orders"
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// SalesOrder 卖单表
|
||||
type SalesOrder struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
OrderNo string `gorm:"type:varchar(50);not null;uniqueIndex;comment:订单编号" json:"order_no"`
|
||||
SellerID uint `gorm:"type:int;not null;comment:卖家用户ID" json:"seller_id" binding:"required"`
|
||||
BuyerID uint `gorm:"type:int;not null;comment:买家用户ID" json:"buyer_id" binding:"required"`
|
||||
SecondaryProductID uint `gorm:"type:int;not null;comment:二级商品ID" json:"secondary_product_id" binding:"required"`
|
||||
ProductName string `gorm:"type:varchar(200);not null;comment:商品名称" json:"product_name" binding:"required"`
|
||||
ProductImages string `gorm:"type:text;comment:商品图片URLs,逗号分割" json:"product_images"`
|
||||
SellingPrice float64 `gorm:"type:decimal(10,2);not null;comment:出售价格" json:"selling_price" binding:"required"`
|
||||
Quantity int `gorm:"type:int;not null;default:1;comment:数量" json:"quantity"`
|
||||
TotalAmount float64 `gorm:"type:decimal(10,2);not null;comment:总金额" json:"total_amount" binding:"required"`
|
||||
AddressID *uint `gorm:"type:int;comment:收货地址ID" json:"address_id"`
|
||||
OrderStatus uint8 `gorm:"type:tinyint;not null;default:0;comment:订单状态:0待付款,1待发货,2确认完成,3已取消" json:"order_status"`
|
||||
CompleteTime *time.Time `gorm:"type:timestamp;null;comment:完成时间" json:"complete_time"`
|
||||
Remark string `gorm:"type:text;comment:备注" json:"remark"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
PaymentProofImage string `json:"payment_proof_image" gorm:"type:varchar(255)"`
|
||||
PurchaseOrderID uint `gorm:"type:int;" json:"purchase_order_id"`
|
||||
// 关联关系
|
||||
Seller *User `gorm:"foreignKey:SellerID" json:"seller,omitempty"`
|
||||
Buyer User `gorm:"foreignKey:BuyerID" json:"buyer,omitempty"`
|
||||
SecondaryProduct SecondaryProduct `gorm:"foreignKey:SecondaryProductID" json:"secondary_product,omitempty"`
|
||||
Address *UserAddress `gorm:"foreignKey:AddressID" json:"address,omitempty"`
|
||||
PurchaseOrder *PurchaseOrder `gorm:"foreignKey:PurchaseOrderID" json:"purchase_order,omitempty"`
|
||||
}
|
||||
|
||||
func (SalesOrder) TableName() string {
|
||||
return "sales_orders"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ScoreRecord 积分记录表
|
||||
type ScoreRecord struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
UserID uint `gorm:"type:int;not null;comment:用户编号" json:"user_id" binding:"required"`
|
||||
ChangeNumber int `gorm:"type:int;not null;comment:变化数量" json:"change_number" binding:"required"`
|
||||
Note string `gorm:"type:varchar(200);not null;comment:说明" json:"note" binding:"required"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
|
||||
// 关联关系
|
||||
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
||||
}
|
||||
|
||||
func (ScoreRecord) TableName() string {
|
||||
return "score_records"
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// SecondaryProduct 二级商品表(用户上架的商品)
|
||||
type SecondaryProduct struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
SellerID uint `gorm:"type:int;not null;comment:卖家用户ID" json:"seller_id" binding:"required"`
|
||||
OriginalProductID *uint `gorm:"type:int;comment:原始商品ID(一级商品ID或二级商品ID)" json:"original_product_id"`
|
||||
OriginalProductType uint8 `gorm:"type:tinyint;not null;comment:原始商品类型:1一级商品,2二级商品" json:"original_product_type" binding:"required"`
|
||||
ProductName string `gorm:"type:varchar(200);not null;comment:商品名称" json:"product_name" binding:"required"`
|
||||
ProductDescription string `gorm:"type:text;comment:商品描述" json:"product_description"`
|
||||
ProductImages string `gorm:"type:text;comment:商品图片URLs,JSON格式存储" json:"product_images"`
|
||||
CostPrice float64 `gorm:"type:decimal(10,2);not null;comment:成本价(用户购买时的价格)" json:"cost_price" binding:"required"`
|
||||
SellingPrice float64 `gorm:"type:decimal(10,2);not null;comment:出售价格" json:"selling_price" binding:"required"`
|
||||
Quantity int `gorm:"type:int;not null;default:1;comment:出售数量" json:"quantity"`
|
||||
Status uint8 `gorm:"type:tinyint;not null;default:1;comment:状态:0下架,1上架,2已售出" json:"status"`
|
||||
ViewCount int `gorm:"type:int;not null;default:0;comment:浏览量" json:"view_count"`
|
||||
SalesCount int `gorm:"type:int;not null;default:0;" json:"sales_count"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
CategoryID uint `gorm:"type:int;not null;default:0;comment:商品分类ID" json:"category_id"`
|
||||
ProductCondition string `gorm:"type varchar(255)" json:"product_condition"`
|
||||
UserWarehouseID uint `gorm:"type:int;not null" json:"user_warehouse_id"`
|
||||
// 关联关系
|
||||
Seller User `gorm:"foreignKey:SellerID" json:"seller,omitempty"`
|
||||
Category *ProductCategory `gorm:"foreignKey:CategoryID" json:"category,omitempty"`
|
||||
UserWarehouse *UserWarehouse `gorm:"foreignKey:UserWarehouseID" json:"user_warehouse,omitempty"`
|
||||
}
|
||||
|
||||
func (SecondaryProduct) TableName() string {
|
||||
return "secondary_products"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// SystemConfig 系统常量设置表
|
||||
type SystemConfig struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
ConfigKey string `gorm:"type:varchar(100);not null;uniqueIndex;comment:配置键" json:"config_key" binding:"required"`
|
||||
ConfigValue string `gorm:"type:text;not null;comment:配置值" json:"config_value" binding:"required"`
|
||||
ConfigName string `gorm:"type:varchar(200);not null;comment:配置名称" json:"config_name" binding:"required"`
|
||||
ConfigDescription string `gorm:"type:text;comment:配置描述" json:"config_description"`
|
||||
ConfigType string `gorm:"type:varchar(20);not null;default:'string';comment:配置类型:string、number、boolean、json" json:"config_type"`
|
||||
IsSystem uint8 `gorm:"type:tinyint;not null;default:0;comment:是否系统配置:0否,1是" json:"is_system"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (SystemConfig) TableName() string {
|
||||
return "system_configs"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// User 用户表
|
||||
type User struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
Phone string `gorm:"type:varchar(20);not null;uniqueIndex" json:"phone" binding:"required"`
|
||||
SystemRole uint8 `gorm:"type:tinyint;not null;default:2;comment:系统角色:0管理员,1代理商,2普通用户" json:"system_role"`
|
||||
CustomerName string `gorm:"type:varchar(50)" json:"customer_name"`
|
||||
RealName string `gorm:"type:varchar(50)" json:"real_name"`
|
||||
CurrentPoints int `gorm:"type:int;not null;default:0;comment:当前积分" json:"current_points"`
|
||||
Avatar string `gorm:"type:varchar(255)" json:"avatar"`
|
||||
CompanyName string `gorm:"type:varchar(100)" json:"company_name"`
|
||||
PersonalIntro string `gorm:"type:text" json:"personal_intro"`
|
||||
IdentityCode string `gorm:"type:varchar(50);uniqueIndex" json:"identity_code"`
|
||||
ReferrerIdentityCode string `gorm:"type:varchar(50)" json:"referrer_identity_code"`
|
||||
BusinessLicenseImage string `gorm:"type:varchar(255)" json:"business_license_image"`
|
||||
IdCardFrontImage string `gorm:"type:varchar(255)" json:"id_card_front_image"`
|
||||
IdCardBackImage string `gorm:"type:varchar(255)" json:"id_card_back_image"`
|
||||
MainPaymentQrImage *string `gorm:"type:varchar(255)" json:"main_payment_qr_image"`
|
||||
SubPaymentQrImage *string `gorm:"type:varchar(255)" json:"sub_payment_qr_image"`
|
||||
Password string `gorm:"type:varchar(255)" json:"password"`
|
||||
Status uint8 `gorm:"type:tinyint;not null;default:1;comment:状态:0禁用,1启用" json:"status"`
|
||||
ExpiryDate *time.Time `gorm:"type:timestamp;null;comment:过期时间,null表示永不过期" json:"expiry_date"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (User) TableName() string {
|
||||
return "users"
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserAddress 收货地址表
|
||||
type UserAddress struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
UserID uint `gorm:"type:int;not null;comment:用户ID" json:"user_id"`
|
||||
ConsigneeName string `gorm:"type:varchar(50);not null;comment:收件人姓名" json:"consignee_name" binding:"required"`
|
||||
ConsigneePhone string `gorm:"type:varchar(20);not null;comment:收件人电话" json:"consignee_phone" binding:"required"`
|
||||
Province string `gorm:"type:varchar(50);not null;comment:省份" json:"province" binding:"required"`
|
||||
City string `gorm:"type:varchar(50);not null;comment:城市" json:"city" binding:"required"`
|
||||
District string `gorm:"type:varchar(50);not null;comment:区县" json:"district" binding:"required"`
|
||||
DetailAddress string `gorm:"type:varchar(200);not null;comment:详细地址" json:"detail_address" binding:"required"`
|
||||
PostalCode string `gorm:"type:varchar(10);comment:邮政编码" json:"postal_code"`
|
||||
IsDefault uint8 `gorm:"type:tinyint;not null;default:0;comment:是否默认地址:0否,1是" json:"is_default"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
|
||||
// 关联关系
|
||||
User *User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE" json:"-"`
|
||||
}
|
||||
|
||||
func (UserAddress) TableName() string {
|
||||
return "user_addresses"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserWarehouse 用户仓库表
|
||||
type UserWarehouse struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
UserID uint `gorm:"type:int;not null;comment:用户ID" json:"user_id" binding:"required"`
|
||||
ProductID uint `gorm:"type:int;not null;comment:商品ID" json:"product_id" binding:"required"`
|
||||
ProductType uint8 `gorm:"type:tinyint;not null;comment:商品类型:1一级商品,2二级商品" json:"product_type" binding:"required"`
|
||||
ProductName string `gorm:"type:varchar(200);not null;comment:商品名称" json:"product_name" binding:"required"`
|
||||
ProductImages string `gorm:"type:text;comment:商品图片URLs,JSON格式存储" json:"product_images"`
|
||||
PurchasePrice float64 `gorm:"type:decimal(10,2);not null;comment:购买价格" json:"purchase_price" binding:"required"`
|
||||
WarehousePrice float64 `gorm:"type:decimal(10,2);not null;comment:入库价格(根据系统常量增值后)" json:"warehouse_price" binding:"required"`
|
||||
Quantity int `gorm:"type:int;not null;default:1;comment:数量" json:"quantity"`
|
||||
SourceOrderID *uint `gorm:"type:int;comment:来源订单ID" json:"source_order_id"`
|
||||
Status uint8 `gorm:"type:tinyint;not null;default:1;comment:状态:0已出售,1库存中" json:"status"`
|
||||
CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
|
||||
// 关联关系
|
||||
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
||||
}
|
||||
|
||||
func (UserWarehouse) TableName() string {
|
||||
return "user_warehouse"
|
||||
}
|
||||
Reference in New Issue
Block a user