Feat[BE-127] create get all with param on project flock kandang

This commit is contained in:
aguhh18
2025-11-06 14:03:47 +07:00
parent 5cfa97dd03
commit 4b69afe4fa
5 changed files with 129 additions and 29 deletions
@@ -33,11 +33,16 @@ func (u *ProjectFlockKandangController) GetAll(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusBadRequest, "page and limit must be greater than 0")
}
result, totalResults, err := u.ProjectFlockKandangService.GetAll(c, query)
results, totalResults, err := u.ProjectFlockKandangService.GetAll(c, query)
if err != nil {
return err
}
var data []dto.ProjectFlockKandangListDTO
for _, result := range results {
data = append(data, dto.ToProjectFlockKandangListDTO(result.Entity))
}
return c.Status(fiber.StatusOK).
JSON(response.SuccessWithPaginate[dto.ProjectFlockKandangListDTO]{
Code: fiber.StatusOK,
@@ -49,7 +54,7 @@ func (u *ProjectFlockKandangController) GetAll(c *fiber.Ctx) error {
TotalPages: int64(math.Ceil(float64(totalResults) / float64(query.Limit))),
TotalResults: totalResults,
},
Data: dto.ToProjectFlockKandangListDTOs(result),
Data: data,
})
}