Files
tp/main_dc/yalarba/api_es/internal/models/review.go
T
valitovgaziz ea9540dc73 new file: main_dc/yalarba/api_es/internal/models/authentication.go
new file:   main_dc/yalarba/api_es/internal/models/filter.go
	new file:   main_dc/yalarba/api_es/internal/models/object.go
	deleted:    main_dc/yalarba/api_es/internal/models/rest_object.go
	new file:   main_dc/yalarba/api_es/internal/models/review.go
	modified:   main_dc/yalarba/api_es/internal/models/user.go
add models into es system
2025-11-11 02:25:22 +05:00

28 lines
987 B
Go

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"`
}