猪群管理聚合服务 增加调栏管理
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
type PigBatchRepository interface {
|
||||
CreatePigBatch(batch *models.PigBatch) (*models.PigBatch, error)
|
||||
GetPigBatchByID(id uint) (*models.PigBatch, error)
|
||||
GetPigBatchByIDTx(tx *gorm.DB, id uint) (*models.PigBatch, error)
|
||||
// UpdatePigBatch 更新一个猪批次,返回更新后的批次、受影响的行数和错误
|
||||
UpdatePigBatch(batch *models.PigBatch) (*models.PigBatch, int64, error)
|
||||
// DeletePigBatch 根据ID删除一个猪批次,返回受影响的行数和错误
|
||||
@@ -83,3 +84,12 @@ func (r *gormPigBatchRepository) ListPigBatches(isActive *bool) ([]*models.PigBa
|
||||
}
|
||||
return batches, nil
|
||||
}
|
||||
|
||||
// GetPigBatchByIDTx 在指定的事务中,通过ID获取单个猪批次
|
||||
func (r *gormPigBatchRepository) GetPigBatchByIDTx(tx *gorm.DB, id uint) (*models.PigBatch, error) {
|
||||
var batch models.PigBatch
|
||||
if err := tx.First(&batch, id).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &batch, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user