Files
tm_back/internal/feedback/form.go
T

99 lines
3.6 KiB
Go

package feedback
import "tm/pkg/response"
// ToggleFeedbackForm represents the form for toggling feedback (like/dislike)
type ToggleFeedbackForm struct {
Tender string `json:"tender_id" validate:"required"`
Type FeedbackType `json:"feedback_type" validate:"required,oneof=like dislike"`
}
// SearchForm represents search criteria for feedback
type SearchForm struct {
Tender *string `query:"tender_id" valid:"optional"`
Customer *string `query:"customer_id" valid:"optional"`
Company *string `query:"company_id" valid:"optional"`
Type *string `query:"feedback_type" valid:"optional,in(like|dislike)"`
DateFrom *int64 `query:"date_from" valid:"optional"`
DateTo *int64 `query:"date_to" valid:"optional"`
}
type (
FeedbackResponse 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 *tenderResponse `json:"tender"`
Company *companyResponse `json:"company"`
}
tenderResponse 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"`
}
companyResponse struct {
ID string `json:"id"`
Name string `json:"name"`
}
)
type FeedbackListResponse struct {
Feedback []*FeedbackResponse `json:"feedback"`
Meta *response.Meta `json:"-"`
}
func (f *Feedback) ToResponse(tender *tenderResponse, company *companyResponse) *FeedbackResponse {
return &FeedbackResponse{
ID: f.ID.Hex(),
FeedbackType: f.FeedbackType,
TenderID: f.TenderID,
CustomerID: f.CustomerID,
CompanyId: f.CompanyID,
UpdatedAt: f.UpdatedAt,
CreatedAt: f.CreatedAt,
Tender: tender,
Company: company,
}
}
type StatsResponse struct {
CompanyID string `json:"company_id"`
Company *companyResponse `json:"company"`
TotalLikes int64 `json:"total_likes"`
TotalDislikes int64 `json:"total_dislikes"`
TotalFeedback int64 `json:"total_feedback"`
LastUpdated int64 `json:"last_updated"`
}
// CustomerStatsResponse represents feedback statistics for a single customer.
type CustomerStatsResponse struct {
CustomerID string `json:"customer_id"`
TotalLikes int64 `json:"total_likes"`
TotalDislikes int64 `json:"total_dislikes"`
TotalFeedback int64 `json:"total_feedback"`
LastUpdated int64 `json:"last_updated"`
}