43 lines
973 B
Go
43 lines
973 B
Go
package models
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
"time"
|
|
)
|
|
|
|
type Feedback struct {
|
|
UUID string `gorm:"primaryKey"`
|
|
UserID string `gorm:"type:varchar(255)"`
|
|
ProjectID string `gorm:"type:varchar(255)"`
|
|
|
|
SessionUUID string `gorm:"type:varchar(255)"`
|
|
|
|
Type FeedbackType `gorm:"type:varchar(255)"`
|
|
Text string `gorm:"type:varchar(300)"`
|
|
|
|
Upvote []Upvote `gorm:"foreignKey:FeedbackUUID;references:UUID"`
|
|
|
|
CreatedAt time.Time `gorm:"type:timestamp"`
|
|
UpdatedAt time.Time `gorm:"type:timestamp"`
|
|
}
|
|
|
|
type FeedbackType string
|
|
|
|
const (
|
|
FeedbackTypeFeature FeedbackType = "feature"
|
|
FeedbackTypeFeedback FeedbackType = "feedback"
|
|
FeedbackTypeSupport FeedbackType = "support"
|
|
)
|
|
|
|
func NewFeedback(userUUID, sessionUUID, text, projectID string, feedbackType FeedbackType) *Feedback {
|
|
return &Feedback{
|
|
UUID: uuid.New().String(),
|
|
UserID: userUUID,
|
|
SessionUUID: sessionUUID,
|
|
ProjectID: projectID,
|
|
|
|
Type: feedbackType,
|
|
Text: text,
|
|
}
|
|
}
|