实现交易管理器主服务入口
This commit is contained in:
@@ -2,6 +2,7 @@ package pig
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
||||
)
|
||||
@@ -30,29 +31,24 @@ var (
|
||||
// PigBatchService 定义了猪批次管理的核心业务逻辑接口。
|
||||
// 它抽象了所有与猪批次相关的操作,使得应用层可以依赖于此接口,而不是具体的实现。
|
||||
type PigBatchService interface {
|
||||
// TransferPigsWithinBatch 处理同一个猪群内部的调栏业务。
|
||||
TransferPigsWithinBatch(batchID uint, fromPenID uint, toPenID uint, quantity uint, operatorID uint, remarks string) error
|
||||
|
||||
// TransferPigsAcrossBatches 处理跨猪群的调栏业务。
|
||||
TransferPigsAcrossBatches(sourceBatchID uint, destBatchID uint, fromPenID uint, toPenID uint, quantity uint, operatorID uint, remarks string) error
|
||||
|
||||
// CreatePigBatch 创建一个新的猪批次。
|
||||
// CreatePigBatch 创建猪批次,并记录初始日志。
|
||||
CreatePigBatch(operatorID uint, batch *models.PigBatch) (*models.PigBatch, error)
|
||||
|
||||
// GetPigBatch 根据ID获取单个猪批次的详细信息。
|
||||
// GetPigBatch 获取单个猪批次。
|
||||
GetPigBatch(id uint) (*models.PigBatch, error)
|
||||
|
||||
// UpdatePigBatch 更新一个已存在的猪批次信息。
|
||||
// UpdatePigBatch 更新猪批次信息。
|
||||
UpdatePigBatch(batch *models.PigBatch) (*models.PigBatch, error)
|
||||
|
||||
// DeletePigBatch 删除一个指定的猪批次。
|
||||
// 实现时需要包含业务规则校验,例如,活跃的批次不能被删除。
|
||||
// DeletePigBatch 删除猪批次,包含业务规则校验。
|
||||
DeletePigBatch(id uint) error
|
||||
|
||||
// ListPigBatches 根据是否活跃的状态,列出所有符合条件的猪批次。
|
||||
// ListPigBatches 批量查询猪批次。
|
||||
ListPigBatches(isActive *bool) ([]*models.PigBatch, error)
|
||||
|
||||
// UpdatePigBatchPens 负责原子性地更新一个猪批次所关联的所有猪栏。
|
||||
// 它会处理猪栏的添加、移除,并确保数据的一致性。
|
||||
// UpdatePigBatchPens 更新猪批次关联的猪栏。
|
||||
UpdatePigBatchPens(batchID uint, desiredPenIDs []uint) error
|
||||
|
||||
// GetCurrentPigQuantity 获取指定猪批次的当前猪只数量。
|
||||
GetCurrentPigQuantity(batchID uint) (int, error)
|
||||
|
||||
// SellPigs 处理卖猪的业务逻辑。
|
||||
SellPigs(batchID uint, quantity int, unitPrice float64, tatalPrice float64, traderName string, tradeDate time.Time, remarks string, operatorID uint) error
|
||||
// BuyPigs 处理买猪的业务逻辑。
|
||||
BuyPigs(batchID uint, quantity int, unitPrice float64, tatalPrice float64, traderName string, tradeDate time.Time, remarks string, operatorID uint) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user