query.go 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. package voice_section
  2. import (
  3. "hongze/hongze_yb/global"
  4. "hongze/hongze_yb/models/tables/voice_broadcast"
  5. )
  6. // GetVoiceSection 查询所有语音播报章节
  7. func GetVoiceSection() (list []*VoiceSection, err error) {
  8. err = global.DEFAULT_MYSQL.Order("create_time").Find(&list).Error
  9. return
  10. }
  11. // GetVoiceSection 查询所有语音播报章节
  12. func GetVoiceVariety() (list []*VoiceSection, err error) {
  13. err = global.DEFAULT_MYSQL.Group("variety_id").Order("create_time").Find(&list).Error
  14. return
  15. }
  16. // GetVoiceSectionFromBroadcast 查询所有语音播报章节
  17. func GetVoiceSectionFromBroadcast(bannedIds []int) (list []*voice_broadcast.VoiceBroadcast, err error) {
  18. err = global.DEFAULT_MYSQL.Where("section_id IN (?)", bannedIds).Group("section_id").Find(&list).Error
  19. return
  20. }
  21. // GetVoiceSectionById 主键获取板块信息
  22. func GetVoiceSectionById(sectionId int) (item *VoiceSection, err error) {
  23. err = global.DEFAULT_MYSQL.Model(VoiceSection{}).
  24. Where("section_id = ?", sectionId).
  25. First(&item).Error
  26. return
  27. }