sys_menu.go 4.7 KB

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