12345678910111213141516171819202122232425262728293031323334353637383940 |
- package yb_user_collection
- import "hongze/hongze_yb/global"
- func (item *YbUserCollection) Create() (err error) {
- err = global.DEFAULT_MYSQL.Create(item).Error
- return
- }
- func (item *YbUserCollection) Update(updateCols []string) (err error) {
- err = global.DEFAULT_MYSQL.Model(item).Select(updateCols).Updates(*item).Error
- return
- }
- // GetPageListByCondition 获取收藏列表-分页
- func GetPageListByCondition(condition string, pars []interface{}, pageIndex, pageSize int) (list []*YbUserCollection, err error) {
- offset := (pageIndex - 1) * pageSize
- err = global.DEFAULT_MYSQL.Model(YbUserCollection{}).
- Where(condition, pars...).
- Offset(offset).Limit(pageSize).
- Order("create_time DESC").
- Scan(&list).Error
- return
- }
- // GetPageListTotalByCondition 获取收藏列表总数-分页
- func GetPageListTotalByCondition(condition string, pars []interface{}) (total int64, err error) {
- err = global.DEFAULT_MYSQL.Model(YbUserCollection{}).
- Where(condition, pars...).
- Count(&total).Error
- return
- }
- // GetItemById 主键获取收藏
- func GetItemById(collectionId int) (item *YbUserCollection, err error) {
- err = global.DEFAULT_MYSQL.Model(YbUserCollection{}).
- Where("collection_id = ? AND state = 1", collectionId).
- First(&item).Error
- return
- }
|