classify_menu.go 1.7 KB

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