sys_menu.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package dto
  2. import (
  3. "cold-delivery/app/admin/model"
  4. "cold-delivery/common/dto"
  5. common "cold-delivery/common/model"
  6. )
  7. // SysMenuGetPageReq 列表或者搜索使用结构体
  8. type SysMenuGetPageReq struct {
  9. dto.Pagination `search:"-"`
  10. Name string `form:"name" search:"type:contains;column:name;table:sys_menu"` // 菜单名称
  11. Visible int `form:"visible" search:"type:exact;column:visible;table:sys_menu"` // 显示状态
  12. SysMenuOrder
  13. }
  14. type SysMenuOrder struct {
  15. SortOrder string `search:"type:order;column:sort;table:sys_menu" form:"sort" default:"ASC"` //排序 ASC 升序 DESC 降序
  16. }
  17. func (m *SysMenuGetPageReq) GetNeedSearch() interface{} {
  18. return *m
  19. }
  20. type SysMenuInsertReq struct {
  21. Id int `json:"id" swaggerignore:"true"` //编码
  22. Title string `json:"title" example:"菜单名称"` //菜单名称
  23. Name string `json:"name" example:"admin"` //路由名称
  24. Icon string `json:"icon" example:"app-group-fill"` //图标
  25. Path string `json:"path" example:"/admin" swaggerignore:"true"` //后端路由地址
  26. MenuPath string `json:"paths" swaggerignore:"true"` //id路径
  27. MenuType string `json:"menuType" example:"C"` //菜单类型 M-目录 C-菜单 F-按钮
  28. Permission string `json:"permission" example:"admin:sysUser:list" swaggerignore:"true"` //权限编码
  29. ParentId int `json:"parentId" example:"0"` //上级菜单
  30. Component string `json:"component" example:"/admin/sys-user/index"` //组件名称
  31. Sort int `json:"sort" example:"0"` //排序
  32. Visible string `json:"visible" example:"1"` //是否显示 1-显示 2-隐藏
  33. IsFrame string `json:"isFrame" example:"0" swaggerignore:"true"` //是否frame 1-是 2-否
  34. common.ControlBy `swaggerignore:"true"`
  35. }
  36. func (s *SysMenuInsertReq) Generate(model *model.SysMenu) {
  37. if s.Id != 0 {
  38. model.Id = s.Id
  39. }
  40. model.Title = s.Title
  41. model.Icon = s.Icon
  42. model.Path = s.Path
  43. model.MenuPath = s.MenuPath
  44. model.MenuType = s.MenuType
  45. model.Name = s.Name
  46. model.ParentId = s.ParentId
  47. model.Component = s.Component
  48. model.Sort = s.Sort
  49. model.Visible = s.Visible
  50. model.IsFrame = s.IsFrame
  51. if s.CreateBy != 0 {
  52. model.CreateBy = s.CreateBy
  53. }
  54. if s.UpdateBy != 0 {
  55. model.UpdateBy = s.UpdateBy
  56. }
  57. }
  58. func (s *SysMenuInsertReq) GetId() interface{} {
  59. return s.Id
  60. }
  61. type SysMenuUpdateReq struct {
  62. Id int `json:"id" comment:"编码"` // 编码
  63. Title string `json:"title" example:"菜单名称"` //菜单名称
  64. Name string `json:"name" example:"admin"` // 路由名称
  65. Icon string `json:"icon" example:"app-group-fill"` //图标
  66. Path string `json:"path" example:"/admin" swaggerignore:"true"` //后端路由地址
  67. MenuPath string `json:"paths" swaggerignore:"true"` //id路径
  68. MenuType string `json:"menuType" example:"C"` //菜单类型 M-目录 C-菜单 F-按钮
  69. Permission string `json:"permission" example:"admin:sysUser:list"` //权限编码
  70. ParentId int `json:"parentId" example:"0"` //上级菜单
  71. Component string `json:"component" example:"admin"` //组件名称
  72. Sort int `json:"sort" example:"0"` //排序
  73. Visible string `json:"visible" example:"1"` //是否显示 1-显示 2-隐藏
  74. IsFrame string `json:"isFrame" example:"0" swaggerignore:"true"` //是否frame 1-是 2-否
  75. common.ControlBy `swaggerignore:"true"`
  76. }
  77. func (s *SysMenuUpdateReq) Generate(model *model.SysMenu) {
  78. if s.Id != 0 {
  79. model.Id = s.Id
  80. }
  81. model.Title = s.Title
  82. model.Icon = s.Icon
  83. model.Path = s.Path
  84. model.MenuPath = s.MenuPath
  85. model.MenuType = s.MenuType
  86. model.Name = s.Name
  87. model.ParentId = s.ParentId
  88. model.Component = s.Component
  89. model.Sort = s.Sort
  90. model.Visible = s.Visible
  91. model.IsFrame = s.IsFrame
  92. if s.CreateBy != 0 {
  93. model.CreateBy = s.CreateBy
  94. }
  95. if s.UpdateBy != 0 {
  96. model.UpdateBy = s.UpdateBy
  97. }
  98. }
  99. func (s *SysMenuUpdateReq) GetId() interface{} {
  100. return s.Id
  101. }
  102. type SysMenuGetReq struct {
  103. Id int `uri:"id"`
  104. }
  105. func (s *SysMenuGetReq) GetId() interface{} {
  106. return s.Id
  107. }
  108. type SysMenuDeleteReq struct {
  109. Id int `json:"id"`
  110. common.ControlBy `swaggerignore:"true"`
  111. }
  112. func (s *SysMenuDeleteReq) GetId() interface{} {
  113. return s.Id
  114. }
  115. type MenuLabel struct {
  116. Id int `json:"id,omitempty" gorm:"-"`
  117. Label string `json:"label,omitempty" gorm:"-"`
  118. Children []MenuLabel `json:"children,omitempty" gorm:"-"`
  119. }