sys_role.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. package dto
  2. import (
  3. "go-admin/app/admin/models"
  4. common "go-admin/common/models"
  5. "go-admin/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:"状态"` // 状态
  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. SysMenu []models.SysMenu `form:"sysMenu"`
  40. MenuIds []int `form:"menuIds"`
  41. SysDept []models.SysDept `form:"sysDept"`
  42. DeptIds []int `form:"deptIds"`
  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.SysMenu = &s.SysMenu
  58. model.SysDept = s.SysDept
  59. }
  60. func (s *SysRoleInsertReq) GetId() interface{} {
  61. return s.RoleId
  62. }
  63. type SysRoleUpdateReq struct {
  64. RoleId int `uri:"id" comment:"角色编码"` // 角色编码
  65. RoleName string `form:"roleName" comment:"角色名称"` // 角色名称
  66. Status string `form:"status" comment:"状态"` // 状态
  67. RoleKey string `form:"roleKey" comment:"角色代码"` // 角色代码
  68. RoleSort int `form:"roleSort" comment:"角色排序"` // 角色排序
  69. Flag string `form:"flag" comment:"标记"` // 标记
  70. Remark string `form:"remark" comment:"备注"` // 备注
  71. Admin bool `form:"admin" comment:"是否管理员"`
  72. DataScope string `form:"dataScope"`
  73. SysMenu []models.SysMenu `form:"sysMenu"`
  74. MenuIds []int `form:"menuIds"`
  75. SysDept []models.SysDept `form:"sysDept"`
  76. DeptIds []int `form:"deptIds"`
  77. common.ControlBy
  78. }
  79. func (s *SysRoleUpdateReq) Generate(model *models.SysRole) {
  80. if s.RoleId != 0 {
  81. model.RoleId = s.RoleId
  82. }
  83. model.RoleName = s.RoleName
  84. model.Status = s.Status
  85. model.RoleKey = s.RoleKey
  86. model.RoleSort = s.RoleSort
  87. model.Flag = s.Flag
  88. model.Remark = s.Remark
  89. model.Admin = s.Admin
  90. model.DataScope = s.DataScope
  91. model.SysMenu = &s.SysMenu
  92. model.SysDept = s.SysDept
  93. }
  94. func (s *SysRoleUpdateReq) GetId() interface{} {
  95. return s.RoleId
  96. }
  97. type UpdateStatusReq struct {
  98. RoleId int `form:"roleId" comment:"角色编码"` // 角色编码
  99. Status string `form:"status" comment:"状态"` // 状态
  100. common.ControlBy
  101. }
  102. func (s *UpdateStatusReq) Generate(model *models.SysRole) {
  103. if s.RoleId != 0 {
  104. model.RoleId = s.RoleId
  105. }
  106. model.Status = s.Status
  107. }
  108. func (s *UpdateStatusReq) GetId() interface{} {
  109. return s.RoleId
  110. }
  111. type SysRoleByName struct {
  112. RoleName string `form:"role"` // 角色编码
  113. }
  114. type SysRoleGetReq struct {
  115. Id int `uri:"id"`
  116. }
  117. func (s *SysRoleGetReq) GetId() interface{} {
  118. return s.Id
  119. }
  120. type SysRoleDeleteReq struct {
  121. Ids []int `json:"ids"`
  122. }
  123. func (s *SysRoleDeleteReq) GetId() interface{} {
  124. return s.Ids
  125. }
  126. // RoleDataScopeReq 角色数据权限修改
  127. type RoleDataScopeReq struct {
  128. RoleId int `json:"roleId" binding:"required"`
  129. DataScope string `json:"dataScope" binding:"required"`
  130. DeptIds []int `json:"deptIds"`
  131. }
  132. func (s *RoleDataScopeReq) Generate(model *models.SysRole) {
  133. if s.RoleId != 0 {
  134. model.RoleId = s.RoleId
  135. }
  136. model.DataScope = s.DataScope
  137. model.DeptIds = s.DeptIds
  138. }
  139. type DeptIdList struct {
  140. DeptId int `json:"DeptId"`
  141. }