买卖猪记录表
This commit is contained in:
@@ -169,6 +169,8 @@ func (ps *PostgresStorage) creatingHyperTable() error {
|
||||
{models.WeighingRecord{}, "weighing_time"},
|
||||
{models.PigTransferLog{}, "transfer_time"},
|
||||
{models.PigBatchSickPigLog{}, "happened_at"},
|
||||
{models.PigPurchase{}, "purchase_date"},
|
||||
{models.PigSale{}, "sale_date"},
|
||||
}
|
||||
|
||||
for _, table := range tablesToConvert {
|
||||
@@ -207,6 +209,8 @@ func (ps *PostgresStorage) applyCompressionPolicies() error {
|
||||
{models.WeighingRecord{}, "weighing_batch_id"},
|
||||
{models.PigTransferLog{}, "pig_batch_id"},
|
||||
{models.PigBatchSickPigLog{}, "pig_batch_id"},
|
||||
{models.PigPurchase{}, "pig_batch_id"},
|
||||
{models.PigSale{}, "pig_batch_id"},
|
||||
}
|
||||
|
||||
for _, policy := range policies {
|
||||
|
||||
@@ -44,6 +44,10 @@ func GetAllModels() []interface{} {
|
||||
&PigTransferLog{},
|
||||
&PigBatchSickPigLog{},
|
||||
|
||||
// Pig Buy & Sell
|
||||
&PigPurchase{},
|
||||
&PigSale{},
|
||||
|
||||
// Feed Models
|
||||
&RawMaterial{},
|
||||
&RawMaterialPurchase{},
|
||||
|
||||
41
internal/infra/models/pig_buy_sell.go
Normal file
41
internal/infra/models/pig_buy_sell.go
Normal file
@@ -0,0 +1,41 @@
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user