package yb_my_chart import "hongze/hongze_yb/global" func (m *YbMyChart) Count(condition string, pars []interface{}) (num int64, err error) { err = global.DEFAULT_MYSQL.Model(m). Where(condition, pars...). Count(&num).Error return } func (m *YbMyChart) Create() (err error) { err = global.DEFAULT_MYSQL.Create(m).Error return } func (m *YbMyChart) Update(updateCols []string) (err error) { err = global.DEFAULT_MYSQL.Model(m).Select(updateCols).Updates(m).Error return } func (m *YbMyChart) List(condition string, pars []interface{}) (list []*YbMyChart, err error) { list = make([]*YbMyChart, 0) err = global.DEFAULT_MYSQL.Model(m). Where(condition, pars...). Order("create_time DESC"). Find(&list).Error return } func (m *YbMyChart) PageList(condition string, pars []interface{}, pageIndex, pageSize int) (list []*YbMyChart, err error) { offset := (pageIndex - 1) * pageSize err = global.DEFAULT_MYSQL.Model(m). Where(condition, pars...). Offset(offset).Limit(pageSize). Order("create_time DESC"). Scan(&list).Error return } func (m *YbMyChart) Fetch(id int) (item *YbMyChart, err error) { err = global.DEFAULT_MYSQL.Model(m).Where("my_chart_id = ?", id).First(&item).Error return } func (m *YbMyChart) FetchByCondition(condition string, pars []interface{}) (item *YbMyChart, err error) { err = global.DEFAULT_MYSQL.Model(m). Where(condition, pars...). First(&item).Error return } func (m *YbMyChart) Delete() (err error) { err = global.DEFAULT_MYSQL.Delete(m).Error return }