mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 07:15:43 +00:00
adjust api get all employees
This commit is contained in:
@@ -29,10 +29,27 @@ func (u *EmployeesController) GetAll(c *fiber.Ctx) error {
|
||||
Search: c.Query("search", ""),
|
||||
}
|
||||
|
||||
if query.Page < 1 || query.Limit < 1 {
|
||||
if query.Page < 1 || query.Limit < 1 {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "page and limit must be greater than 0")
|
||||
}
|
||||
|
||||
if kandangParam := c.Query("kandang_id", ""); kandangParam != "" {
|
||||
id, err := strconv.Atoi(kandangParam)
|
||||
if err != nil || id <= 0 {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "invalid kandang_id")
|
||||
}
|
||||
temp := uint(id)
|
||||
query.KandangId = &temp
|
||||
}
|
||||
|
||||
if activeParam := c.Query("is_active", ""); activeParam != "" {
|
||||
value, err := strconv.ParseBool(activeParam)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "invalid is_active value")
|
||||
}
|
||||
query.IsActive = &value
|
||||
}
|
||||
|
||||
result, totalResults, err := u.EmployeesService.GetAll(c, query)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user