From fbf31651696997a1bf47d7930dc2c10aeebe3e10 Mon Sep 17 00:00:00 2001 From: "n.nakhostin" Date: Tue, 2 Sep 2025 11:41:51 +0330 Subject: [PATCH] Refactor Tender Handler to Use ListTendersRequest Struct - Updated the GetPublicTenders handler to utilize a new ListTendersRequest struct for improved clarity and organization of parameters. - Changed the handling of `publication_from` and `publication_to` query parameters to use pointers for optional timestamp values. - Enhanced the service call to ListTenders, aligning with the new request structure and improving the overall code maintainability. --- internal/tender/handler.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/internal/tender/handler.go b/internal/tender/handler.go index 7f4454e..9d65c79 100644 --- a/internal/tender/handler.go +++ b/internal/tender/handler.go @@ -272,21 +272,29 @@ func (h *TenderHandler) GetPublicTenders(c echo.Context) error { companyID = &customerCompanyID } - from := int64(0) + var from *int64 if fromParam := c.QueryParam("publication_from"); fromParam != "" { if parsed, err := strconv.ParseInt(fromParam, 10, 64); err == nil { - from = parsed + from = &parsed } } - to := int64(0) + var to *int64 if toParam := c.QueryParam("publication_to"); toParam != "" { if parsed, err := strconv.ParseInt(toParam, 10, 64); err == nil { - to = parsed + to = &parsed } } - result, err := h.service.RecommendTenders(c.Request().Context(), companyID, &from, &to, limit, offset) + req := ListTendersRequest{ + Criteria: criteria, + Limit: limit, + Offset: offset, + CompanyID: companyID, + From: from, + To: to, + } + result, err := h.service.ListTenders(c.Request().Context(), req) if err != nil { return response.InternalServerError(c, "Failed to retrieve tenders") }