mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 05:21:57 +00:00
fix: error checking id exists
This commit is contained in:
@@ -739,25 +739,26 @@ func (s *adjustmentService) AdjustmentHistory(c *fiber.Ctx, query *validation.Qu
|
||||
}
|
||||
offset := (query.Page - 1) * query.Limit
|
||||
|
||||
var isProductsExist bool
|
||||
isWarehousesExist, err := s.WarehouseRepo.IdExists(c.Context(), uint(query.WarehouseID))
|
||||
|
||||
if query.WarehouseID > 0 {
|
||||
isWarehouseExist, err := s.WarehouseRepo.IdExists(c.Context(), query.WarehouseID)
|
||||
if err != nil {
|
||||
return nil, 0, fiber.NewError(fiber.StatusInternalServerError, "Failed to validate warehouse")
|
||||
}
|
||||
if query.WarehouseID > 0 && !isWarehousesExist {
|
||||
if !isWarehouseExist {
|
||||
return nil, 0, fiber.NewError(fiber.StatusNotFound, "Warehouse not found")
|
||||
}
|
||||
}
|
||||
|
||||
isProductsExist, err = s.ProductRepo.IdExists(c.Context(), uint(query.ProductID))
|
||||
|
||||
if query.ProductID > 0 {
|
||||
isProductExist, err := s.ProductRepo.IdExists(c.Context(), query.ProductID)
|
||||
if err != nil {
|
||||
s.Log.Errorf("Failed to check product existence: %+v", err)
|
||||
return nil, 0, fiber.NewError(fiber.StatusInternalServerError, "Failed to validate product")
|
||||
}
|
||||
if query.ProductID > 0 && !isProductsExist {
|
||||
if !isProductExist {
|
||||
return nil, 0, fiber.NewError(fiber.StatusNotFound, "Product not found")
|
||||
}
|
||||
}
|
||||
|
||||
scope, scopeErr := m.ResolveLocationScope(c, s.AdjustmentStockRepository.DB())
|
||||
if scopeErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user