/
user_groups.go
60 lines (49 loc) · 924 Bytes
/
user_groups.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
package messages
import (
"github.com/google/uuid"
)
/*
* UserGroup
*
*/
type UserInGroup struct {
Id string
Name string
Type string
TypeKey string
Key []byte
}
func NewUserInGroup() (*UserInGroup) {
return &UserInGroup{}
}
/*
* UserGroup
*
*/
type UserGroup struct {
Id string
Name string
Type string
Users []*UserInGroup
}
func NewUserGroup() (*UserGroup) {
return &UserGroup{Users: make([]*UserInGroup, 0)}
}
func (t *UserGroup) AddUser(name string, tp string, tpkey string, key []byte) {
tu := NewUserInGroup()
uid, _ := uuid.NewUUID()
tu.Id = uid.String()
tu.Name = name
tu.Type = tp
tu.TypeKey = tpkey
tu.Key = key
t.Users = append(t.Users, tu)
}
/*
* UserGroups
*
*/
type UserGroups []*UserGroup
func NewUserGroups() UserGroups {
return make([]*UserGroup, 0)
}