package yb_my_chart_classify

import "hongze/hongze_yb/global"

func (m *YbMyChartClassify) Create() (err error) {
	err = global.DEFAULT_MYSQL.Create(m).Error
	return
}

func (m *YbMyChartClassify) Update(updateCols []string) (err error) {
	err = global.DEFAULT_MYSQL.Model(m).Select(updateCols).Updates(m).Error
	return
}

func (m *YbMyChartClassify) List(condition string, pars []interface{}) (list []*YbMyChartClassify, err error) {
	list = make([]*YbMyChartClassify, 0)
	err = global.DEFAULT_MYSQL.Model(m).
		Where(condition, pars...).
		Order("sort ASC, my_chart_classify_id ASC").
		Find(&list).Error
	return
}

func (m *YbMyChartClassify) Fetch(id int) (item *YbMyChartClassify, err error) {
	err = global.DEFAULT_MYSQL.Model(m).Where("my_chart_classify_id = ?", id).First(&item).Error
	return
}

func (m *YbMyChartClassify) FetchByCondition(condition string, pars []interface{}) (item *YbMyChartClassify, err error) {
	err = global.DEFAULT_MYSQL.Model(m).
		Where(condition, pars...).
		First(&item).Error
	return
}

func (m *YbMyChartClassify) Delete() (err error) {
	err = global.DEFAULT_MYSQL.Delete(m).Error
	return
}
