classify_menu_relation.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "time"
  6. )
  7. type ClassifyMenuRelation struct {
  8. Id int `gorm:"column:id;primaryKey"` //`orm:"column(id);pk" gorm:"primaryKey" `
  9. MenuId int `gorm:"column:menu_id"` //`description:"子目录ID"`
  10. ClassifyId int `gorm:"column:classify_id"` //`description:"二级分类ID"`
  11. CreateTime time.Time `gorm:"column:create_time"` //`description:"创建时间"`
  12. }
  13. func (item *ClassifyMenuRelation) TableName() string {
  14. return "classify_menu_relation"
  15. }
  16. func (item *ClassifyMenuRelation) Create() (err error) {
  17. err = global.DmSQL["rddp"].Create(item).Error
  18. return
  19. }
  20. func (item *ClassifyMenuRelation) Update(cols []string) (err error) {
  21. err = global.DmSQL["rddp"].Select(cols).Updates(item).Error
  22. return
  23. }
  24. func (item *ClassifyMenuRelation) InsertMulti(items []*ClassifyMenuRelation) (err error) {
  25. err = global.DmSQL["rddp"].CreateInBatches(items, utils.MultiAddNum).Error
  26. return
  27. }
  28. func GetClassifyMenuRelationList(condition string, pars []interface{}) (list []*ClassifyMenuRelation, err error) {
  29. sql := `SELECT * FROM classify_menu_relation WHERE 1 = 1 `
  30. sql += condition
  31. sql += ` ORDER BY create_time DESC`
  32. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&list).Error
  33. return
  34. }