123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "hongze/hongze_cygx/utils"
- "time"
- )
- // ActivityVoice 活动语音表结构体
- type CygxActivityVoice struct {
- ActivityVoiceId int `orm:"column(activity_voice_id);pk" description:"活动音频ID"`
- ActivityId int ` description:"活动ID"`
- VoiceUrl string `description:"音频地址"`
- VoiceName string `description:"音频名称"`
- VoicePlaySeconds string `description:"音频时长"`
- VoiceCounts int `description:"播放量"`
- ModifyTime string `description:"更新时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- // ActivityVoiceReq 音频数据
- type CygxActivityVoiceReq struct {
- ActivityId int ` description:"活动ID"`
- Url string `description:"音频资源url地址"`
- Name string `description:"音频名称"`
- PlaySeconds int `description:"音频时长"`
- }
- // GetCygxActivityVoiceReqList 获取活动ID的音频
- func GetCygxActivityVoiceReqList(activityIds []int) (items []*CygxActivityVoiceReq, err error) {
- lenactivityIds := len(activityIds)
- if lenactivityIds == 0 {
- return
- }
- sql := `SELECT
- activity_id ,
- voice_url AS url,
- voice_name AS name,
- voice_play_seconds AS play_seconds FROM cygx_activity_voice WHERE activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `) `
- o := orm.NewOrm()
- _, err = o.Raw(sql, activityIds).QueryRows(&items)
- return
- }
- func UpdateCygxActivityVoiceCounts(activityId int) (err error) {
- sql := `UPDATE cygx_activity_voice SET voice_counts = voice_counts+1 WHERE activity_id = ? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, activityId).Exec()
- return
- }
- // GetCygxActivityVoiceById 主键获取活动音频
- func GetCygxActivityVoiceById(videoId int) (item *CygxActivityVoice, err error) {
- sql := `SELECT * FROM cygx_activity_voice WHERE activity_voice_id = ? LIMIT 1`
- err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
- return
- }
|