package banner

import "hongze/hongze_yb/global"

// GetBannerList
func GetBannerList(cond string, page, limit int) (list []*Banner, err error) {
	err = global.DEFAULT_MYSQL.Where(cond).Order("create_time desc").Limit(limit).Offset((page - 1) * limit).Find(&list).Error
	return
}

// GetBannerById
func GetBannerById(id int) (item *Banner, err error) {
	err = global.DEFAULT_MYSQL.Where(" id=? ",id).First(&item).Error
	return
}

// GetBannerListCount
func GetBannerListCount(cond string) (total int64, err error) {
	err = global.DEFAULT_MYSQL.Model(Banner{}).
		Where(cond).
		Count(&total).Error
	return
}