21b736b55b
- Introduced a new feedback management system, including the creation of feedback entities, services, and repositories. - Implemented CRUD operations for feedback, allowing users to submit likes and dislikes on tenders. - Developed administrative endpoints for listing and retrieving feedback with comprehensive filtering options. - Enhanced public API to allow users to view feedback related to tenders. - Updated Swagger documentation to reflect new feedback endpoints and their functionalities. - Removed obsolete configuration file `config.yaml` as part of the transition to a modular configuration system. - Ensured adherence to Clean Architecture principles throughout the implementation.
62 lines
1.8 KiB
Go
62 lines
1.8 KiB
Go
package feedback
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// ListFeedbackForm represents the form for listing feedback
|
|
type ListFeedbackForm struct {
|
|
Feedbacks []FeedbackResponse `json:"feedbacks"`
|
|
DateFrom *int64 `json:"date_from,omitempty" validate:"omitempty,min=0"`
|
|
DateTo *int64 `json:"date_to,omitempty" validate:"omitempty,min=0"`
|
|
Limit int `json:"limit" validate:"required,min=1,max=100"`
|
|
Offset int `json:"offset" validate:"required,min=0"`
|
|
}
|
|
|
|
// ToggleFeedbackForm represents the form for toggling feedback (like/dislike)
|
|
type ToggleFeedbackForm struct {
|
|
TenderID string `json:"tender_id" validate:"required"`
|
|
FeedbackType FeedbackType `json:"feedback_type" validate:"required,oneof=like dislike"`
|
|
}
|
|
|
|
// FeedbackResponse represents the response for feedback operations
|
|
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"`
|
|
CustomerID *string `json:"customer_id"`
|
|
CompanyId *string `json:"company_id"`
|
|
}
|
|
|
|
// GetDateFromTime returns the date_from as time.Time
|
|
func (f *ListFeedbackForm) GetDateFromTime() *time.Time {
|
|
if f.DateFrom == nil {
|
|
return nil
|
|
}
|
|
t := time.Unix(*f.DateFrom, 0)
|
|
return &t
|
|
}
|
|
|
|
// GetDateToTime returns the date_to as time.Time
|
|
func (f *ListFeedbackForm) GetDateToTime() *time.Time {
|
|
if f.DateTo == nil {
|
|
return nil
|
|
}
|
|
t := time.Unix(*f.DateTo, 0)
|
|
return &t
|
|
}
|
|
|
|
func (f *Feedback) ToResponse() *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,
|
|
}
|
|
}
|