sys_menu.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package eta
  2. import (
  3. "hongze/hz_crm_eta/global"
  4. "strings"
  5. "time"
  6. )
  7. type SysMenu struct {
  8. MenuId int32 `gorm:"column:menu_id;primary_key;AUTO_INCREMENT;NOT NULL"`
  9. ParentId int32 `gorm:"column:parent_id;default:0;comment:'父级菜单ID\n'"`
  10. Name string `gorm:"column:name;default:;comment:'菜单名称或者按钮名称'"`
  11. Sort int8 `gorm:"column:sort;default:0;comment:'排序\n'"`
  12. Path string `gorm:"column:path;default:;comment:'路径'"`
  13. IconPath string `gorm:"column:icon_path;default:;comment:'菜单图标地址\n'"`
  14. Component string `gorm:"column:component;default:;comment:'组件路径\n'"`
  15. Hidden int8 `gorm:"column:hidden;default:0;comment:'是否隐藏:1-隐藏 0-显示\n'"`
  16. IsLevel int8 `gorm:"column:is_level;default:0;NOT NULL;comment:'1,只有一级;2,有多级'"`
  17. LevelPath string `gorm:"column:level_path;default:"`
  18. MenuType int8 `gorm:"column:menu_type;default:0;NOT NULL;comment:'菜单类型: 0-菜单; 1-按钮; 2-字段(需要特殊处理)'"`
  19. ButtonCode string `gorm:"column:button_code;default:;NOT NULL;comment:'按钮唯一编码'"`
  20. CreateTime time.Time `gorm:"column:create_time;default:NULL;comment:'创建时间'"`
  21. ModifyTime time.Time `gorm:"column:modify_time;default:NULL;comment:'更新时间'"`
  22. Api string `gorm:"column:api;NOT NULL;comment:'按钮相关api'"`
  23. NameEn string `gorm:"column:name_en;default:;comment:'菜单名称或者按钮名称(英文)'"`
  24. }
  25. func (s *SysMenu) TableName() string {
  26. return "sys_menu"
  27. }
  28. const (
  29. MenuSpecialHandleClassifyChildMenu = "classifyList:cnClassify:childMenu"
  30. MenuSpecialHandleClassifyShowType = "classifyList:cnClassify:showType"
  31. MenuSpecialHandleClassifyReportImgs = "classifyList:cnClassify:reportImgs"
  32. MenuSpecialHandleSandboxVariety = "sandbox:variety"
  33. )
  34. // GetSysMenuItemsByCondition 获取菜单列表
  35. func (s *SysMenu) GetSysMenuItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*SysMenu, err error) {
  36. fields := strings.Join(fieldArr, ",")
  37. if len(fieldArr) == 0 {
  38. fields = `*`
  39. }
  40. order := ` create_time DESC`
  41. if orderRule != "" {
  42. order = orderRule
  43. }
  44. err = global.MYSQL["hz_eta"].Model(s).Select(fields).Where(condition, pars...).Order(order).Scan(&items).Error
  45. return
  46. }