admin_permission.go
880 字节
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
package domain
//权限代码
const (
PERMINSSION_ADMIN_USER string = "ADMIN_USER"
PERMINSSION_PARTNER string = "PARTNER"
)
//权限数据
var ConstAdminPermissions = map[string]AdminPermission{
PERMINSSION_ADMIN_USER: AdminPermission{
Code: PERMINSSION_ADMIN_USER,
Name: "管理员管理",
},
PERMINSSION_PARTNER: AdminPermission{
Code: PERMINSSION_PARTNER,
Name: "合伙人管理",
},
}
// 权限结构
type AdminPermission struct {
Code string `json:"code"`
Name string `json:"name"`
}
func (permission AdminPermission) GetPermissions(codes []string) []AdminPermission {
newPermissions := []AdminPermission{}
if len(codes) == 0 {
return newPermissions
}
for i := range codes {
code := codes[i]
if _, ok := ConstAdminPermissions[code]; ok {
newPermissions = append(newPermissions, ConstAdminPermissions[code])
}
}
return newPermissions
}