sys_menu.go 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. }
  51. func (m SysMenu) ConvName() string {
  52. name := m.Path
  53. if strings.Contains(m.Path, "/") {
  54. nameList := strings.Split(m.Path, "/")
  55. for _, v := range nameList {
  56. if v != "" {
  57. name = v
  58. break
  59. }
  60. }
  61. }
  62. return utils.FirstUpper(name)
  63. }
  64. func (m SysMenu) ConvMenuTree() MenuTree {
  65. menuTree := MenuTree{
  66. Id: m.Id,
  67. ParentId: m.ParentId,
  68. Name: m.ConvName(),
  69. Path: m.Path,
  70. Component: m.Component,
  71. Meta: Meta{
  72. Title: m.MenuName,
  73. Icon: m.Icon,
  74. //BreadcrumbHidden: m.BreadcrumbHidden,
  75. ActiveMenu: m.ActiveMenu,
  76. NoKeepAlive: m.IsCache != 1,
  77. Hidden: m.Visible != "10",
  78. },
  79. Children: nil,
  80. }
  81. if m.IsFrame == 1 {
  82. menuTree.Meta.Target = "_blank"
  83. }
  84. return menuTree
  85. }