classify_menu.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "time"
  6. )
  7. type ClassifyMenu struct {
  8. MenuId int `gorm:"column:menu_id;primaryKey"` // `orm:"column(menu_id);pk" gorm:"primaryKey" `
  9. MenuName string `gorm:"column:mobile"` //`description:"子目录名称"`
  10. ClassifyId int `gorm:"column:classify_id"` //`description:"一级分类ID"`
  11. Sort int `gorm:"column:sort"` //`description:"排序"`
  12. CreateTime time.Time `gorm:"column:create_time"` //`description:"创建时间"`
  13. ModifyTime time.Time `gorm:"column:modify_time"` //`description:"更新时间"`
  14. }
  15. func (item *ClassifyMenu) TableName() string {
  16. return "classify_menu"
  17. }
  18. func (item *ClassifyMenu) Create() (err error) {
  19. err = global.DmSQL["rddp"].Create(item).Error
  20. return
  21. }
  22. func (item *ClassifyMenu) Update(cols []string) (err error) {
  23. err = global.DmSQL["rddp"].Select(cols).Updates(item).Error
  24. return
  25. }
  26. func (item *ClassifyMenu) InsertMulti(items []*ClassifyMenu) (err error) {
  27. err = global.DmSQL["rddp"].CreateInBatches(items, utils.MultiAddNum).Error
  28. return
  29. }
  30. func GetClassifyMenuList(condition string, pars []interface{}) (list []*ClassifyMenu, err error) {
  31. sql := `SELECT * FROM classify_menu WHERE 1 = 1 `
  32. sql += condition
  33. sql += ` ORDER BY sort ASC, create_time ASC`
  34. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&list).Error
  35. return
  36. }
  37. type ClassifyMenuSaveReq struct {
  38. MenuId int `description:"子目录ID, 0为新增, 大于0为编辑"`
  39. MenuName string `description:"子目录名称"`
  40. }