Add Company Feedback Statistics Endpoint and Update API Documentation
- Introduced a new endpoint to retrieve comprehensive feedback statistics for the authenticated user's company, including total likes, dislikes, and percentage calculations. - Implemented the GetCompanyFeedbackStats method in the feedback handler to handle requests, ensuring proper authentication and error handling. - Updated Swagger JSON, YAML, and Go documentation to accurately reflect the new endpoint, including detailed descriptions, parameters, and response formats for the CompanyFeedbackStatsResponse. - Enhanced the feedback repository and service layers to support the new statistics functionality, improving the overall data handling capabilities of the tender management system. - These changes enhance the usability and functionality of the API, providing valuable insights into company feedback statistics.
This commit is contained in:
@@ -378,3 +378,29 @@ func (h *Handler) PublicGetFeedbackByTenderID(c echo.Context) error {
|
||||
|
||||
return response.Success(c, feedback, "Feedback retrieved successfully")
|
||||
}
|
||||
|
||||
// GetCompanyFeedbackStats retrieves feedback statistics for the authenticated user's company
|
||||
// @Summary Get company feedback statistics
|
||||
// @Description Retrieve comprehensive feedback statistics for the authenticated user's company including total likes, dislikes, and percentage calculations.
|
||||
// @Tags Feedback
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} response.APIResponse{data=CompanyFeedbackStatsResponse} "Company feedback statistics retrieved successfully"
|
||||
// @Failure 400 {object} response.APIResponse{error=string,message=string} "Bad request - Missing company association"
|
||||
// @Failure 401 {object} response.APIResponse{error=string,message=string} "Unauthorized - User not authenticated"
|
||||
// @Failure 500 {object} response.APIResponse{error=string,message=string} "Internal server error"
|
||||
// @Security BearerAuth
|
||||
// @Router /api/v1/feedback/stats/company [get]
|
||||
func (h *Handler) GetCompanyFeedbackStats(c echo.Context) error {
|
||||
companyID, err := user.GetCompanyIDFromContext(c)
|
||||
if err != nil {
|
||||
return response.BadRequest(c, "Company ID required", "User must be associated with a company")
|
||||
}
|
||||
|
||||
stats, err := h.service.CompanyFeedbackStats(c.Request().Context(), companyID)
|
||||
if err != nil {
|
||||
return response.InternalServerError(c, "Failed to retrieve company feedback statistics")
|
||||
}
|
||||
|
||||
return response.Success(c, stats, "Company feedback statistics retrieved successfully")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user