-
Notifications
You must be signed in to change notification settings - Fork 1
/
employee.go
46 lines (37 loc) · 870 Bytes
/
employee.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
package employee
import "time"
type Company struct {
employees map[string]Employee
uuidGenerator func() string
}
func (c Company) ListEmployees() []Employee {
output := []Employee{}
for _, employee := range c.employees {
output = append(output, employee)
}
return output
}
func NewCompany(uuidGenerator func() string) Company {
return Company{map[string]Employee{}, uuidGenerator}
}
func (c *Company) Enroll(employee Employee) Employee {
employee.id = c.uuidGenerator()
c.employees[employee.id] = employee
return employee
}
func (c *Company) Dissmiss(uuid string) {
delete(c.employees, uuid)
}
func (c Company) ShowEmployee(uuid string) Employee {
return c.employees[uuid]
}
func (e Employee) Id() string {
return e.id
}
type Employee struct {
FirstName string
LastName string
Birthday time.Time
EntryDate time.Time
id string
}