mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 07:15:43 +00:00
Feat[BE]: implement max target quantity retrieval for kandangs and update routes
This commit is contained in:
+26
@@ -218,3 +218,29 @@ func (u *TransferLayingController) GetAvailableQtyPerKandang(c *fiber.Ctx) error
|
||||
Data: resp,
|
||||
})
|
||||
}
|
||||
|
||||
func (u *TransferLayingController) GetMaxTargetQtyPerKandang(c *fiber.Ctx) error {
|
||||
projectFlockID, err := strconv.ParseUint(c.Params("project_flock_id"), 10, 32)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "Invalid project_flock_id")
|
||||
}
|
||||
kandangMaxTargetQty, err := u.TransferLayingService.GetMaxTargetQtyPerKandang(c, uint(projectFlockID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
kandangs := make([]dto.KandangMaxTargetQtyDTO, 0, len(kandangMaxTargetQty))
|
||||
for pfkId, maxTargetQty := range kandangMaxTargetQty {
|
||||
kandangs = append(kandangs, dto.ToKandangMaxTargetQtyDTO(pfkId, maxTargetQty))
|
||||
}
|
||||
|
||||
resp := dto.ToMaxTargetQtyForTransferDTO(uint(projectFlockID), kandangs)
|
||||
|
||||
return c.Status(fiber.StatusOK).
|
||||
JSON(response.Success{
|
||||
Code: fiber.StatusOK,
|
||||
Status: "success",
|
||||
Message: "Get max target quantity successfully",
|
||||
Data: resp,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user