Add Feedback Retrieval Endpoint for Tender ID

- Introduced a new API endpoint to retrieve feedback details by tender ID, enhancing the feedback management system for public users.
- Updated Swagger documentation to accurately reflect the new endpoint, including detailed descriptions, parameters, and response formats.
- Implemented necessary service and repository methods to support the new functionality, ensuring adherence to Clean Architecture principles.
- Modified existing routes to include the new feedback retrieval functionality, maintaining a clear separation of concerns in the handler layer.
- Enhanced feedback types to include 'unlike' and 'undislike' options for better user interaction.
This commit is contained in:
n.nakhostin
2025-08-17 13:29:44 +03:30
parent 4663a9781e
commit a8ef631e43
7 changed files with 329 additions and 8 deletions
+16
View File
@@ -22,6 +22,7 @@ type Repository interface {
Search(ctx context.Context, criteria FeedbackSearchCriteria) ([]*Feedback, error)
GetFeedbackSummary(ctx context.Context, tenderID string) (*FeedbackSummary, error)
GetFeedbackCountByType(ctx context.Context) (map[FeedbackType]int64, error)
GetByTenderID(ctx context.Context, tenderID, companyID string) (*Feedback, error)
}
// feedbackRepository implements FeedbackRepository interface using MongoDB ORM
@@ -396,6 +397,21 @@ func (r *feedbackRepository) GetCustomerFeedbackHistory(ctx context.Context, cus
return feedback, result.TotalCount, nil
}
func (r *feedbackRepository) GetByTenderID(ctx context.Context, tenderID, companyID string) (*Feedback, error) {
filter := bson.M{"tender_id": tenderID, "company_id": companyID}
result, err := r.repo.FindOne(ctx, filter)
if err != nil {
r.logger.Error("Failed to get feedback by tender ID", map[string]interface{}{
"tender_id": tenderID,
"error": err.Error(),
})
return nil, err
}
return result, nil
}
// buildSearchFilter builds MongoDB filter from search criteria
func (r *feedbackRepository) buildSearchFilter(criteria FeedbackSearchCriteria) bson.M {
filter := bson.M{}