banner.go 849 B

12345678910111213141516171819202122232425262728293031
  1. package models
  2. import (
  3. "time"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type Banner struct {
  7. BannerId int `orm:"pk" description:"id"`
  8. ImageUrl string `description:"图片地址"`
  9. CreateTime time.Time `description:"创建时间"`
  10. ModifyTime time.Time `description:"修改时间"`
  11. JumpUrl string `description:"跳转路径"`
  12. Remake string `description:"备注"`
  13. ImageUrlPc string `description:"pc端图片地址"`
  14. }
  15. func GetBannerList(startSize, pageSize int) (items []*Banner, err error) {
  16. o := orm.NewOrm()
  17. sql := `SELECT * FROM banner LIMIT ?,?`
  18. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  19. return
  20. }
  21. func GetBannerById(bannerId int) (items *Banner, err error) {
  22. o := orm.NewOrm()
  23. sql := `SELECT * FROM banner WHERE banner_id = ?`
  24. err = o.Raw(sql, bannerId).QueryRow(&items)
  25. return
  26. }