Files
tp/main_dc/yalarba/api_yal/internal/models/comment.go
T
valitovgaziz c0734f50e8 modified: main_dc/yalarba/api_yal/internal/database/psql_db.go
new file:   main_dc/yalarba/api_yal/internal/models/comment.go
	modified:   main_dc/yalarba/api_yal/internal/models/feedback.go
add comment into models
add comment into feedback
add comment into autoMigrate psql_db.go
2026-02-22 14:04:55 +05:00

29 lines
1.3 KiB
Go

package models
import ()
// Comment представляет комментарий к отзыву (Feedback)
type Comment struct {
/*ID, CreatedAt, UpdatedAt, DeletedAt (Update's history)*/
Base Base `gorm:"embedded"`
// Автор комментария
AuthorID uint `gorm:"not null;index" json:"author_id"`
Author Account `gorm:"foreignKey:AuthorID;references:ID" json:"author,omitempty"`
// Отзыв, к которому оставлен комментарий
FeedbackID uint `gorm:"not null;index" json:"feedback_id"`
Feedback Feedback `gorm:"foreignKey:FeedbackID;references:ID" json:"feedback,omitempty"`
// Содержание комментария
Text string `gorm:"not null" json:"text"`
// Для поддержки вложенных комментариев (ответы на комментарии)
ParentID *uint `gorm:"index" json:"parent_id,omitempty"` // NULL для корневых комментариев
Parent *Comment `gorm:"foreignKey:ParentID;references:ID" json:"parent,omitempty"`
Replies []Comment `gorm:"foreignKey:ParentID;references:ID" json:"replies,omitempty"`
// Статус
IsEdited bool `gorm:"default:false" json:"is_edited"`
IsVerified bool `gorm:"default:false" json:"is_verified"` // если нужна модерация
}