-
Notifications
You must be signed in to change notification settings - Fork 12
/
user.go
45 lines (37 loc) · 844 Bytes
/
user.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
package rippledemo
// ======================================
// Define some basic model for testing
// ======================================
type UserModel struct {
Id int
Name string
}
type FriendshipModel struct {
UserId1 int
UserId2 int
}
type UserCollection struct {
Users map[int]UserModel
nextUserId int
}
func (this *UserCollection) Add(user UserModel) UserModel {
this.nextUserId++
user.Id = this.nextUserId
this.Users[this.nextUserId] = user
return user
}
func (this *UserCollection) Get(id int) UserModel {
return this.Users[id]
}
func (this *UserCollection) Set(id int, user UserModel) UserModel {
user.Id = id
this.Users[id] = user
return user
}
func (this *UserCollection) GetAll() []UserModel {
var output []UserModel
for _, d := range this.Users {
output = append(output, d)
}
return output
}