删批次时释放猪栏
This commit is contained in:
@@ -15,6 +15,7 @@ type PigBatchRepository interface {
|
||||
UpdatePigBatch(batch *models.PigBatch) (*models.PigBatch, int64, error)
|
||||
// DeletePigBatch 根据ID删除一个猪批次,返回受影响的行数和错误
|
||||
DeletePigBatch(id uint) (int64, error)
|
||||
DeletePigBatchTx(tx *gorm.DB, id uint) (int64, error)
|
||||
ListPigBatches(isActive *bool) ([]*models.PigBatch, error)
|
||||
}
|
||||
|
||||
@@ -58,7 +59,11 @@ func (r *gormPigBatchRepository) UpdatePigBatch(batch *models.PigBatch) (*models
|
||||
|
||||
// DeletePigBatch 根据ID删除一个猪批次 (GORM 会执行软删除)
|
||||
func (r *gormPigBatchRepository) DeletePigBatch(id uint) (int64, error) {
|
||||
result := r.db.Delete(&models.PigBatch{}, id)
|
||||
return r.DeletePigBatchTx(r.db, id)
|
||||
}
|
||||
|
||||
func (r *gormPigBatchRepository) DeletePigBatchTx(tx *gorm.DB, id uint) (int64, error) {
|
||||
result := tx.Delete(&models.PigBatch{}, id)
|
||||
if result.Error != nil {
|
||||
return 0, result.Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user