package models

import (
    "time"
)

type Review struct {
    ID        uint      `gorm:"primaryKey" json:"id"`
    CreatedAt time.Time `json:"created_at"`
    
    // Связи
    ObjectID  uint      `gorm:"not null" json:"object_id"`
    Object    Object    `gorm:"foreignKey:ObjectID" json:"object,omitempty"`
    AuthorID  uint      `gorm:"not null" json:"author_id"`
    Author    User      `gorm:"foreignKey:AuthorID" json:"author"`
    
    // Контент отзыва
    Rating    int       `gorm:"not null;check:rating >= 1 AND rating <= 5" json:"rating"`
    Text      string    `gorm:"type:text" json:"text"`
    IsActive  bool      `gorm:"default:true" json:"is_active"`
}

// ReviewCreateRequest - запрос на создание отзыва
type ReviewCreateRequest struct {
    ObjectID uint   `json:"object_id" binding:"required"`
    Rating   int    `json:"rating" binding:"required,min=1,max=5"`
    Text     string `json:"text" binding:"required,min=10"`
}