authority.api 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. syntax = "v1"
  2. info(
  3. title: "authority control"
  4. desc: "authority control including authority management, role access control"
  5. author: "Ryan Su"
  6. email: "yuansu.china.work@gmail.com"
  7. version: "v1.0"
  8. )
  9. import "../base.api"
  10. type (
  11. // The response data of api authorization | API授权数据
  12. ApiAuthorityInfo {
  13. // API path | API 路径
  14. Path string `json:"path" validate="required,max=80"`
  15. // API method | API请求方法
  16. Method string `json:"method" validate="required,min=3,max=4"`
  17. }
  18. // Create or update api authorization information request | 创建或更新API授权信息
  19. CreateOrUpdateApiAuthorityReq {
  20. // Role ID | 角色ID
  21. RoleId uint64 `json:"roleId" validate:"required,lt=1000"`
  22. // API authorization list | API授权列表数据
  23. // Required: true
  24. Data []ApiAuthorityInfo `json:"data"`
  25. }
  26. // The response data of api authorization list | API授权列表返回数据
  27. ApiAuthorityListResp {
  28. BaseDataInfo
  29. // The api authorization list data | API授权列表数据
  30. Data ApiAuthorityListInfo `json:"data"`
  31. }
  32. // The data of api authorization list | API授权列表数据
  33. ApiAuthorityListInfo {
  34. BaseListInfo
  35. // The api authorization list data | API授权列表数据
  36. Data []ApiAuthorityInfo `json:"data"`
  37. }
  38. // Create or update menu authorization information request params | 创建或更新菜单授权信息参数
  39. MenuAuthorityInfoReq {
  40. // role ID | 角色ID
  41. RoleId uint64 `json:"roleId" validate:"required,lt=1000"`
  42. // menu ID array | 菜单ID数组
  43. MenuIds []uint64 `json:"menuIds" validate:"required"`
  44. }
  45. // Menu authorization response data | 菜单授权信息数据
  46. MenuAuthorityInfoResp {
  47. BaseDataInfo
  48. // The menu authorization data | 菜单授权信息数据
  49. Data MenuAuthorityInfoReq `json:"data"`
  50. }
  51. )
  52. @server(
  53. jwt: Auth
  54. group: authority
  55. middleware: Authority
  56. )
  57. service Core {
  58. // Create or update API authorization information | 创建或更新API权限
  59. @handler createOrUpdateApiAuthority
  60. post /authority/api/create_or_update (CreateOrUpdateApiAuthorityReq) returns (BaseMsgResp)
  61. // Get role's API authorization list | 获取角色api权限列表
  62. @handler getApiAuthority
  63. post /authority/api/role (IDReq) returns (ApiAuthorityListResp)
  64. // Create or update menu authorization information | 创建或更新菜单权限
  65. @handler createOrUpdateMenuAuthority
  66. post /authority/menu/create_or_update (MenuAuthorityInfoReq) returns (BaseMsgResp)
  67. // Get role's menu authorization list | 获取角色菜单权限列表
  68. @handler getMenuAuthority
  69. post /authority/menu/role (IDReq) returns (MenuAuthorityInfoResp)
  70. }