sys_role.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package dto
  2. import (
  3. "IotAdmin/app/system/models"
  4. common "IotAdmin/common/models"
  5. "IotAdmin/common/dto"
  6. )
  7. type SysRoleGetPageReq struct {
  8. dto.Pagination `search:"-"`
  9. RoleId int `form:"roleId" search:"type:exact;column:role_id;table:sys_role" comment:"角色编码"` // 角色编码
  10. RoleName string `form:"roleName" search:"type:exact;column:role_name;table:sys_role" comment:"角色名称"` // 角色名称
  11. Status string `form:"status" search:"type:exact;column:status;table:sys_role" comment:"状态"` // 状态
  12. RoleKey string `form:"roleKey" search:"type:exact;column:role_key;table:sys_role" comment:"角色代码"` // 角色代码
  13. RoleSort int `form:"roleSort" search:"type:exact;column:role_sort;table:sys_role" comment:"角色排序"` // 角色排序
  14. Flag string `form:"flag" search:"type:exact;column:flag;table:sys_role" comment:"标记"` // 标记
  15. Remark string `form:"remark" search:"type:exact;column:remark;table:sys_role" comment:"备注"` // 备注
  16. Admin bool `form:"admin" search:"type:exact;column:admin;table:sys_role" comment:"是否管理员"`
  17. DataScope string `form:"dataScope" search:"type:exact;column:data_scope;table:sys_role" comment:"是否管理员"`
  18. }
  19. type SysRoleOrder struct {
  20. RoleIdOrder string `search:"type:order;column:role_id;table:sys_role" form:"roleIdOrder"`
  21. RoleNameOrder string `search:"type:order;column:role_name;table:sys_role" form:"roleNameOrder"`
  22. RoleSortOrder string `search:"type:order;column:role_sort;table:sys_role" form:"usernameOrder"`
  23. StatusOrder string `search:"type:order;column:status;table:sys_role" form:"statusOrder"`
  24. CreatedAtOrder string `search:"type:order;column:created_at;table:sys_role" form:"createdAtOrder"`
  25. }
  26. func (m *SysRoleGetPageReq) GetNeedSearch() interface{} {
  27. return *m
  28. }
  29. type SysRoleInsertReq struct {
  30. RoleId int `uri:"id" comment:"角色编码"` // 角色编码
  31. RoleName string `form:"roleName" comment:"角色名称"` // 角色名称
  32. Status string `form:"status" comment:"状态"` // 状态 1禁用 2正常
  33. RoleKey string `form:"roleKey" comment:"角色代码"` // 角色代码
  34. RoleSort int `form:"roleSort" comment:"角色排序"` // 角色排序
  35. Flag string `form:"flag" comment:"标记"` // 标记
  36. Remark string `form:"remark" comment:"备注"` // 备注
  37. Admin bool `form:"admin" comment:"是否管理员"`
  38. DataScope string `form:"dataScope"`
  39. Menus []models.SysMenu `form:"menus"`
  40. MenuIds []int `form:"menuIds"`
  41. Orgs []models.SysOrg `form:"orgs"`
  42. OrgIds []int `form:"orgIds"`
  43. common.ControlBy
  44. }
  45. func (s *SysRoleInsertReq) Generate(model *models.SysRole) {
  46. if s.RoleId != 0 {
  47. model.RoleId = s.RoleId
  48. }
  49. model.RoleName = s.RoleName
  50. model.Status = s.Status
  51. model.RoleKey = s.RoleKey
  52. model.RoleSort = s.RoleSort
  53. model.Flag = s.Flag
  54. model.Remark = s.Remark
  55. model.Admin = s.Admin
  56. model.DataScope = s.DataScope
  57. model.Menus = &s.Menus
  58. model.Orgs = &s.Orgs
  59. model.CreateBy = s.CreateBy
  60. }
  61. func (s *SysRoleInsertReq) GetId() interface{} {
  62. return s.RoleId
  63. }
  64. type SysRoleUpdateReq struct {
  65. RoleId int `uri:"id" comment:"角色编码"` // 角色编码
  66. RoleName string `form:"roleName" comment:"角色名称"` // 角色名称
  67. Status string `form:"status" comment:"状态"` // 状态
  68. RoleKey string `form:"roleKey" comment:"角色代码"` // 角色代码
  69. RoleSort int `form:"roleSort" comment:"角色排序"` // 角色排序
  70. Flag string `form:"flag" comment:"标记"` // 标记
  71. Remark string `form:"remark" comment:"备注"` // 备注
  72. Admin bool `form:"admin" comment:"是否管理员"`
  73. DataScope string `form:"dataScope"`
  74. Menus []models.SysMenu `form:"menus"`
  75. MenuIds []int `form:"menuIds"`
  76. Orgs []models.SysOrg `form:"orgs"`
  77. OrgIds []int `form:"orgIds"`
  78. common.ControlBy
  79. }
  80. func (s *SysRoleUpdateReq) Generate(model *models.SysRole) {
  81. if s.RoleId != 0 {
  82. model.RoleId = s.RoleId
  83. }
  84. model.RoleName = s.RoleName
  85. model.Status = s.Status
  86. model.RoleKey = s.RoleKey
  87. model.RoleSort = s.RoleSort
  88. model.Flag = s.Flag
  89. model.Remark = s.Remark
  90. model.Admin = s.Admin
  91. model.DataScope = s.DataScope
  92. model.Menus = &s.Menus
  93. model.Orgs = &s.Orgs
  94. model.UpdateBy = s.UpdateBy
  95. }
  96. func (s *SysRoleUpdateReq) GetId() interface{} {
  97. return s.RoleId
  98. }
  99. type UpdateStatusReq struct {
  100. RoleId int `form:"roleId" comment:"角色编码"` // 角色编码
  101. Status string `form:"status" comment:"状态"` // 状态
  102. common.ControlBy
  103. }
  104. func (s *UpdateStatusReq) Generate(model *models.SysRole) {
  105. if s.RoleId != 0 {
  106. model.RoleId = s.RoleId
  107. }
  108. model.Status = s.Status
  109. }
  110. func (s *UpdateStatusReq) GetId() interface{} {
  111. return s.RoleId
  112. }
  113. type SysRoleByName struct {
  114. RoleName string `form:"role"` // 角色编码
  115. }
  116. type SysRoleGetReq struct {
  117. Id int `uri:"id"`
  118. }
  119. func (s *SysRoleGetReq) GetId() interface{} {
  120. return s.Id
  121. }
  122. type SysRoleDeleteReq struct {
  123. Ids []int `json:"ids"`
  124. }
  125. func (s *SysRoleDeleteReq) GetId() interface{} {
  126. return s.Ids
  127. }
  128. // RoleDataScopeReq 角色数据权限修改
  129. type RoleDataScopeReq struct {
  130. RoleId int `json:"roleId" binding:"required"`
  131. DataScope string `json:"dataScope" binding:"required"`
  132. OrgIds []int `json:"orgIds"`
  133. }
  134. func (s *RoleDataScopeReq) Generate(model *models.SysRole) {
  135. if s.RoleId != 0 {
  136. model.RoleId = s.RoleId
  137. }
  138. model.DataScope = s.DataScope
  139. model.OrgIds = s.OrgIds
  140. }
  141. type OrgIdList struct {
  142. OrgId int `json:"OrgId"`
  143. }