-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
146 lines (127 loc) · 3.62 KB
/
model.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
package main
import (
"time"
"github.com/satori/go.uuid"
)
type ResourceInfo struct {
Type string
Collection string
}
type IEntity interface {
GetID() string
Created(by string)
Updated(by string)
GetResourceInfo() ResourceInfo
}
type Entity struct {
ID string `json:"id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"update_at"`
CreatedBy string `json:"created_by,omitempty"`
UpdatedBy string `json:"updated_by,omitempty"`
}
func (e *Entity) GetID() string {
return e.ID
}
func (e *Entity) Created(by string) {
e.ID = uuid.NewV4().String()
e.CreatedAt = time.Now().UTC()
e.CreatedBy = by
}
func (e *Entity) Updated(by string) {
e.UpdatedAt = time.Now().UTC()
e.UpdatedBy = by
}
type User struct {
Entity
TeamID string `json:"team_id,omitempty"`
Name string `json:"name"`
Email string `json:"email"`
Login string `json:"login"`
Description string `json:"description,omitempty"`
Comment string `json:"comment,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
GravatarID string `json:"gravatar_id,omitempty"`
Course int `json:"course"`
Faculty string `json:"faculty,omitempty"`
Group int `json:"group,omitempty"`
Role string `json:"role,omitempty"` // student, mentor
Github string `json:"github,omitempty"`
Skype string `json:"skype,omitempty"`
Twitter string `json:"twitter,omitempty"`
Telegram string `json:"telegram,omitempty"`
WebURL string `json:"web_url,omitempty"` // url to user website
Location string `json:"location,omitempty"`
}
func (u *User) GetResourceInfo() ResourceInfo {
return ResourceInfo{
Type: "user",
Collection: "users",
}
}
type Team struct {
Entity
OrganizationID string `json:"organization_id,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Slug string `json:"slug,omitempty"`
Github string `json:"github,omitempty"` // github URL
Telegram string `json:"telegram,omitempty"` // team chat
Members []string `json:"members,omitempty"` // member ids
}
func (t *Team) GetResourceInfo() ResourceInfo {
return ResourceInfo{
Type: "team",
Collection: "teams",
}
}
type Organization struct {
Entity
Name string `json:"name"`
Description string `json:"description,omitempty"`
Slug string `json:"slug,omitempty"`
Github string `json:"github,omitempty"` // organization github URL
Teams []string `json:"teams,omitempty"` // team ids
}
func (o *Organization) GetResourceInfo() ResourceInfo {
return ResourceInfo{
Type: "org",
Collection: "orgs",
}
}
const (
EventStatus = "status"
EventPresence = "presence"
)
type Event struct {
Entity
UserID string `json:"user_id"`
Type string `json:"type"`
Message string `json:"message"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
// allow to track just time spent in hours
Duration int `json:"duration"`
SpectacleID string `json:"spectacle_id,omitempty"`
}
func (e *Event) GetResourceInfo() ResourceInfo {
return ResourceInfo{
Type: "event",
Collection: "events",
}
}
type Spectacle struct {
Entity
Type string `json:"type"`
Title string `json:"title"`
Start time.Time `json:"start"`
Duration int `json:"duration"` // in hours
PresenterID string `json:"presenter_id"`
PresenterName string `json:"presenter_name"`
}
func (s *Spectacle) GetResourceInfo() ResourceInfo {
return ResourceInfo{
Type: "spectacle",
Collection: "spectacles",
}
}