role.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package entity
  2. type RoleResp struct {
  3. Details []*RoleDetail `json:"details"`
  4. Total int64 `json:"total"`
  5. }
  6. type RoleDetail struct {
  7. Id string `gorm:"column:id;primaryKey" json:"id" bson:"_id"`
  8. RenterId uint64 `gorm:"column:renter_id;type:bigint;NOT NULL;comment:租户ID;" json:"renter_id" bson:"renter_id"`
  9. Name string `gorm:"column:name;type:varchar(1024);NOT NULL;comment:角色名称" json:"name" bson:"name"`
  10. PresetId uint64 `gorm:"column:preset_id;comment:预设角色" json:"preset_id" bson:"preset_id"`
  11. Desc string `gorm:"column:desc;comment:描述" json:"desc" bson:"desc"`
  12. Status uint `gorm:"column:status;type:tinyint;default:1;comment:状态,1:正常,2:禁用" json:"status" bson:"status"`
  13. CreatedAt uint64 `gorm:"column:created_at;autoCreateTime" json:"created_at" bson:"created_at"`
  14. DeletedAt uint64 `gorm:"column:deleted_at;" json:"deleted_at" bson:"deleted_at"`
  15. }
  16. type AccessResp struct {
  17. Details []*AccessDetail `json:"details"`
  18. Total int64 `json:"total"`
  19. }
  20. type AccessDetail struct {
  21. ID string `bson:"id" json:"id,omitempty"`
  22. ModuleName string `bson:"module_name" json:"module_name,omitempty"` // 模块名称
  23. ActionName string `bson:"action_name" json:"action_name,omitempty"` // 操作名称
  24. ParentId string `bson:"parent_id" json:"parent_id,omitempty"` // 父级ID
  25. Type int `bson:"type" json:"type,omitempty"` // 节点类型 : 1、表示模块 2、表示菜单 3、操作
  26. URL string `bson:"url" json:"url,omitempty"` // 路由跳转地址
  27. Sort int `bson:"sort" json:"sort,omitempty"` // 排序
  28. Description string `bson:"description" json:"description,omitempty"` // 描述
  29. Status int `bson:"status" json:"status,omitempty"` // 状态 1、正常 2、禁用
  30. AddTime int `bson:"add_time" json:"add_time,omitempty"` // 添加时间-
  31. AccessItem []*AccessDetail `bson:"access_item" json:"access_item"` // 子节点
  32. }
  33. type RoleListReq struct {
  34. Page int `json:"page" binding:"required" form:"page"`
  35. Size int `json:"size" binding:"required" form:"size"`
  36. Count int64 `json:"count" form:"count"`
  37. Name string `json:"name" form:"name"`
  38. Status uint `json:"status" form:"status"`
  39. }
  40. type RoleAddReq struct {
  41. Name string `json:"name" binding:"required" bson:"name"`
  42. Desc string `json:"desc" bson:"desc"`
  43. Status uint `json:"status" bson:"status" binding:"required"`
  44. }
  45. type RoleDelReq struct {
  46. Id string `json:"id" binding:"required" form:"id"`
  47. }
  48. type RoleUpdateReq struct {
  49. Id string `json:"id" binding:"required"`
  50. Name string `json:"name"`
  51. Desc string `json:"desc" bson:"desc"`
  52. Status uint `json:"status" bson:"status"`
  53. }
  54. // RoleAccessListReq 角色权限
  55. type RoleAccessListReq struct {
  56. RoleId string `json:"role_id" form:"role_id"`
  57. }
  58. // RoleAccessAddReq 添加角色权限
  59. type RoleAccessAddReq struct {
  60. RoleId string `json:"role_id"`
  61. AccessId []string `json:"access"`
  62. }
  63. // RoleAccessUpdateReq 修改角色权限
  64. type RoleAccessUpdateReq struct {
  65. RoleId string `json:"role_id"`
  66. AccessId []string `json:"access"`
  67. }
  68. type RoleAccessDelReq struct {
  69. RoleId string `json:"role_id" form:"role_id"`
  70. }
  71. type Response struct {
  72. Code int `json:"code"`
  73. Message string `json:"message"`
  74. Data interface{}
  75. }
  76. type AccessDelReq struct {
  77. Id string `json:"id" form:"id"`
  78. }
  79. // AccessAddReq 添加权限路由
  80. type AccessAddReq struct {
  81. ModuleName string `bson:"module_name" json:"module_name"` // 模块名称
  82. ActionName string `bson:"action_name" json:"action_name"` // 操作名称
  83. ParentId string `bson:"parent_id" json:"parent_id"` // 父级ID 0表示顶级
  84. Type int `bson:"type" json:"type"` // 节点类型 : 1、表示模块 2、表示菜单 3、操作
  85. URL string `bson:"url" json:"url"` // 路由跳转地址
  86. Sort int `bson:"sort" json:"sort"` // 排序
  87. Description string `bson:"description" json:"description"` // 描述
  88. Status int `bson:"status" json:"status"` // 状态 1、正常 2、禁用
  89. }
  90. // AccessUpdateReq 修改权限路由
  91. type AccessUpdateReq struct {
  92. Id string `bson:"_id" json:"id"` // 权限ID
  93. ModuleName string `bson:"module_name" json:"module_name"` // 模块名称
  94. ActionName string `bson:"action_name" json:"action_name"` // 操作名称
  95. ParentId string `bson:"parent_id" json:"parent_id"` // 父级ID 0表示顶级
  96. Type int `bson:"type" json:"type"` // 节点类型 : 1、表示模块 2、表示菜单 3、操作
  97. URL string `bson:"url" json:"url"` // 路由跳转地址
  98. Sort int `bson:"sort" json:"sort"` // 排序
  99. Description string `bson:"description" json:"description"` // 描述
  100. Status int `bson:"status" json:"status"` // 状态 1、正常 2、禁用
  101. }
  102. type AccessListReq struct {
  103. Page int `json:"page" form:"page"`
  104. Size int `json:"size" form:"size"`
  105. Count int64 `json:"count" form:"count"`
  106. ModuleName string `json:"module_name" form:"module_name"`
  107. ActionName string `json:"action_name" form:"action_name"`
  108. ParentId string `json:"parent_id" form:"parent_id"`
  109. Type int `json:"type" form:"type"`
  110. Status int `json:"status" form:"status"`
  111. URL string `bson:"url" json:"url" form:"url"` // 路由跳转地址
  112. }
  113. type AdminBindRoleReq struct {
  114. AdminId string `json:"admin_id" form:"admin_id"`
  115. RoleId string `json:"role_id" form:"role_id"`
  116. }
  117. type AdminRoleByIDReq struct {
  118. AdminId string `json:"admin_id" form:"admin_id"`
  119. }
  120. type AdminBindRoleResp struct {
  121. RoleId string `json:"role_id"` // 角色ID
  122. AdminId string `json:"admin_id"` // 管理员ID
  123. AdminName string `json:"admin_name"` // 管理员名称
  124. RoleName string `json:"role_name"` // 角色名称
  125. AccessList []*AccessDetail `json:"access_list"`
  126. }