Add Company Tender Approval Statistics Endpoint and Update API Documentation

- Introduced a new API endpoint to retrieve company-specific tender approval statistics, enhancing the analytics capabilities of the tender management system.
- Implemented the `GetCompanyTenderApprovalStats` method in the service layer to fetch detailed statistics, including total approvals, approved and rejected tenders, and submission counts.
- Updated Swagger documentation to accurately reflect the new endpoint, including detailed descriptions, parameters, and response formats for the `CompanyTenderApprovalStatsResponse`.
- Enhanced the router to include the new statistics route, ensuring adherence to Clean Architecture principles and maintaining a clear separation of concerns in the handler layer.
- Added necessary request and response forms to support the new functionality, improving the overall API structure and usability.
This commit is contained in:
n.nakhostin
2025-08-19 11:27:40 +03:30
parent 392b31626d
commit 81914e2eeb
8 changed files with 432 additions and 0 deletions
+25
View File
@@ -231,6 +231,31 @@ func (h *Handler) GetTenderApprovalStats(c echo.Context) error {
return response.Success(c, stats, "Tender approval statistics retrieved successfully")
}
// GetCompanyTenderApprovalStats returns company-specific tender approval statistics
// @Summary Get company tender approval statistics
// @Description Get comprehensive tender approval statistics for a specific company
// @Tags TenderApprovals
// @Accept json
// @Produce json
// @Success 200 {object} response.APIResponse{data=CompanyTenderApprovalStatsResponse} "Company tender approval statistics 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/stats [get]
func (h *Handler) GetCompanyTenderApprovalStats(c echo.Context) error {
companyID := c.Get("company_id").(string)
if companyID == "" {
return response.Unauthorized(c, "Unauthorized")
}
stats, err := h.service.GetCompanyTenderApprovalStats(c.Request().Context(), companyID)
if err != nil {
return response.InternalServerError(c, "Failed to get company tender approval statistics")
}
return response.Success(c, stats, "Company tender approval statistics retrieved successfully")
}
// GetTenderApprovalsByStatus retrieves tender approvals by status
// @Summary Get tender approvals by status
// @Description Retrieve tender approvals filtered by their status (approved, rejected)