model.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package yb_my_chart_classify
  2. import "hongze/hongze_yb/global"
  3. func (m *YbMyChartClassify) Create() (err error) {
  4. err = global.DEFAULT_MYSQL.Create(m).Error
  5. return
  6. }
  7. func (m *YbMyChartClassify) Update(updateCols []string) (err error) {
  8. err = global.DEFAULT_MYSQL.Model(m).Select(updateCols).Updates(m).Error
  9. return
  10. }
  11. func (m *YbMyChartClassify) List(condition string, pars []interface{}) (list []*YbMyChartClassify, err error) {
  12. list = make([]*YbMyChartClassify, 0)
  13. err = global.DEFAULT_MYSQL.Model(m).
  14. Where(condition, pars...).
  15. Order("sort ASC, my_chart_classify_id ASC").
  16. Find(&list).Error
  17. return
  18. }
  19. func (m *YbMyChartClassify) Fetch(id int) (item *YbMyChartClassify, err error) {
  20. err = global.DEFAULT_MYSQL.Model(m).Where("my_chart_classify_id = ?", id).First(&item).Error
  21. return
  22. }
  23. func (m *YbMyChartClassify) FetchByCondition(condition string, pars []interface{}) (item *YbMyChartClassify, err error) {
  24. err = global.DEFAULT_MYSQL.Model(m).
  25. Where(condition, pars...).
  26. First(&item).Error
  27. return
  28. }
  29. func (m *YbMyChartClassify) Delete() (err error) {
  30. err = global.DEFAULT_MYSQL.Delete(m).Error
  31. return
  32. }