sys_menu.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. package dto
  2. import (
  3. "Medical_OAuth/app/admin/model"
  4. common "Medical_OAuth/common/model"
  5. )
  6. // SysMenuGetPageReq 列表或者搜索使用结构体
  7. type SysMenuGetPageReq struct {
  8. Name string `form:"name" search:"-"` // 菜单名称
  9. Visible int `form:"visible" search:"type:exact;column:visible;table:sys_menu"` // 显示状态
  10. SysMenuOrder
  11. }
  12. type SysMenuOrder struct {
  13. SortOrder string `search:"type:order;column:sort;table:sys_menu" form:"sort" default:"asc"` //排序 ASC 升序 DESC 降序
  14. }
  15. func (m *SysMenuGetPageReq) GetNeedSearch() interface{} {
  16. return *m
  17. }
  18. type SysMenuInsertReq struct {
  19. Id int `uri:"id" comment:"编码" swaggerignore:"true"` // 编码
  20. ParentId int `form:"parentId" example:"0"` //上级菜单
  21. ServiceMenuId int `uri:"id"` //编码
  22. ServiceId int `form:"serviceId" example:"1" vd:"@:$>0; msg:'服务ID不能为空'"` // 服务id
  23. Sort int `form:"sort" example:"0"` //排序
  24. Visible string `form:"visible" example:"1"` //是否显示 1-显示 2-隐藏
  25. common.ControlBy `swaggerignore:"true"`
  26. }
  27. func (s *SysMenuInsertReq) Generate(model *model.SysMenu) {
  28. if s.Id != 0 {
  29. model.Id = s.Id
  30. }
  31. model.ParentId = s.ParentId
  32. model.ServiceMenuId = s.ServiceMenuId
  33. model.ServiceId = s.ServiceId
  34. model.Sort = s.Sort
  35. model.Visible = s.Visible
  36. if s.CreateBy != 0 {
  37. model.CreateBy = s.CreateBy
  38. }
  39. if s.UpdateBy != 0 {
  40. model.UpdateBy = s.UpdateBy
  41. }
  42. }
  43. func (s *SysMenuInsertReq) GetId() interface{} {
  44. return s.Id
  45. }
  46. type SysMenuUpdateReq struct {
  47. Id int `uri:"id" comment:"编码"` // 编码
  48. Sort int `form:"sort" comment:"排序"` //排序
  49. Visible string `form:"visible" comment:"是否显示"` //是否显示
  50. common.ControlBy `swaggerignore:"true"`
  51. }
  52. func (s *SysMenuUpdateReq) Generate(model *model.SysMenu) {
  53. if s.Id != 0 {
  54. model.Id = s.Id
  55. }
  56. model.Sort = s.Sort
  57. model.Visible = s.Visible
  58. if s.CreateBy != 0 {
  59. model.CreateBy = s.CreateBy
  60. }
  61. if s.UpdateBy != 0 {
  62. model.UpdateBy = s.UpdateBy
  63. }
  64. }
  65. func (s *SysMenuUpdateReq) GetId() interface{} {
  66. return s.Id
  67. }
  68. type SysMenuGetReq struct {
  69. Id int `uri:"id"`
  70. }
  71. func (s *SysMenuGetReq) GetId() interface{} {
  72. return s.Id
  73. }
  74. type SysMenuDeleteReq struct {
  75. Ids []int `json:"ids"`
  76. common.ControlBy `swaggerignore:"true"`
  77. }
  78. func (s *SysMenuDeleteReq) GetId() interface{} {
  79. return s.Ids
  80. }
  81. type SysMenu struct {
  82. Id int `json:"id"` //编码
  83. ParentId int `json:"parentId"` // 父id
  84. ServiceMenuId int `json:"serviceMenuId"` //服务菜单ID
  85. ServiceId int `json:"serviceId"` // 服务ID
  86. Sort int `json:"sort"` // 排序
  87. Visible string `json:"visible"` // 1-显示 0-隐藏
  88. MenuPath string `json:"paths"` //
  89. Name string `json:"name"` // 菜单名称
  90. MenuType string `json:"menuType"` // 菜单类型
  91. Icon string `json:"icon"` // 图标
  92. Component string `json:"component"` // 组件路径
  93. IsFrame string `json:"isFrame"` // 是否外链 1-是 2-否
  94. Path string `json:"path"` // 外链路由地址
  95. Permission string `json:"permission"` // 权限标识
  96. common.ControlBy
  97. common.ModelTime
  98. }
  99. func (s SysMenu) Generate() (model model.SysMenu) {
  100. model.Id = s.Id
  101. model.ParentId = s.ParentId
  102. model.ServiceMenuId = s.ServiceMenuId
  103. model.ServiceId = s.ServiceId
  104. model.Sort = s.Sort
  105. model.Visible = s.Visible
  106. model.MenuPath = s.MenuPath
  107. model.Name = s.Name
  108. model.MenuType = s.MenuType
  109. model.Icon = s.Icon
  110. model.Component = s.Component
  111. model.IsFrame = s.IsFrame
  112. model.Path = s.Path
  113. model.Permission = s.Permission
  114. if s.CreateBy != 0 {
  115. model.CreateBy = s.CreateBy
  116. }
  117. if s.UpdateBy != 0 {
  118. model.UpdateBy = s.UpdateBy
  119. }
  120. if !s.CreatedAt.IsZero() {
  121. model.CreatedAt = s.CreatedAt
  122. }
  123. if !s.UpdatedAt.IsZero() {
  124. model.UpdatedAt = s.UpdatedAt
  125. }
  126. return
  127. }
  128. type MenuLabel struct {
  129. Id int `json:"id,omitempty" gorm:"-"`
  130. Label string `json:"label,omitempty" gorm:"-"`
  131. Children []MenuLabel `json:"children,omitempty" gorm:"-"`
  132. }
  133. type MenuRole struct {
  134. model.SysMenu
  135. IsSelect bool `json:"is_select" gorm:"-"`
  136. }
  137. type SelectRole struct {
  138. RoleId int `uri:"roleId"`
  139. }