package entity

import (
	"time"

	"github.com/google/uuid"
)

// MediaLibraryItem stores metadata for a single logical media asset (one public URL).
// The file may also be referenced from article_files, CMS image tables, etc.
type MediaLibraryItem struct {
	ID               uint       `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
	PublicURL        string     `json:"public_url" gorm:"type:varchar(2048);not null;uniqueIndex:ux_media_library_public_url"`
	ObjectKey        *string    `json:"object_key" gorm:"type:varchar(1024)"`
	OriginalFilename *string    `json:"original_filename" gorm:"type:varchar(512)"`
	FileCategory     string     `json:"file_category" gorm:"type:varchar(32);not null;default:other"` // image, video, audio, document, other
	SizeBytes        *int64     `json:"size_bytes" gorm:"type:int8"`
	SourceType       string     `json:"source_type" gorm:"type:varchar(64);not null"` // article_file, cms, upload
	SourceLabel      *string    `json:"source_label" gorm:"type:varchar(255)"`
	ArticleFileID    *uint      `json:"article_file_id" gorm:"type:int4"`
	CreatedByID      int        `json:"created_by_id" gorm:"type:int4;default:0"`
	ClientID         *uuid.UUID `json:"client_id" gorm:"type:UUID"`
	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()"`
}
