Enhance Tender Approval Filtering with Created Date Parameters

- Added new query parameters `created_from` and `created_to` to the tender approval endpoints for filtering by creation date using Unix timestamps.
- Updated the `GetByCompanyID` method in the repository and service layers to support the new filtering options.
- Modified the handler methods to parse and pass the new parameters, improving the flexibility of tender approval retrieval.
- Updated API documentation to reflect the new query parameters, ensuring clarity for API consumers.
This commit is contained in:
n.nakhostin
2025-09-03 10:23:47 +03:30
parent 8d3a021fbf
commit 61a217cf09
6 changed files with 64 additions and 9 deletions
+17 -1
View File
@@ -131,6 +131,8 @@ func (h *Handler) GetTenderApprovalByTenderAndCompany(c echo.Context) error {
// @Produce json
// @Param submission_mode query string false "Filter by submission mode Enums(self-apply, partnership)"
// @Param status query string false "Filter by status Enums(submitted, rejected)"
// @Param created_from query integer false "Filter by created date from (Unix timestamp)"
// @Param created_to query integer false "Filter by created date to (Unix timestamp)"
// @Success 200 {object} response.APIResponse{data=[]TenderApprovalWithTenderResponse} "Tender approvals retrieved successfully"
// @Failure 400 {object} response.APIResponse "Bad request - Invalid company ID"
// @Failure 500 {object} response.APIResponse "Internal server error"
@@ -166,7 +168,21 @@ func (h *Handler) PublicGetTenderApprovals(c echo.Context) error {
status = &statusVal
}
tenderApprovalsWithTender, err := h.service.GetTenderApprovalsByCompanyIDWithTender(c.Request().Context(), companyID, submissionMode, status)
var from *int64
if fromParam := c.QueryParam("created_from"); fromParam != "" {
if parsed, err := strconv.ParseInt(fromParam, 10, 64); err == nil {
from = &parsed
}
}
var to *int64
if toParam := c.QueryParam("created_to"); toParam != "" {
if parsed, err := strconv.ParseInt(toParam, 10, 64); err == nil {
to = &parsed
}
}
tenderApprovalsWithTender, err := h.service.GetTenderApprovalsByCompanyIDWithTender(c.Request().Context(), companyID, submissionMode, status, from, to)
if err != nil {
return response.InternalServerError(c, "Failed to get tender approvals")
}