29 lines
1.7 KiB
Go
29 lines
1.7 KiB
Go
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"
|
||
} |