Files
n.nakhostin a342da193e Refactor Feedback Module for Consistency and Clarity
- Updated feedback repository and service methods to use a consistent naming convention, changing `NewTenderRepository` and similar methods to `NewRepository`.
- Refactored feedback handler methods to improve clarity by renaming methods such as `ListFeedback` to `Search` and `GetFeedback` to `Get`.
- Enhanced feedback response structures to include detailed company and tender information, improving the clarity of feedback data returned to API consumers.
- Updated Swagger documentation to reflect changes in feedback response structures and endpoint paths, ensuring accurate representation of the API for consumers.
2025-09-24 12:20:19 +03:30

65 lines
1.8 KiB
Go

package feedback
import (
"tm/pkg/mongo"
"go.mongodb.org/mongo-driver/v2/bson"
)
// 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"`
}
// SetID sets the feedback ID (implements IDSetter interface)
func (f *Feedback) SetID(id string) {
f.ID, _ = bson.ObjectIDFromHex(id)
}
// GetID returns the feedback ID (implements IDGetter interface)
func (f *Feedback) GetID() string {
return f.ID.Hex()
}
// SetCreatedAt sets the created timestamp (implements Timestamp interface)
func (f *Feedback) SetCreatedAt(timestamp int64) {
f.CreatedAt = timestamp
}
// SetUpdatedAt sets the updated timestamp (implements Timestamp interface)
func (f *Feedback) SetUpdatedAt(timestamp int64) {
f.UpdatedAt = timestamp
}
// GetCreatedAt returns the created timestamp (implements Timestamp interface)
func (f *Feedback) GetCreatedAt() int64 {
return f.CreatedAt
}
// GetUpdatedAt returns the updated timestamp (implements Timestamp interface)
func (f *Feedback) GetUpdatedAt() int64 {
return f.UpdatedAt
}
// 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
}