activity_voice.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package yb
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ActivityVoice 活动语音表结构体
  7. type ActivityVoice struct {
  8. ActivityVoiceId int `orm:"column(activity_voice_id);pk" description:"活动音频ID"`
  9. ActivityId int ` description:"活动ID"`
  10. VoiceUrl string `description:"音频地址"`
  11. VoiceName string `description:"音频名称"`
  12. VoicePlaySeconds string `description:"音频时长"`
  13. CreateTime time.Time `description:"创建时间"`
  14. }
  15. // TableName 表名变更
  16. func (activityVoice *ActivityVoice) TableName() string {
  17. return "yb_activity_voice"
  18. }
  19. // DelByActivityId 根据活动id删除所有音频
  20. func DelByActivityId(activityId int) (err error) {
  21. o := orm.NewOrm()
  22. sql := "delete from yb_activity_voice where activity_id=?"
  23. _, err = o.Raw(sql, activityId).Exec()
  24. return
  25. }
  26. // AddActivityVoice 新增活动音频
  27. func AddActivityVoice(activityVoiceInfo *ActivityVoice) (err error) {
  28. o := orm.NewOrm()
  29. _, err = o.Insert(activityVoiceInfo)
  30. return
  31. }
  32. // AddActivityVoiceMulti 批量新增活动音频
  33. func AddActivityVoiceMulti(activityVoiceList []*ActivityVoice) (err error) {
  34. o := orm.NewOrm()
  35. _, err = o.InsertMulti(len(activityVoiceList), activityVoiceList)
  36. return
  37. }
  38. // GetVoiceListByActivityIds 根据活动id集合获取音频列表
  39. func GetVoiceListByActivityIds(activityIds string) (list []*ActivityVoice, err error) {
  40. if activityIds == "" {
  41. return
  42. }
  43. o := orm.NewOrm()
  44. sql := `select * from yb_activity_voice where activity_id in (` + activityIds + `) `
  45. _, err = o.Raw(sql).QueryRows(&list)
  46. return
  47. }