Refactor Feedback Service to Include Tender Information in Responses
- Updated the FeedbackService to include a new dependency on TenderService, allowing feedback responses to include associated tender details. - Modified the ListFeedback method to return a new FeedbackListWithTenderResponse type, which includes feedback along with tender information. - Enhanced the feedback entity and form structures to support the new response format, improving the API's capability to provide comprehensive feedback data. - Adjusted the main application initialization to reflect the changes in the feedback service dependencies.
This commit is contained in:
@@ -2,6 +2,7 @@ package feedback
|
||||
|
||||
import (
|
||||
"time"
|
||||
"tm/pkg/response"
|
||||
)
|
||||
|
||||
// ListFeedbackForm represents the form for listing feedback
|
||||
@@ -30,6 +31,53 @@ type FeedbackResponse struct {
|
||||
CompanyId *string `json:"company_id"`
|
||||
}
|
||||
|
||||
// FeedbackListResponse represents a paginated list of feedback
|
||||
type FeedbackListResponse struct {
|
||||
Feedback []*FeedbackResponse `json:"feedback"`
|
||||
Meta *response.Meta `json:"meta"`
|
||||
}
|
||||
|
||||
// FeedbackListResponse represents a paginated list of feedback
|
||||
type FeedbackListWithTenderResponse struct {
|
||||
Feedback []*FeedbackWithTenderResponse `json:"feedback"`
|
||||
Meta *response.Meta `json:"meta"`
|
||||
}
|
||||
type FeedbackWithTenderResponse struct {
|
||||
ID string `json:"id"`
|
||||
FeedbackType FeedbackType `json:"feedback_type"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
TenderID string `json:"tender_id"`
|
||||
CustomerID *string `json:"customer_id"`
|
||||
CompanyId *string `json:"company_id"`
|
||||
Tender *tenderDetails `json:"tender"`
|
||||
}
|
||||
|
||||
// tenderDetails represents essential tender information for the response
|
||||
type (
|
||||
tenderDetails struct {
|
||||
ID string `json:"id"`
|
||||
NoticePublicationID string `json:"notice_publication_id"`
|
||||
PublicationDate int64 `json:"publication_date"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
ProcurementTypeCode string `json:"procurement_type_code"`
|
||||
ProcedureCode string `json:"procedure_code"`
|
||||
EstimatedValue float64 `json:"estimated_value"`
|
||||
Currency string `json:"currency"`
|
||||
Duration string `json:"duration"`
|
||||
DurationUnit string `json:"duration_unit"`
|
||||
TenderDeadline int64 `json:"tender_deadline"`
|
||||
SubmissionDeadline int64 `json:"submission_deadline"`
|
||||
CountryCode string `json:"country_code"`
|
||||
BuyerOrganization *organizationResponse `json:"buyer_organization"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
organizationResponse struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
)
|
||||
|
||||
// CompanyFeedbackStatsResponse represents the response for company feedback statistics
|
||||
type CompanyFeedbackStatsResponse struct {
|
||||
CompanyID string `json:"company_id"`
|
||||
@@ -68,3 +116,16 @@ func (f *Feedback) ToResponse() *FeedbackResponse {
|
||||
CreatedAt: f.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Feedback) ToResponseWithTender(tender *tenderDetails) *FeedbackWithTenderResponse {
|
||||
return &FeedbackWithTenderResponse{
|
||||
ID: f.ID.Hex(),
|
||||
FeedbackType: f.FeedbackType,
|
||||
TenderID: f.TenderID,
|
||||
CustomerID: f.CustomerID,
|
||||
CompanyId: f.CompanyID,
|
||||
UpdatedAt: f.UpdatedAt,
|
||||
CreatedAt: f.CreatedAt,
|
||||
Tender: tender,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user