Update API Documentation and Enhance Tender Query Parameters
- Changed references in API documentation from `main.HealthResponse` to `bootstrap.HealthResponse` for consistency. - Added new query parameters `publication_from` and `publication_to` to the tender listing and recommendation endpoints to allow filtering by publication date. - Updated the `ListTendersRequest` struct to include optional fields for `from` and `to` timestamps. - Modified the `TenderRepository` and `TenderService` interfaces to support the new filtering parameters in the tender listing functionality. - Enhanced the service and handler layers to process the new query parameters, improving the flexibility of tender retrieval.
This commit is contained in:
@@ -229,6 +229,8 @@ func (h *TenderHandler) ListTenders(c echo.Context) error {
|
||||
// @Param country_code query string false "Filter by country code"
|
||||
// @Param min_estimated_value query number false "Minimum estimated value"
|
||||
// @Param max_estimated_value query number false "Maximum estimated value"
|
||||
// @Param publication_from query number false "Publication from"
|
||||
// @Param publication_to query number false "Publication to"
|
||||
// @Success 200 {object} response.APIResponse{data=map[string]interface{}}
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
@@ -270,14 +272,21 @@ func (h *TenderHandler) GetPublicTenders(c echo.Context) error {
|
||||
companyID = &customerCompanyID
|
||||
}
|
||||
|
||||
req := ListTendersRequest{
|
||||
Criteria: criteria,
|
||||
Limit: limit,
|
||||
Offset: offset,
|
||||
CompanyID: companyID,
|
||||
from := int64(0)
|
||||
if fromParam := c.QueryParam("publication_from"); fromParam != "" {
|
||||
if parsed, err := strconv.ParseInt(fromParam, 10, 64); err == nil {
|
||||
from = parsed
|
||||
}
|
||||
}
|
||||
|
||||
result, err := h.service.ListTenders(c.Request().Context(), req)
|
||||
to := int64(0)
|
||||
if toParam := c.QueryParam("publication_to"); toParam != "" {
|
||||
if parsed, err := strconv.ParseInt(toParam, 10, 64); err == nil {
|
||||
to = parsed
|
||||
}
|
||||
}
|
||||
|
||||
result, err := h.service.RecommendTenders(c.Request().Context(), companyID, &from, &to, limit, offset)
|
||||
if err != nil {
|
||||
return response.InternalServerError(c, "Failed to retrieve tenders")
|
||||
}
|
||||
@@ -295,6 +304,8 @@ func (h *TenderHandler) GetPublicTenders(c echo.Context) error {
|
||||
// @Param country_code query string false "Filter by country code"
|
||||
// @Param min_estimated_value query number false "Minimum estimated value"
|
||||
// @Param max_estimated_value query number false "Maximum estimated value"
|
||||
// @Param publication_from query number false "Publication from"
|
||||
// @Param publication_to query number false "Publication to"
|
||||
// @Success 200 {object} response.APIResponse{data=map[string]interface{}}
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
@@ -336,7 +347,21 @@ func (h *TenderHandler) RecommendTenders(c echo.Context) error {
|
||||
companyID = &customerCompanyID
|
||||
}
|
||||
|
||||
result, err := h.service.RecommendTenders(c.Request().Context(), companyID, limit, offset)
|
||||
from := int64(0)
|
||||
if fromParam := c.QueryParam("publication_from"); fromParam != "" {
|
||||
if parsed, err := strconv.ParseInt(fromParam, 10, 64); err == nil {
|
||||
from = parsed
|
||||
}
|
||||
}
|
||||
|
||||
to := int64(0)
|
||||
if toParam := c.QueryParam("publication_to"); toParam != "" {
|
||||
if parsed, err := strconv.ParseInt(toParam, 10, 64); err == nil {
|
||||
to = parsed
|
||||
}
|
||||
}
|
||||
|
||||
result, err := h.service.RecommendTenders(c.Request().Context(), companyID, &from, &to, limit, offset)
|
||||
if err != nil {
|
||||
return response.InternalServerError(c, "Failed to retrieve tenders")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user