query.go 581 B

1234567891011121314151617181920212223
  1. package banner
  2. import "hongze/hongze_yb/global"
  3. // GetBannerList
  4. func GetBannerList(cond string, page, limit int) (list []*Banner, err error) {
  5. err = global.DEFAULT_MYSQL.Where(cond).Limit(limit).Offset((page - 1) * limit).Find(&list).Error
  6. return
  7. }
  8. // GetBannerById
  9. func GetBannerById(id int) (item *Banner, err error) {
  10. err = global.DEFAULT_MYSQL.Where(" id=? ",id).First(&item).Error
  11. return
  12. }
  13. // GetBannerListCount
  14. func GetBannerListCount(cond string) (total int64, err error) {
  15. err = global.DEFAULT_MYSQL.Model(Banner{}).
  16. Where(cond).
  17. Count(&total).Error
  18. return
  19. }