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.
This commit is contained in:
n.nakhostin
2025-09-02 11:41:51 +03:30
parent 8f909618d8
commit fbf3165169
+13 -5
View File
@@ -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")
}