refactor: use serial as id instead of uuid
This commit is contained in:
parent
18b033add1
commit
370531a9a5
11 changed files with 319 additions and 381 deletions
|
|
@ -8,11 +8,13 @@ import (
|
|||
type InMemoryTrainingRepository struct {
|
||||
trainings map[TrainingID]Training
|
||||
lock sync.RWMutex
|
||||
ai int
|
||||
}
|
||||
|
||||
func NewInMemoryTrainingRepository() *InMemoryTrainingRepository {
|
||||
return &InMemoryTrainingRepository{
|
||||
trainings: make(map[TrainingID]Training),
|
||||
ai: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +22,8 @@ func (r *InMemoryTrainingRepository) Create(training *Training) error {
|
|||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
|
||||
training.ID = NewTrainingID()
|
||||
training.ID = r.ai
|
||||
r.ai++
|
||||
r.trainings[training.ID] = *training
|
||||
return nil
|
||||
}
|
||||
|
|
@ -73,12 +76,14 @@ type InMemoryTrainingDateRepository struct {
|
|||
trainingToDates map[TrainingID][]TrainingDateID
|
||||
|
||||
lock sync.RWMutex
|
||||
ai int
|
||||
}
|
||||
|
||||
func NewInMemoryTrainingDateRepository() *InMemoryTrainingDateRepository {
|
||||
return &InMemoryTrainingDateRepository{
|
||||
trainingDates: make(map[TrainingDateID]TrainingDate),
|
||||
trainingToDates: make(map[TrainingID][]TrainingDateID),
|
||||
ai: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +91,8 @@ func (r *InMemoryTrainingDateRepository) Create(trainingID TrainingID, trainingD
|
|||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
|
||||
trainingDate.ID = NewTrainingDateID()
|
||||
trainingDate.ID = r.ai
|
||||
r.ai++
|
||||
trainingDate.trainingID = trainingID
|
||||
|
||||
r.trainingDates[trainingDate.ID] = *trainingDate
|
||||
|
|
@ -181,12 +187,14 @@ type InMemoryTrainingDateAttendeeRepository struct {
|
|||
dateToAttendees map[TrainingDateID][]TrainingDateAttendeeID
|
||||
|
||||
lock sync.RWMutex
|
||||
ai int
|
||||
}
|
||||
|
||||
func NewInMemoryTrainingDateAttendeeRepository() *InMemoryTrainingDateAttendeeRepository {
|
||||
return &InMemoryTrainingDateAttendeeRepository{
|
||||
attendees: make(map[TrainingDateAttendeeID]TrainingDateAttendee),
|
||||
dateToAttendees: make(map[TrainingDateID][]TrainingDateAttendeeID),
|
||||
ai: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +202,8 @@ func (r *InMemoryTrainingDateAttendeeRepository) Create(trainingDateID TrainingD
|
|||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
|
||||
attendee.ID = NewTrainingDateAttendeeID()
|
||||
attendee.ID = r.ai
|
||||
r.ai++
|
||||
attendee.trainingDateID = trainingDateID
|
||||
|
||||
r.attendees[attendee.ID] = *attendee
|
||||
|
|
|
|||
Reference in a new issue