-
Notifications
You must be signed in to change notification settings - Fork 0
/
permission.go
41 lines (35 loc) · 1007 Bytes
/
permission.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
package collections
import (
"github.com/galexrt/fivenet/query/fivenet/model"
)
// Permissions provides methods for you to manage array data more easily.
type Permissions []*model.FivenetPermissions
// Len returns the number of elements of the array.
// @return int64
func (u Permissions) Len() (length int64) {
return int64(len(u))
}
// IDs returns an array of the permission array's ids.
// @return []uint
func (u Permissions) IDs() (IDs []uint64) {
for _, permission := range u {
IDs = append(IDs, permission.ID)
}
return IDs
}
// Names returns an array of the permission array's names.
// @return []string
func (u Permissions) Names() (names []string) {
for _, permission := range u {
names = append(names, permission.Name)
}
return names
}
// GuardNames returns an array of the permission array's guard names.
// @return []string
func (u Permissions) GuardNames() (guards []string) {
for _, permission := range u {
guards = append(guards, permission.GuardName)
}
return guards
}