mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Feat[BE] : add avaibility DOC on lookup porject flock API, add note request json on chickin
This commit is contained in:
+4
-2
@@ -30,6 +30,10 @@ func (u *ProductWarehouseController) GetAll(c *fiber.Ctx) error {
|
||||
WarehouseId: uint(c.QueryInt("warehouse_id", 0)),
|
||||
}
|
||||
|
||||
if query.Page < 1 || query.Limit < 1 {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "page and limit must be greater than 0")
|
||||
}
|
||||
|
||||
result, totalResults, err := u.ProductWarehouseService.GetAll(c, query)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -71,5 +75,3 @@ func (u *ProductWarehouseController) GetOne(c *fiber.Ctx) error {
|
||||
Data: dto.ToProductWarehouseListDTO(*result),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,26 @@ func (s productWarehouseService) GetAll(c *fiber.Ctx, params *validation.Query)
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if params.ProductId > 0 {
|
||||
isProductExist, err := s.Repository.IsProductExist(c.Context(), params.ProductId)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if !isProductExist {
|
||||
return nil, 0, fiber.NewError(fiber.StatusNotFound, "Product not found")
|
||||
}
|
||||
}
|
||||
|
||||
if params.WarehouseId > 0 {
|
||||
isWarehouseExist, err := s.Repository.IsWarehouseExist(c.Context(), params.WarehouseId)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if !isWarehouseExist {
|
||||
return nil, 0, fiber.NewError(fiber.StatusNotFound, "Warehouse not found")
|
||||
}
|
||||
}
|
||||
|
||||
offset := (params.Page - 1) * params.Limit
|
||||
|
||||
productWarehouses, total, err := s.Repository.GetAll(c.Context(), offset, params.Limit, func(db *gorm.DB) *gorm.DB {
|
||||
|
||||
Reference in New Issue
Block a user