diff --git a/internal/modules/closings/controllers/closing.controller.go b/internal/modules/closings/controllers/closing.controller.go index 2b29429e..113aa667 100644 --- a/internal/modules/closings/controllers/closing.controller.go +++ b/internal/modules/closings/controllers/closing.controller.go @@ -251,7 +251,7 @@ func (u *ClosingController) GetExpeditionHPP(c *fiber.Ctx) error { projectFlockID, err := strconv.Atoi(param) if err != nil || projectFlockID <= 0 { - return fiber.NewError(fiber.StatusBadRequest, "Invalid Project Flock Id") + return fiber.NewError(fiber.StatusBadRequest, "Invalid project_flock_id") } var projectFlockKandangID *uint @@ -277,3 +277,33 @@ func (u *ClosingController) GetExpeditionHPP(c *fiber.Ctx) error { Data: result, }) } + +func (u *ClosingController) GetExpeditionHPPByKandang(c *fiber.Ctx) error { + projectParam := c.Params("project_flock_id") + kandangParam := c.Params("project_flock_kandang_id") + + projectFlockID, err := strconv.Atoi(projectParam) + if err != nil || projectFlockID <= 0 { + return fiber.NewError(fiber.StatusBadRequest, "Invalid project_flock_id") + } + + pfkID, err := strconv.Atoi(kandangParam) + if err != nil || pfkID <= 0 { + return fiber.NewError(fiber.StatusBadRequest, "Invalid project_flock_kandang_id") + } + + kandangID := uint(pfkID) + + result, err := u.ClosingService.GetExpeditionHPP(c, uint(projectFlockID), &kandangID) + if err != nil { + return err + } + + return c.Status(fiber.StatusOK). + JSON(response.Success{ + Code: fiber.StatusOK, + Status: "success", + Message: "Get expedition HPP successfully", + Data: result, + }) +} diff --git a/internal/modules/closings/route.go b/internal/modules/closings/route.go index 526ab3b9..8a155bd0 100644 --- a/internal/modules/closings/route.go +++ b/internal/modules/closings/route.go @@ -28,4 +28,5 @@ func ClosingRoutes(v1 fiber.Router, u user.UserService, s closing.ClosingService route.Get("/:projectFlockId", ctrl.GetClosingSummary) route.Get("/:projectFlockId/sapronak", ctrl.GetClosingSapronak) route.Get("/:project_flock_id/expedition-hpp", ctrl.GetExpeditionHPP) + route.Get("/:project_flock_id/:project_flock_kandang_id/expedition-hpp", ctrl.GetExpeditionHPPByKandang) }