package voice_section

import (
	"hongze/hongze_yb/global"
	"hongze/hongze_yb/models/tables/voice_broadcast"
)

// GetVoiceSection 查询所有语音播报章节
func GetVoiceSection() (list []*VoiceSection, err error) {
	err = global.DEFAULT_MYSQL.Order("create_time").Find(&list).Error
	return
}

// GetVoiceSection 查询所有语音播报章节
func GetVoiceVariety() (list []*VoiceSection, err error) {
	err = global.DEFAULT_MYSQL.Group("variety_id").Order("create_time").Find(&list).Error
	return
}

// GetVoiceSectionFromBroadcast 查询所有语音播报章节
func GetVoiceSectionFromBroadcast(bannedIds []int) (list []*voice_broadcast.VoiceBroadcast, err error) {
	err = global.DEFAULT_MYSQL.Where("section_id IN (?)", bannedIds).Group("section_id").Find(&list).Error
	return
}

// GetVoiceSectionById 主键获取板块信息
func GetVoiceSectionById(sectionId int) (item *VoiceSection, err error) {
	err = global.DEFAULT_MYSQL.Model(VoiceSection{}).
		Where("section_id = ?", sectionId).
		First(&item).Error
	return
}