42 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package models
 | 
						|
 | 
						|
import (
 | 
						|
	"time"
 | 
						|
 | 
						|
	"gorm.io/gorm"
 | 
						|
)
 | 
						|
 | 
						|
// PigPurchase 记录了猪只采购信息
 | 
						|
type PigPurchase struct {
 | 
						|
	gorm.Model
 | 
						|
	PigBatchID   uint      `gorm:"not null;index;comment:关联的猪批次ID"`
 | 
						|
	PurchaseDate time.Time `gorm:"primaryKey;comment:采购日期"`
 | 
						|
	Supplier     string    `gorm:"comment:供应商"`
 | 
						|
	Quantity     int       `gorm:"not null;comment:采购数量"`
 | 
						|
	UnitPrice    float64   `gorm:"not null;comment:单价"`
 | 
						|
	TotalPrice   float64   `gorm:"not null;comment:总价"`
 | 
						|
	Remarks      string    `gorm:"size:255;comment:备注"`
 | 
						|
	OperatorID   uint      `gorm:"comment:操作员ID"`
 | 
						|
}
 | 
						|
 | 
						|
func (PigPurchase) TableName() string {
 | 
						|
	return "pig_purchases"
 | 
						|
}
 | 
						|
 | 
						|
// PigSale 记录了猪只销售信息
 | 
						|
type PigSale struct {
 | 
						|
	gorm.Model
 | 
						|
	PigBatchID uint      `gorm:"not null;index;comment:关联的猪批次ID"`
 | 
						|
	SaleDate   time.Time `gorm:"primaryKey;comment:销售日期"`
 | 
						|
	Buyer      string    `gorm:"comment:购买方"`
 | 
						|
	Quantity   int       `gorm:"not null;comment:销售数量"`
 | 
						|
	UnitPrice  float64   `gorm:"not null;comment:单价"`
 | 
						|
	TotalPrice float64   `gorm:"not null;comment:总价"`
 | 
						|
	Remarks    string    `gorm:"size:255;comment:备注"`
 | 
						|
	OperatorID uint      `gorm:"comment:操作员ID"`
 | 
						|
}
 | 
						|
 | 
						|
func (PigSale) TableName() string {
 | 
						|
	return "pig_sales"
 | 
						|
}
 |