package entity

import (
	users "narasi-ahli-be/app/database/entity/users"
	"time"
)

type EbookRatings struct {
	ID          uint            `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
	UserId      uint            `json:"user_id" gorm:"type:int4"`
	User        *users.Users    `json:"user" gorm:"foreignKey:UserId;references:ID"`
	EbookId     uint            `json:"ebook_id" gorm:"type:int4"`
	Ebook       *Ebooks         `json:"ebook" gorm:"foreignKey:EbookId;references:ID"`
	PurchaseId  uint            `json:"purchase_id" gorm:"type:int4"`
	Purchase    *EbookPurchases `json:"purchase" gorm:"foreignKey:PurchaseId;references:ID"`
	Rating      int             `json:"rating" gorm:"type:int4;check:rating >= 1 AND rating <= 5"`
	Review      *string         `json:"review" gorm:"type:text"`
	IsAnonymous *bool           `json:"is_anonymous" gorm:"type:bool;default:false"`
	IsVerified  *bool           `json:"is_verified" gorm:"type:bool;default:true"`
	StatusId    *int            `json:"status_id" gorm:"type:int4;default:1"`
	IsActive    *bool           `json:"is_active" gorm:"type:bool;default:true"`
	CreatedAt   time.Time       `json:"created_at" gorm:"default:now()"`
	UpdatedAt   time.Time       `json:"updated_at" gorm:"default:now()"`
}
