yb_speaker.go 937 B

12345678910111213141516171819202122232425262728293031323334
  1. package yb
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. // Speaker 活动表
  6. type Speaker struct {
  7. SpeakerId int `orm:"column(speaker_id);pk" description:"主讲人ID"`
  8. SpeakerName string `description:"主讲人"`
  9. SpeakerHeadPic string `description:"主讲人头像"`
  10. SpeakerBackgroundPic string `description:"主讲人背景图"`
  11. }
  12. // TableName 表名变更
  13. func (speaker *Speaker) TableName() string {
  14. return "yb_speaker"
  15. }
  16. // GetSpeakerById 根据id获取主讲人详情
  17. func GetSpeakerById(id int) (item *Speaker, err error) {
  18. o := orm.NewOrm()
  19. sql := "select * from yb_speaker where speaker_id=? "
  20. err = o.Raw(sql, id).QueryRow(&item)
  21. return
  22. }
  23. // GetAllSpeakerList 获取所有主讲人列表数据
  24. func GetAllSpeakerList() (list []*Speaker, err error) {
  25. o := orm.NewOrm()
  26. sql := "select * from yb_speaker order by speaker_id desc "
  27. _, err = o.Raw(sql).QueryRows(&list)
  28. return
  29. }