sys_menu.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package dto
  2. import (
  3. "go-admin/app/admin/models"
  4. common "go-admin/common/models"
  5. "go-admin/common/dto"
  6. )
  7. // SysMenuGetPageReq 列表或者搜索使用结构体
  8. type SysMenuGetPageReq struct {
  9. dto.Pagination `search:"-"`
  10. Title string `form:"title" search:"type:contains;column:title;table:sys_menu" comment:"菜单名称"` // 菜单名称
  11. Visible int `form:"visible" search:"type:exact;column:visible;table:sys_menu" comment:"显示状态"` // 显示状态
  12. }
  13. func (m *SysMenuGetPageReq) GetNeedSearch() interface{} {
  14. return *m
  15. }
  16. type SysMenuInsertReq struct {
  17. MenuId int `uri:"id" comment:"编码"` // 编码
  18. MenuName string `form:"menuName" comment:"菜单name"` //菜单name
  19. Title string `form:"title" comment:"显示名称"` //显示名称
  20. Icon string `form:"icon" comment:"图标"` //图标
  21. Path string `form:"path" comment:"路径"` //路径
  22. Paths string `form:"paths" comment:"id路径"` //id路径
  23. MenuType string `form:"menuType" comment:"菜单类型"` //菜单类型
  24. SysApi []models.SysApi `form:"sysApi"`
  25. Apis []int `form:"apis"`
  26. Action string `form:"action" comment:"请求方式"` //请求方式
  27. Permission string `form:"permission" comment:"权限编码"` //权限编码
  28. ParentId int `form:"parentId" comment:"上级菜单"` //上级菜单
  29. NoCache bool `form:"noCache" comment:"是否缓存"` //是否缓存
  30. Breadcrumb string `form:"breadcrumb" comment:"是否面包屑"` //是否面包屑
  31. Component string `form:"component" comment:"组件"` //组件
  32. Sort int `form:"sort" comment:"排序"` //排序
  33. Visible string `form:"visible" comment:"是否显示"` //是否显示
  34. IsFrame string `form:"isFrame" comment:"是否frame"` //是否frame
  35. common.ControlBy
  36. }
  37. func (s *SysMenuInsertReq) Generate(model *models.SysMenu) {
  38. if s.MenuId != 0 {
  39. model.MenuId = s.MenuId
  40. }
  41. model.MenuName = s.MenuName
  42. model.Title = s.Title
  43. model.Icon = s.Icon
  44. model.Path = s.Path
  45. model.Paths = s.Paths
  46. model.MenuType = s.MenuType
  47. model.Action = s.Action
  48. model.SysApi = s.SysApi
  49. model.Permission = s.Permission
  50. model.ParentId = s.ParentId
  51. model.NoCache = s.NoCache
  52. model.Breadcrumb = s.Breadcrumb
  53. model.Component = s.Component
  54. model.Sort = s.Sort
  55. model.Visible = s.Visible
  56. model.IsFrame = s.IsFrame
  57. if s.CreateBy != 0 {
  58. model.CreateBy = s.CreateBy
  59. }
  60. if s.UpdateBy != 0 {
  61. model.UpdateBy = s.UpdateBy
  62. }
  63. }
  64. func (s *SysMenuInsertReq) GetId() interface{} {
  65. return s.MenuId
  66. }
  67. type SysMenuUpdateReq struct {
  68. MenuId int `uri:"id" comment:"编码"` // 编码
  69. MenuName string `form:"menuName" comment:"菜单name"` //菜单name
  70. Title string `form:"title" comment:"显示名称"` //显示名称
  71. Icon string `form:"icon" comment:"图标"` //图标
  72. Path string `form:"path" comment:"路径"` //路径
  73. Paths string `form:"paths" comment:"id路径"` //id路径
  74. MenuType string `form:"menuType" comment:"菜单类型"` //菜单类型
  75. SysApi []models.SysApi `form:"sysApi"`
  76. Apis []int `form:"apis"`
  77. Action string `form:"action" comment:"请求方式"` //请求方式
  78. Permission string `form:"permission" comment:"权限编码"` //权限编码
  79. ParentId int `form:"parentId" comment:"上级菜单"` //上级菜单
  80. NoCache bool `form:"noCache" comment:"是否缓存"` //是否缓存
  81. Breadcrumb string `form:"breadcrumb" comment:"是否面包屑"` //是否面包屑
  82. Component string `form:"component" comment:"组件"` //组件
  83. Sort int `form:"sort" comment:"排序"` //排序
  84. Visible string `form:"visible" comment:"是否显示"` //是否显示
  85. IsFrame string `form:"isFrame" comment:"是否frame"` //是否frame
  86. common.ControlBy
  87. }
  88. func (s *SysMenuUpdateReq) Generate(model *models.SysMenu) {
  89. if s.MenuId != 0 {
  90. model.MenuId = s.MenuId
  91. }
  92. model.MenuName = s.MenuName
  93. model.Title = s.Title
  94. model.Icon = s.Icon
  95. model.Path = s.Path
  96. model.Paths = s.Paths
  97. model.MenuType = s.MenuType
  98. model.Action = s.Action
  99. model.SysApi = s.SysApi
  100. model.Permission = s.Permission
  101. model.ParentId = s.ParentId
  102. model.NoCache = s.NoCache
  103. model.Breadcrumb = s.Breadcrumb
  104. model.Component = s.Component
  105. model.Sort = s.Sort
  106. model.Visible = s.Visible
  107. model.IsFrame = s.IsFrame
  108. if s.CreateBy != 0 {
  109. model.CreateBy = s.CreateBy
  110. }
  111. if s.UpdateBy != 0 {
  112. model.UpdateBy = s.UpdateBy
  113. }
  114. }
  115. func (s *SysMenuUpdateReq) GetId() interface{} {
  116. return s.MenuId
  117. }
  118. type SysMenuGetReq struct {
  119. Id int `uri:"id"`
  120. }
  121. func (s *SysMenuGetReq) GetId() interface{} {
  122. return s.Id
  123. }
  124. type SysMenuDeleteReq struct {
  125. Ids []int `json:"ids"`
  126. common.ControlBy
  127. }
  128. func (s *SysMenuDeleteReq) GetId() interface{} {
  129. return s.Ids
  130. }
  131. type MenuLabel struct {
  132. Id int `json:"id,omitempty" gorm:"-"`
  133. Label string `json:"label,omitempty" gorm:"-"`
  134. Children []MenuLabel `json:"children,omitempty" gorm:"-"`
  135. }
  136. type MenuRole struct {
  137. models.SysMenu
  138. IsSelect bool `json:"is_select" gorm:"-"`
  139. }
  140. type SelectRole struct {
  141. RoleId int `uri:"roleId"`
  142. }