package models

import (
	"time"

	"gorm.io/gorm"
)

type Article struct {
	ID          uint           `gorm:"primaryKey" json:"id"`
	Title       string         `gorm:"size:255;not null" json:"title"`
	Content     string         `gorm:"type:text;not null" json:"content"`
	Summary     string         `gorm:"size:500" json:"summary"`
	CoverImage  string         `gorm:"size:500" json:"cover_image"`
	Carousel    string         `gorm:"size:500" json:"carousel"`
	IsPinned    bool           `gorm:"default:false" json:"is_pinned"`
	IsPublished bool           `gorm:"default:true" json:"is_published"`
	SortOrder   int            `gorm:"default:0" json:"sort_order"`
	AuthorID    *uint          `json:"author_id"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`
	Author      *User          `gorm:"foreignKey:AuthorID" json:"author,omitempty"`
}

func (Article) TableName() string {
	return "articles"
}
