123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package yb
- import (
- "github.com/beego/beego/v2/client/orm"
- )
- type VoiceSection struct {
- SectionId int `orm:"column(section_id);pk" description:"板块id"`
- SectionName string `description:"板块名称"`
- ImgUrl string `description:"背景图url"`
- VarietyId int `description:"品种id"`
- VarietyName string `description:"品种名称"`
- Status int `description:"角色状态"`
- CreateTime string `description:"创建时间"`
- }
- // TableName 表名变更
- func (voiceSection *VoiceSection) TableName() string {
- return "yb_voice_section"
- }
- func GetVoiceSectionList(startSize, pageSize int) (list []*VoiceSection, err error) {
- o := orm.NewOrm()
- sql := "SELECT * FROM yb_voice_section ORDER BY create_time DESC limit ?, ? "
- _, err = o.Raw(sql, startSize, pageSize).QueryRows(&list)
- return
- }
- func AddVoiceSection(item VoiceSection) (err error) {
- o := orm.NewOrm()
- _, err = o.Insert(&item)
- if err != nil {
- return err
- }
- return
- }
- func GetVoiceSectionTotal() (total int, err error) {
- o := orm.NewOrm()
- sql := "SELECT COUNT(1) AS ct FROM yb_voice_section "
- err = o.Raw(sql).QueryRow(&total)
- return
- }
- func GetVoiceSectionEnableTotal() (total int, err error) {
- o := orm.NewOrm()
- sql := "SELECT COUNT(1) AS ct FROM yb_voice_section WHERE status=1 "
- err = o.Raw(sql).QueryRow(&total)
- return
- }
- func EditVoiceSection(condition string, pars []interface{}) (err error) {
- o := orm.NewOrm()
- sql := "UPDATE yb_voice_section SET status=? WHERE 1=1 "
- if condition != "" {
- sql += condition
- }
- _, err = o.Raw(sql, pars).Exec()
- return
- }
- // Update 更新语音播报板块
- func (voiceSection *VoiceSection) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(voiceSection, cols...)
- return
- }
- // GetAllEnableVoiceSectionList 获取所有启用的语言播报版块
- func GetAllEnableVoiceSectionList() (list []*VoiceSection, err error) {
- o := orm.NewOrm()
- sql := "SELECT * FROM yb_voice_section where status=1 ORDER BY create_time ASC "
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- // GetVoiceSectionById 根据版块id来获取版块信息
- func GetVoiceSectionById(sectionId int) (item *VoiceSection, err error) {
- o := orm.NewOrm()
- sql := "SELECT * FROM yb_voice_section WHERE section_id= ? "
- err = o.Raw(sql, sectionId).QueryRow(&item)
- return
- }
|