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
+32
View File
@@ -346,3 +346,35 @@ func (h *Handler) PublicGetFeedback(c echo.Context) error {
return response.Success(c, feedback, "Feedback retrieved successfully")
}
// PublicGetFeedbackByTenderID retrieves feedback by tender ID
// @Summary Get feedback by tender ID
// @Description Retrieve feedback details by tender ID. This endpoint provides basic feedback information for public users.
// @Tags Feedback
// @Accept json
// @Produce json
// @Param tender_id path string true "Tender ID (MongoDB ObjectID format)" minlength(24) maxlength(24)
// @Success 200 {object} response.APIResponse{data=FeedbackResponse} "Feedback retrieved successfully"
// @Failure 400 {object} response.APIResponse{error=string,message=string} "Bad request - Invalid tender ID format"
// @Failure 404 {object} response.APIResponse{error=string,message=string} "Feedback not found"
// @Failure 500 {object} response.APIResponse{error=string,message=string} "Internal server error"
// @Security BearerAuth
// @Router /api/v1/feedback/tender/{tender_id} [get]
func (h *Handler) PublicGetFeedbackByTenderID(c echo.Context) error {
tenderID := c.Param("tender_id")
if tenderID == "" {
return response.BadRequest(c, "Tender ID is required", "Tender ID parameter is missing")
}
companyID, err := user.GetCompanyIDFromContext(c)
if err != nil {
return response.BadRequest(c, "Company ID required", "User must be associated with a company")
}
feedback, err := h.service.GetFeedbackByTenderID(c.Request().Context(), tenderID, companyID)
if err != nil {
return response.BadRequest(c, "Failed to get feedback", "")
}
return response.Success(c, feedback, "Feedback retrieved successfully")
}