实现修改批次绑定的猪栏

This commit is contained in:
2025-10-04 00:47:27 +08:00
parent d03163a189
commit 8bb0a54f18
13 changed files with 498 additions and 27 deletions

View File

@@ -163,8 +163,8 @@ func (s *pigFarmService) DeletePen(id uint) error {
}
// 检查猪栏是否关联了活跃批次
if pen.PigBatchID != 0 {
pigBatch, err := s.repo.GetPigBatchByID(pen.PigBatchID)
if *pen.PigBatchID != 0 {
pigBatch, err := s.repo.GetPigBatchByID(*pen.PigBatchID)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return err
}