sys_menu.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // ==========================================================================
  2. // This is auto-generated by gf cli tool. Fill this file as you wish.
  3. // ==========================================================================
  4. package model
  5. import (
  6. "dashoo.cn/micro/app/model/internal"
  7. "dashoo.cn/opms_libary/utils"
  8. "strings"
  9. )
  10. // SysMenu is the golang structure for table sys_menu.
  11. type SysMenu internal.SysMenu
  12. // Fill with you ideas below.
  13. // SysMenuReq 新增页面请求参数
  14. type SysMenuReq struct {
  15. Id int `json:"id"` // ID
  16. ParentId int `json:"parentId"` // 父菜单ID
  17. MenuName string `json:"menuName" v:"required#菜单名称不能为空"` // 菜单名称
  18. Path string `json:"path"` // 路由地址
  19. Component string `json:"component"` // 组件路径
  20. Query string `json:"query"` // 路由参数
  21. IsFrame int `json:"isFrame"` // 是否为外链(10是20否)
  22. IsCache int `json:"isCache"` // 是否缓存(10缓存20不缓存)
  23. MenuType string `json:"menuType" v:"required#菜单类型不能为空"` // 菜单类型(M目录C菜单 F按钮)
  24. Visible string `json:"visible"` // 显示状态(10显示20隐藏)
  25. Status string `json:"status"` // 菜单状态(10正常20停用)
  26. Perms string `json:"perms"` // 权限标识
  27. Icon string `json:"icon"` // 菜单图标
  28. PlatformId int `json:"platformId"` // 所属平台
  29. Sort int `json:"sort"` // 显示顺序
  30. ActiveMenu string `json:"activeMenu"` // 高亮路由
  31. Remark string `json:"remark"` // 备注
  32. }
  33. type MenuTree struct {
  34. Id int `json:"id"`
  35. ParentId int `json:"parent_id"`
  36. Name string `json:"name"`
  37. Path string `json:"path"`
  38. Component string `json:"component"`
  39. Meta Meta `json:"meta"`
  40. Children []MenuTree `json:"children,omitempty"`
  41. }
  42. type Meta struct {
  43. Title string `json:"title"`
  44. Icon string `json:"icon"`
  45. BreadcrumbHidden bool `json:"breadcrumbHidden,omitempty"`
  46. NoKeepAlive bool `json:"noKeepAlive,omitempty"`
  47. Hidden bool `json:"hidden,omitempty"`
  48. ActiveMenu string `json:"activeMenu,omitempty"`
  49. Target string `json:"target,omitempty"`
  50. NoColumn bool `json:"noColumn,omitempty"`
  51. }
  52. func (m SysMenu) ConvName() string {
  53. name := m.Path
  54. if strings.Contains(m.Path, "/") {
  55. nameList := strings.Split(m.Path, "/")
  56. for _, v := range nameList {
  57. if v != "" {
  58. name = v
  59. break
  60. }
  61. }
  62. }
  63. return utils.FirstUpper(name)
  64. }
  65. func (m SysMenu) ConvMenuTree() MenuTree {
  66. menuTree := MenuTree{
  67. Id: m.Id,
  68. ParentId: m.ParentId,
  69. Name: m.ConvName(),
  70. Path: m.Path,
  71. Component: m.Component,
  72. Meta: Meta{
  73. Title: m.MenuName,
  74. Icon: m.Icon,
  75. //BreadcrumbHidden: m.BreadcrumbHidden,
  76. ActiveMenu: m.ActiveMenu,
  77. NoKeepAlive: m.IsCache != 1,
  78. Hidden: m.Visible != "10",
  79. NoColumn: m.NoColumn == "20",
  80. },
  81. Children: nil,
  82. }
  83. if m.IsFrame == 1 {
  84. menuTree.Meta.Target = "_blank"
  85. }
  86. return menuTree
  87. }