Files
pig-farm-controller/internal/infra/models/pig_trade.go

40 lines
1.2 KiB
Go
Raw Normal View History

2025-10-05 22:09:25 +08:00
package models
import (
"time"
)
// PigPurchase 记录了猪只采购信息
type PigPurchase struct {
2025-11-10 22:23:31 +08:00
Model
PigBatchID uint32 `gorm:"not null;index;comment:关联的猪批次ID"`
2025-10-05 22:09:25 +08:00
PurchaseDate time.Time `gorm:"primaryKey;comment:采购日期"`
Supplier string `gorm:"comment:供应商"`
Quantity int `gorm:"not null;comment:采购数量"`
2025-11-10 21:42:46 +08:00
UnitPrice float32 `gorm:"not null;comment:单价"`
TotalPrice float32 `gorm:"not null;comment:总价"`
2025-10-05 22:09:25 +08:00
Remarks string `gorm:"size:255;comment:备注"`
2025-11-10 22:23:31 +08:00
OperatorID uint32 `gorm:"comment:操作员ID"`
2025-10-05 22:09:25 +08:00
}
func (PigPurchase) TableName() string {
return "pig_purchases"
}
// PigSale 记录了猪只销售信息
type PigSale struct {
2025-11-10 22:23:31 +08:00
Model
PigBatchID uint32 `gorm:"not null;index;comment:关联的猪批次ID"`
2025-10-05 22:09:25 +08:00
SaleDate time.Time `gorm:"primaryKey;comment:销售日期"`
Buyer string `gorm:"comment:购买方"`
Quantity int `gorm:"not null;comment:销售数量"`
2025-11-10 21:42:46 +08:00
UnitPrice float32 `gorm:"not null;comment:单价"`
TotalPrice float32 `gorm:"not null;comment:总价"`
2025-10-05 22:09:25 +08:00
Remarks string `gorm:"size:255;comment:备注"`
2025-11-10 22:23:31 +08:00
OperatorID uint32 `gorm:"comment:操作员ID"`
2025-10-05 22:09:25 +08:00
}
func (PigSale) TableName() string {
return "pig_sales"
}