123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package yb
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // ActivityVoice 活动语音表结构体
- type ActivityVoice struct {
- ActivityVoiceId int `orm:"column(activity_voice_id);pk" description:"活动音频ID"`
- ActivityId int ` description:"活动ID"`
- VoiceUrl string `description:"音频地址"`
- VoiceName string `description:"音频名称"`
- VoicePlaySeconds string `description:"音频时长"`
- CreateTime time.Time `description:"创建时间"`
- }
- // TableName 表名变更
- func (activityVoice *ActivityVoice) TableName() string {
- return "yb_activity_voice"
- }
- // DelByActivityId 根据活动id删除所有音频
- func DelByActivityId(activityId int) (err error) {
- o := orm.NewOrm()
- sql := "delete from yb_activity_voice where activity_id=?"
- _, err = o.Raw(sql, activityId).Exec()
- return
- }
- // AddActivityVoice 新增活动音频
- func AddActivityVoice(activityVoiceInfo *ActivityVoice) (err error) {
- o := orm.NewOrm()
- _, err = o.Insert(activityVoiceInfo)
- return
- }
- // AddActivityVoiceMulti 批量新增活动音频
- func AddActivityVoiceMulti(activityVoiceList []*ActivityVoice) (err error) {
- o := orm.NewOrm()
- _, err = o.InsertMulti(len(activityVoiceList), activityVoiceList)
- return
- }
- // GetVoiceListByActivityIds 根据活动id集合获取音频列表
- func GetVoiceListByActivityIds(activityIds string) (list []*ActivityVoice, err error) {
- if activityIds == "" {
- return
- }
- o := orm.NewOrm()
- sql := `select * from yb_activity_voice where activity_id in (` + activityIds + `) `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
|