-
Notifications
You must be signed in to change notification settings - Fork 0
/
route_rbac.go
165 lines (155 loc) · 5.06 KB
/
route_rbac.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// SPDX-License-Identifier: MIT
package admin
import "github.com/issue9/web"
// <api method="get" summary="获取权限组列表">
//
// <server>admin</server>
// <tag>rbac</tag>
// <tag>admin</tag>
// <path path="/groups" />
// <response status="200" type="object" array="true">
// <param name="id" xml-attr="true" type="number" summary="权限组 ID" />
// <param name="name" type="string" summary="权限组名称" />
// <param name="description" type="string" summary="权限组描信信息" />
// <param name="parent" xml-attr="true" type="number" summary="父类 " />
// </response>
//
// </api>
func (m *Admin) getGroups(ctx *web.Context) web.Responser {
return m.rbac.GetRolesHandle(ctx)
}
// <api method="post" summary="添加一个权限组">
//
// <server>admin</server>
// <tag>rbac</tag>
// <tag>admin</tag>
// <path path="/groups" />
// <request type="object">
// <header name="Authorization" type="string" summary="登录凭证 token" />
// <param name="name" type="string" summary="权限组名称" />
// <param name="description" type="string" summary="权限组描信信息" />
// <param name="parent" type="number" summary="上一级权限组" />
// </request>
// <response status="201" />
//
// </api>
func (m *Admin) postGroups(ctx *web.Context) web.Responser {
return m.rbac.PostRolesHandle(ctx)
}
// <api method="put" summary="修改权限组">
//
// <server>admin</server>
// <tag>rbac</tag>
// <tag>admin</tag>
// <path path="/groups/{id}">
// <param name="id" type="number" summary="权限组 ID" />
// </path>
// <request type="object">
// <header name="Authorization" type="string" summary="登录凭证 token" />
// <param name="name" type="string" summary="权限组名称" />
// <param name="description" type="string" summary="权限组描信信息" />
// </request>
// <response status="204" />
//
// </api>
func (m *Admin) putGroup(ctx *web.Context) web.Responser {
return m.rbac.PutRoleHandle("id", ctx)
}
// <api method="delete" summary="删除权限组">
//
// <server>admin</server>
// <tag>rbac</tag>
// <tag>admin</tag>
// <path path="/groups/{id}">
// <param name="id" type="number" summary="权限组 ID" />
// </path>
// <response status="204" />
//
// </api>
func (m *Admin) deleteGroup(ctx *web.Context) web.Responser {
return m.rbac.DeleteRole("id", ctx)
}
// <api method="GET" summary="获取所有的资源">
//
// <server>admin</server>
// <tag>rbac</tag>
// <tag>admin</tag>
// <path path="/resources" />
// <response status="200" type="object">
// <param name="key" type="string" summary="资源 ID 及与双对应的描述" />
// <example mimetype="application/json"><![CDATA[
// {
// "admin:resources-list":"查看资源列表",
// "admin:resources-list":"查看资源列表"
// }
// ]]></example>
// </response>
//
// </api>
func (m *Admin) getResources(ctx *web.Context) web.Responser {
return m.rbac.GetResourcesHandle(ctx)
}
// <api method="GET" summary="获得权限组可访问的资源列表">
//
// <server>admin</server>
// <tag>rbac</tag>
// <tag>admin</tag>
// <path path="/groups/{id}/resources">
// <param name="id" type="number" summary="权限组 ID" />
// </path>
// <response status="200" type="object">
// <param name="key" type="string" summary="资源 ID 及与双对应的描述" />
// <example mimetype="application/json"><![CDATA[
// {
// "admin:resources-list":"查看资源列表",
// "admin:resources-list":"查看资源列表"
// }
// ]]></example>
// </response>
//
// </api>
func (m *Admin) getGroupResources(ctx *web.Context) web.Responser {
return m.rbac.GetRoleResourcesHandle("id", ctx)
}
// <api method="GET" summary="获得权限组允许访问的资源列表">
//
// <server>admin</server>
// <tag>rbac</tag>
// <tag>admin</tag>
// <path path="/groups/{id}/resources/allowed">
// <param name="id" type="number" summary="权限组 ID" />
// </path>
// <response status="200" type="object">
// <param name="key" type="string" summary="资源 ID 及与双对应的描述" />
// <example mimetype="application/json"><![CDATA[
// {
// "admin:resources-list":"查看资源列表",
// "admin:resources-list":"查看资源列表"
// }
// ]]></example>
// </response>
//
// </api>
func (m *Admin) getGroupAllowedResources(ctx *web.Context) web.Responser {
return m.rbac.GetRoleAllowedResourcesHandle("id", ctx)
}
// <api method="patch" summary="设置权限组的可访问的资源">
//
// <server>admin</server>
// <tag>rbac</tag>
// <tag>admin</tag>
// <path path="/groups/{id}/resources">
// <param name="id" type="number" summary="权限组 ID" />
// </path>
// <request type="string" array="true">
// <param name="key" type="string" summary="资源 ID" />
// <example mimetype="application/json"><![CDATA[
// ["admin:resources-list","admin:resources-list"]
// ]]></example>
// </request>
// <response status="204" />
//
// </api>
func (m *Admin) patchGroupResources(ctx *web.Context) web.Responser {
return m.rbac.PutRoleResourcesHandle("id", ctx)
}