package eta

import "eta/eta_mini_ht_api/models"

const (
	columns = "title,content,video_url,video_name,video_play_seconds,video_size"
)

// ReportChapter 表示报告章节的结构体
type ReportChapter struct {
	Title            string `gorm:"column:title;size:125;not null;default:'';comment:'章节标题'"`
	Abstract         string `gorm:"column:abstract;size:255;not null;default:'';comment:'摘要'"`
	Author           string `gorm:"column:author;size:50;not null;default:'';comment:'作者'"`
	Content          string `gorm:"column:content;type:longtext;comment:'内容'"`
	VideoURL         string `gorm:"column:video_url;size:255;not null;default:'';comment:'音频文件URL'"`
	VideoName        string `gorm:"column:video_name;size:255;not null;default:'';comment:'音频文件名称'"`
	VideoPlaySeconds string `gorm:"column:video_play_seconds;size:255;not null;default:'';comment:'音频播放时长'"`
	VideoSize        string `gorm:"column:video_size;size:20;not null;default:'';comment:'音频文件大小，单位M'"`
}

func GetChaptersByReportId(reportId int) (chapters []ReportChapter, err error) {
	db := models.ETA()
	err = db.Select(columns).Where("report_id = ?", reportId).Where("publish_state = ?", 2).Find(&chapters).Error
	return
}

func (ReportChapter) TableName() string {
	return "report_chapter"
}
