sys_role.go 5.8 KB

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