sys_menu.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. Name string `json:"name"` // 路由名称
  19. Path string `json:"path"` // 路由地址
  20. Component string `json:"component"` // 组件路径
  21. Query string `json:"query"` // 路由参数
  22. IsFrame int `json:"isFrame"` // 是否为外链(10是20否)
  23. IsCache int `json:"isCache"` // 是否缓存(10缓存20不缓存)
  24. MenuType string `json:"menuType" v:"required#菜单类型不能为空"` // 菜单类型(M目录C菜单 F按钮)
  25. Visible string `json:"visible"` // 显示状态(10显示20隐藏)
  26. Status string `json:"status"` // 菜单状态(10正常20停用)
  27. Perms string `json:"perms"` // 权限标识
  28. Icon string `json:"icon"` // 菜单图标
  29. PlatformId int `json:"platformId"` // 所属平台
  30. Sort int `json:"sort"` // 显示顺序
  31. ActiveMenu string `json:"activeMenu"` // 高亮路由
  32. Remark string `json:"remark"` // 备注
  33. }
  34. type MenuTree struct {
  35. Id int `json:"id"`
  36. ParentId int `json:"parent_id"`
  37. Name string `json:"name"`
  38. Path string `json:"path"`
  39. Component string `json:"component"`
  40. Meta Meta `json:"meta"`
  41. Children []MenuTree `json:"children,omitempty"`
  42. }
  43. type Meta struct {
  44. Title string `json:"title"`
  45. Icon string `json:"icon"`
  46. BreadcrumbHidden bool `json:"breadcrumbHidden,omitempty"`
  47. NoKeepAlive bool `json:"noKeepAlive,omitempty"`
  48. Hidden bool `json:"hidden,omitempty"`
  49. ActiveMenu string `json:"activeMenu,omitempty"`
  50. Target string `json:"target,omitempty"`
  51. NoColumn bool `json:"noColumn,omitempty"`
  52. }
  53. func (m SysMenu) ConvName() string {
  54. if m.Name != "" {
  55. return m.Name
  56. }
  57. name := m.Path
  58. if strings.Contains(m.Path, "/") {
  59. nameList := strings.Split(m.Path, "/")
  60. for _, v := range nameList {
  61. if v != "" {
  62. name = v
  63. break
  64. }
  65. }
  66. }
  67. return utils.FirstUpper(name)
  68. }
  69. func (m SysMenu) ConvMenuTree() MenuTree {
  70. menuTree := MenuTree{
  71. Id: m.Id,
  72. ParentId: m.ParentId,
  73. Name: m.ConvName(),
  74. Path: m.Path,
  75. Component: m.Component,
  76. Meta: Meta{
  77. Title: m.MenuName,
  78. Icon: m.Icon,
  79. //BreadcrumbHidden: m.BreadcrumbHidden,
  80. ActiveMenu: m.ActiveMenu,
  81. NoKeepAlive: m.IsCache != 1,
  82. Hidden: m.Visible != "10",
  83. NoColumn: m.NoColumn == "20",
  84. },
  85. Children: nil,
  86. }
  87. if m.IsFrame == 1 {
  88. menuTree.Meta.Target = "_blank"
  89. }
  90. return menuTree
  91. }