392b31626d
- Replaced the existing tender approval update and delete endpoints with a new toggle functionality, allowing for more streamlined management of tender approvals. - Introduced the `ToggleTenderApproval` method in the service layer to handle both approval and rejection actions based on the current state of the tender approval. - Updated the API documentation to reflect the new endpoint structure and response formats, including the `TenderApprovalWithTenderResponse`. - Enhanced Swagger documentation to ensure accurate representation of the updated tender approval operations. - Removed obsolete methods and routes to maintain a clean and efficient codebase, adhering to Clean Architecture principles.
72 lines
2.4 KiB
Go
72 lines
2.4 KiB
Go
package feedback
|
|
|
|
import (
|
|
"time"
|
|
"tm/pkg/mongo"
|
|
"tm/pkg/response"
|
|
)
|
|
|
|
// FeedbackType represents the type of feedback
|
|
type FeedbackType string
|
|
|
|
const (
|
|
FeedbackTypeLike FeedbackType = "like"
|
|
FeedbackTypeDislike FeedbackType = "dislike"
|
|
)
|
|
|
|
// Feedback represents feedback given to a tender by a user
|
|
type Feedback struct {
|
|
mongo.Model `bson:",inline"`
|
|
TenderID string `bson:"tender_id" json:"tender_id" validate:"required"`
|
|
CustomerID *string `bson:"customer_id,omitempty" json:"customer_id,omitempty"`
|
|
CompanyID *string `bson:"company_id,omitempty" json:"company_id,omitempty"`
|
|
FeedbackType FeedbackType `bson:"feedback_type" json:"feedback_type" validate:"required,oneof=like dislike"`
|
|
}
|
|
|
|
// FeedbackSummary represents aggregated feedback statistics for a tender
|
|
type FeedbackSummary struct {
|
|
TenderID string `bson:"tender_id" json:"tender_id"`
|
|
TotalLikes int64 `bson:"total_likes" json:"total_likes"`
|
|
TotalDislikes int64 `bson:"total_dislikes" json:"total_dislikes"`
|
|
LastUpdated int64 `bson:"last_updated" json:"last_updated"` // Unix timestamp
|
|
}
|
|
|
|
// FeedbackSearchCriteria represents search criteria for feedback
|
|
type FeedbackSearchCriteria struct {
|
|
TenderID *string `json:"tender_id,omitempty"`
|
|
CustomerID *string `json:"customer_id,omitempty"`
|
|
CompanyID *string `json:"company_id,omitempty"`
|
|
FeedbackType *FeedbackType `json:"feedback_type,omitempty"`
|
|
DateFrom *int64 `json:"date_from,omitempty"` // Unix timestamp
|
|
DateTo *int64 `json:"date_to,omitempty"` // Unix timestamp
|
|
Limit int `json:"limit,omitempty"`
|
|
Offset int `json:"offset,omitempty"`
|
|
}
|
|
|
|
// FeedbackListResponse represents a paginated list of feedback
|
|
type FeedbackListResponse struct {
|
|
Feedback []*FeedbackResponse `json:"feedback"`
|
|
Meta *response.Meta `json:"meta"`
|
|
}
|
|
|
|
// GetID returns the feedback ID
|
|
func (f *Feedback) GetID() string {
|
|
return f.ID.Hex()
|
|
}
|
|
|
|
// IsLike returns true if the feedback is a like
|
|
func (f *Feedback) IsLike() bool {
|
|
return f.FeedbackType == FeedbackTypeLike
|
|
}
|
|
|
|
// IsDislike returns true if the feedback is a dislike
|
|
func (f *Feedback) IsDislike() bool {
|
|
return f.FeedbackType == FeedbackTypeDislike
|
|
}
|
|
|
|
// UpdateFeedbackType updates the feedback type and updated timestamp
|
|
func (f *Feedback) UpdateFeedbackType(feedbackType FeedbackType) {
|
|
f.FeedbackType = feedbackType
|
|
f.UpdatedAt = time.Now().Unix()
|
|
}
|