123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package yb
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type VoiceBroadcast struct {
- BroadcastId int `gorm:"primaryKey;column:broadcast_id;type:int(11)" description:"语音ID"`
- BroadcastName string `description:"语音名称"`
- SectionId int `description:"语音分类ID"`
- SectionName string `description:"语音分类名称"`
- VarietyId int `description:"品种id"`
- VarietyName string `description:"品种名称"`
- AuthorId int `description:"作者id"`
- Author string `description:"作者"`
- ImgUrl string `description:"背景图url"`
- VoiceUrl string `description:"音频url"`
- VoicePlaySeconds string `description:"音频时长"`
- VoiceSize string `description:"音频大小"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- PublishState int `description:"发布状态:0-未发布 1-已发布"`
- PublishTime time.Time `description:"发布时间"`
- PrePublishTime time.Time `description:"预发布时间"`
- MsgState int `description:"消息推送状态:0-待推送 1-已推送"`
- MsgTime time.Time `description:"消息推送时间"`
- }
- // TableName get sql table name.获取数据库表名
- func (m *VoiceBroadcast) TableName() string {
- return "yb_voice_broadcast"
- }
- func (item *VoiceBroadcast) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(item, cols...)
- return
- }
- func GetBroadcastById(broadcastId int) (item *VoiceBroadcast, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM yb_voice_broadcast WHERE broadcast_id = ? LIMIT 1`
- err = o.Raw(sql, broadcastId).QueryRow(&item)
- return
- }
- // GetUnpublishedVoiceBroadcastList 获取未发布的语音播报列表
- func GetUnpublishedVoiceBroadcastList() (list []*VoiceBroadcast, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM yb_voice_broadcast WHERE publish_state = 0 `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- // PublishVoiceBroadcast 发布语音播报
- func PublishVoiceBroadcast(broadcastId int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE yb_voice_broadcast
- SET publish_state = 1, publish_time = NOW(), msg_state = 1, msg_time = NOW()
- WHERE
- broadcast_id = ?
- LIMIT 1`
- _, err = o.Raw(sql, broadcastId).Exec()
- return
- }
|