swag
This commit is contained in:
@@ -16,8 +16,8 @@ var (
|
||||
ErrHouseNotFound = errors.New("指定的猪舍不存在")
|
||||
ErrPenInUse = errors.New("猪栏正在被活跃批次使用,无法删除")
|
||||
ErrPenNotFound = errors.New("指定的猪栏不存在")
|
||||
ErrPenStatusInvalidForOccupiedPen = errors.New("猪栏已被批次占用,无法设置为非占用状态")
|
||||
ErrPenStatusInvalidForUnoccupiedPen = errors.New("猪栏未被批次占用,无法设置为占用状态")
|
||||
ErrPenStatusInvalidForOccupiedPen = errors.New("猪栏已被批次使用,无法设置为非使用中状态")
|
||||
ErrPenStatusInvalidForUnoccupiedPen = errors.New("猪栏未被批次使用,无法设置为使用中状态")
|
||||
)
|
||||
|
||||
// PigFarmService 提供了猪场资产管理的业务逻辑
|
||||
@@ -217,12 +217,12 @@ func (s *pigFarmService) UpdatePenStatus(id uint, newStatus models.PenStatus) (*
|
||||
}
|
||||
|
||||
// 业务逻辑:根据猪栏的 PigBatchID 和当前状态,判断是否允许设置为 newStatus
|
||||
if pen.PigBatchID != nil && *pen.PigBatchID != 0 { // 猪栏已被批次占用
|
||||
if newStatus == models.PenStatusEmpty { // 猪栏已被批次占用,不能直接设置为空闲
|
||||
if pen.PigBatchID != nil && *pen.PigBatchID != 0 { // 猪栏已被批次使用
|
||||
if newStatus == models.PenStatusEmpty { // 猪栏已被批次使用,不能直接设置为空闲
|
||||
return ErrPenStatusInvalidForOccupiedPen
|
||||
}
|
||||
} else { // 猪栏未被批次占用 (PigBatchID == nil)
|
||||
if newStatus == models.PenStatusOccupied { // 猪栏未被批次占用,不能设置为占用
|
||||
} else { // 猪栏未被批次使用 (PigBatchID == nil)
|
||||
if newStatus == models.PenStatusOccupied { // 猪栏未被批次使用,不能设置为使用中
|
||||
return ErrPenStatusInvalidForUnoccupiedPen
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user