-
Notifications
You must be signed in to change notification settings - Fork 0
/
team.go
39 lines (34 loc) · 954 Bytes
/
team.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
package entities
import "time"
type (
Team struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
EventID string `json:"eventId"`
Event Event `json:"event"`
Trainees []Trainee `json:"trainees"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
TeamRepo interface {
Create(team *Team) (*Team, map[string]string)
List(event string) (*[]Team, error)
Get(id string) (*Team, error)
Update(team *Team) (string, error)
GetByName(event, name string) (*Team, error)
}
)
func (r *Team) Validate() map[string]string {
var errMessages = make(map[string]string)
if r.Name == "" {
errMessages["name"] = "team name is required"
}
if r.Description == "" {
errMessages["description"] = "description is required"
}
if r.EventID == "" {
errMessages["event"] = "event is required"
}
return errMessages
}