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:
@@ -13,6 +13,7 @@ type FeedbackService interface {
|
||||
ListFeedback(ctx context.Context, criteria FeedbackSearchCriteria, limit, offset int) (*FeedbackListResponse, error)
|
||||
DeleteFeedback(ctx context.Context, id string) error
|
||||
GetFeedbackByTenderID(ctx context.Context, tenderID, companyID string) (*FeedbackResponse, error)
|
||||
CompanyFeedbackStats(ctx context.Context, companyID string) (*CompanyFeedbackStatsResponse, error)
|
||||
}
|
||||
|
||||
// feedbackService implements FeedbackService interface
|
||||
@@ -152,3 +153,27 @@ func (s *feedbackService) GetFeedbackByTenderID(ctx context.Context, tenderID, c
|
||||
}
|
||||
return feedback.ToResponse(), nil
|
||||
}
|
||||
|
||||
func (s *feedbackService) CompanyFeedbackStats(ctx context.Context, companyID string) (*CompanyFeedbackStatsResponse, error) {
|
||||
s.logger.Info("Getting company feedback statistics", map[string]interface{}{
|
||||
"company_id": companyID,
|
||||
})
|
||||
|
||||
stats, err := s.feedbackRepo.GetCompanyFeedbackStats(ctx, companyID)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get company feedback statistics", map[string]interface{}{
|
||||
"company_id": companyID,
|
||||
"error": err.Error(),
|
||||
})
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.logger.Info("Company feedback statistics retrieved successfully", map[string]interface{}{
|
||||
"company_id": companyID,
|
||||
"total_feedback": stats.TotalFeedback,
|
||||
"total_likes": stats.TotalLikes,
|
||||
"total_dislikes": stats.TotalDislikes,
|
||||
})
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user