package yb import ( "github.com/beego/beego/v2/client/orm" ) // Speaker 活动表 type Speaker struct { SpeakerId int `orm:"column(speaker_id);pk" description:"主讲人ID"` SpeakerName string `description:"主讲人"` SpeakerHeadPic string `description:"主讲人头像"` SpeakerBackgroundPic string `description:"主讲人背景图"` } // TableName 表名变更 func (speaker *Speaker) TableName() string { return "yb_speaker" } // GetSpeakerById 根据id获取主讲人详情 func GetSpeakerById(id int) (item *Speaker, err error) { o := orm.NewOrm() sql := "select * from yb_speaker where speaker_id=? " err = o.Raw(sql, id).QueryRow(&item) return } // GetAllSpeakerList 获取所有主讲人列表数据 func GetAllSpeakerList() (list []*Speaker, err error) { o := orm.NewOrm() sql := "select * from yb_speaker order by speaker_id desc " _, err = o.Raw(sql).QueryRows(&list) return }