Update Configuration and Enhance Tender Approval Pagination
- Changed the server port from 8081 to 8082 for the web application. - Updated MongoDB URI to include authentication credentials for improved security. - Added new query parameters `limit` and `offset` for pagination in tender approval retrieval, enhancing the API's flexibility. - Modified the response structure to include metadata for pagination, improving the clarity of responses. - Updated API documentation to reflect the new pagination parameters and response format, ensuring consistency for API consumers.
This commit is contained in:
@@ -129,16 +129,34 @@ func (h *Handler) GetTenderApprovalByTenderAndCompany(c echo.Context) error {
|
||||
// @Tags TenderApprovals
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param limit query integer false "Number of approvals per page (1-100)" minimum(1) maximum(100) default(20)
|
||||
// @Param offset query integer false "Number of approvals to skip for pagination" minimum(0) default(0)
|
||||
// @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"
|
||||
// @Success 200 {object} response.APIResponse{data=TenderApprovalWithTenderListResponse} "Tender approvals retrieved successfully"
|
||||
// @Failure 400 {object} response.APIResponse "Bad request - Invalid company ID"
|
||||
// @Failure 500 {object} response.APIResponse "Internal server error"
|
||||
// @Security BearerAuth
|
||||
// @Router /api/v1/tender-approvals [get]
|
||||
func (h *Handler) PublicGetTenderApprovals(c echo.Context) error {
|
||||
|
||||
// Parse pagination parameters
|
||||
limit := 20
|
||||
if l := c.QueryParam("limit"); l != "" {
|
||||
if parsed, err := strconv.Atoi(l); err == nil && parsed > 0 && parsed <= 100 {
|
||||
limit = parsed
|
||||
}
|
||||
}
|
||||
|
||||
offset := 0
|
||||
if o := c.QueryParam("offset"); o != "" {
|
||||
if parsed, err := strconv.Atoi(o); err == nil && parsed >= 0 {
|
||||
offset = parsed
|
||||
}
|
||||
}
|
||||
|
||||
companyID := c.Get("company_id").(string)
|
||||
if companyID == "" {
|
||||
return response.Unauthorized(c, "Unauthorized")
|
||||
@@ -182,7 +200,7 @@ func (h *Handler) PublicGetTenderApprovals(c echo.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
tenderApprovalsWithTender, err := h.service.GetTenderApprovalsByCompanyIDWithTender(c.Request().Context(), companyID, submissionMode, status, from, to)
|
||||
tenderApprovalsWithTender, err := h.service.GetTenderApprovalsByCompanyIDWithTender(c.Request().Context(), companyID, submissionMode, status, from, to, limit, offset)
|
||||
if err != nil {
|
||||
return response.InternalServerError(c, "Failed to get tender approvals")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user