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
+34
View File
@@ -12,6 +12,7 @@ type FeedbackService interface {
GetFeedback(ctx context.Context, id string) (*FeedbackResponse, error)
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)
}
// feedbackService implements FeedbackService interface
@@ -52,6 +53,27 @@ func (s *feedbackService) ToggleFeedback(ctx context.Context, req ToggleFeedback
return feedback.ToResponse(), nil
}
if existing.FeedbackType == req.FeedbackType {
if existing.FeedbackType == FeedbackTypeLike {
existing.FeedbackType = FeedbackTypeUnLike
} else {
existing.FeedbackType = FeedbackTypeUnDislike
}
err = s.feedbackRepo.Delete(ctx, existing.GetID())
if err != nil {
s.logger.Error("Failed to update existing feedback", map[string]interface{}{
"feedback_id": existing.GetID(),
"tender_id": req.TenderID,
"company_id": *companyID,
"error": err.Error(),
})
return nil, err
}
return existing.ToResponse(), nil
}
if existing.FeedbackType == FeedbackTypeLike {
existing.FeedbackType = FeedbackTypeDislike
} else {
@@ -118,3 +140,15 @@ func (s *feedbackService) ListFeedback(ctx context.Context, criteria FeedbackSea
func (s *feedbackService) DeleteFeedback(ctx context.Context, id string) error {
return s.feedbackRepo.Delete(ctx, id)
}
func (s *feedbackService) GetFeedbackByTenderID(ctx context.Context, tenderID, companyID string) (*FeedbackResponse, error) {
feedback, err := s.feedbackRepo.GetByTenderID(ctx, tenderID, companyID)
if err != nil {
s.logger.Error("Failed to get feedback by tender ID", map[string]interface{}{
"tender_id": tenderID,
"error": err.Error(),
})
return nil, err
}
return feedback.ToResponse(), nil
}