package book

import "time"

const (
	BookEraTagUnknown               = "unknown"
	BookEraTagAncient               = "ancient"
	BookEraTagHan                   = "han"
	BookEraTagTang                  = "tang"
	BookEraTagSong                  = "song"
	BookEraTagYuan                  = "yuan"
	BookEraTagMing                  = "ming"
	BookEraTagQing                  = "qing"
	BookEraTagModern                = "modern"
	BookEraTagContemporary          = "contemporary"
	BookCompletionStatusCompleted   = "completed"
	BookCompletionStatusSerializing = "serializing"
	BookPublishStatusDraft          = "draft"
	BookPublishStatusOffShelf       = "off_shelf"
	BookPublishStatusOnShelf        = "on_shelf"
	BookAuthorStatusEnabled         = "enabled"
	BookAuthorStatusDisabled        = "disabled"
	BookCommentStatusNormal         = "normal"
	BookCommentStatusHidden         = "hidden"
)

type Book struct {
	HardDeleteModel
	Title            string     `json:"title" form:"title" gorm:"type:varchar(255);not null;comment:书名主标题"`
	Subtitle         string     `json:"subtitle" form:"subtitle" gorm:"type:varchar(255);comment:书籍副标题"`
	BookType         string     `json:"bookType" form:"bookType" gorm:"type:varchar(64);not null;index;comment:书籍类型字典值，对应 book_type"`
	EraTag           string     `json:"eraTag" form:"eraTag" gorm:"type:varchar(32);not null;default:unknown;index;comment:时代标签字典值，对应 book_era_tag"`
	CoverUrl         string     `json:"coverUrl" form:"coverUrl" gorm:"type:varchar(500);comment:封面图片 URL"`
	Publisher        string     `json:"publisher" form:"publisher" gorm:"type:varchar(128);comment:出版社名称"`
	PublishedAt      *time.Time `json:"publishedAt" form:"publishedAt" gorm:"type:date;comment:出版日期"`
	Intro            string     `json:"intro" form:"intro" gorm:"type:text;comment:书籍简介"`
	HotScore         int64      `json:"hotScore" form:"hotScore" gorm:"not null;default:0;comment:热度聚合值"`
	Rating           float64    `json:"rating" form:"rating" gorm:"type:numeric(3,1);not null;default:0.0;comment:书籍评分，范围 0-10"`
	CommentCount     int64      `json:"commentCount" form:"commentCount" gorm:"not null;default:0;comment:点评数聚合值"`
	WordCount        int64      `json:"wordCount" form:"wordCount" gorm:"not null;default:0;comment:书籍总字数"`
	CompletionStatus string     `json:"completionStatus" form:"completionStatus" gorm:"type:varchar(32);not null;default:serializing;index;comment:书籍完结状态字典值，对应 book_completion_status"`
	PublishStatus    string     `json:"publishStatus" form:"publishStatus" gorm:"type:varchar(32);not null;default:draft;index;comment:书籍上下架状态字典值，对应 book_publish_status"`
	SeriesID         *uint      `json:"seriesId" form:"seriesId" gorm:"index:idx_book_series_id_series_sort;comment:所属系列 ID，可为空"`
	SeriesSort       int        `json:"seriesSort" form:"seriesSort" gorm:"not null;default:0;index:idx_book_series_id_series_sort;comment:同系列内展示排序"`
	RawTxtUrl        string     `json:"rawTxtUrl" form:"rawTxtUrl" gorm:"type:varchar(500);comment:原始 txt 文件 URL"`
}

func (Book) TableName() string {
	return "book"
}
