package entity

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

type Ebooks struct {
	ID            uint         `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
	Title         string       `json:"title" gorm:"type:varchar"`
	Slug          string       `json:"slug" gorm:"type:varchar"`
	Description   string       `json:"description" gorm:"type:varchar"`
	Price         float64      `json:"price" gorm:"type:decimal(10,2)"`
	PdfFilePath   *string      `json:"pdf_file_path" gorm:"type:varchar"`
	PdfFileName   *string      `json:"pdf_file_name" gorm:"type:varchar"`
	PdfFileSize   *int64       `json:"pdf_file_size" gorm:"type:int8"`
	ThumbnailPath *string      `json:"thumbnail_path" gorm:"type:varchar"`
	ThumbnailName *string      `json:"thumbnail_name" gorm:"type:varchar"`
	AuthorId      uint         `json:"author_id" gorm:"type:int4"`
	Author        *users.Users `json:"author" gorm:"foreignKey:AuthorId;references:ID"`
	Category      *string      `json:"category" gorm:"type:varchar"`
	Tags          *string      `json:"tags" gorm:"type:varchar"`
	PageCount     *int         `json:"page_count" gorm:"type:int4"`
	Language      *string      `json:"language" gorm:"type:varchar;default:'id'"`
	Isbn          *string      `json:"isbn" gorm:"type:varchar"`
	Publisher     *string      `json:"publisher" gorm:"type:varchar"`
	PublishedYear *int         `json:"published_year" gorm:"type:int4"`
	DownloadCount *int         `json:"download_count" gorm:"type:int4;default:0"`
	PurchaseCount *int         `json:"purchase_count" gorm:"type:int4;default:0"`
	WishlistCount *int         `json:"wishlist_count" gorm:"type:int4;default:0"`
	Rating        *float64     `json:"rating" gorm:"type:decimal(3,2);default:0"`
	ReviewCount   *int         `json:"review_count" gorm:"type:int4;default:0"`
	StatusId      *int         `json:"status_id" gorm:"type:int4;default:1"`
	IsActive      *bool        `json:"is_active" gorm:"type:bool;default:true"`
	IsPublished   *bool        `json:"is_published" gorm:"type:bool;default:false"`
	PublishedAt   *time.Time   `json:"published_at" gorm:"type:timestamp"`
	CreatedById   *uint        `json:"created_by_id" gorm:"type:int4"`
	CreatedAt     time.Time    `json:"created_at" gorm:"default:now()"`
	UpdatedAt     time.Time    `json:"updated_at" gorm:"default:now()"`
}
