1
0
Fork 0

refactor(training): use golang style of naming (do not repeat pacakge name in struct/func names)

This commit is contained in:
Vojtěch Mareš 2024-06-23 13:13:44 +02:00
parent e0f401f0a9
commit c3795dba6a
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
12 changed files with 232 additions and 232 deletions

View file

@ -6,14 +6,14 @@ import (
)
type InMemoryTrainingRepository struct {
trainings map[TrainingID]Training
trainings map[ID]Training
lock sync.RWMutex
ai int
}
func NewInMemoryTrainingRepository() *InMemoryTrainingRepository {
return &InMemoryTrainingRepository{
trainings: make(map[TrainingID]Training),
trainings: make(map[ID]Training),
ai: 1,
}
}
@ -28,7 +28,7 @@ func (r *InMemoryTrainingRepository) Create(training *Training) error {
return nil
}
func (r *InMemoryTrainingRepository) FindByID(id TrainingID) (*Training, error) {
func (r *InMemoryTrainingRepository) FindByID(id ID) (*Training, error) {
r.lock.RLock()
defer r.lock.RUnlock()
@ -58,7 +58,7 @@ func (r *InMemoryTrainingRepository) Update(training *Training) error {
return nil
}
func (r *InMemoryTrainingRepository) Delete(id TrainingID) error {
func (r *InMemoryTrainingRepository) Delete(id ID) error {
r.lock.Lock()
defer r.lock.Unlock()
@ -71,23 +71,23 @@ func (r *InMemoryTrainingRepository) Delete(id TrainingID) error {
return nil
}
type InMemoryTrainingDateRepository struct {
trainingDates map[TrainingDateID]TrainingDate
trainingToDates map[TrainingID][]TrainingDateID
type InMemoryDateRepository struct {
trainingDates map[DateID]Date
trainingToDates map[ID][]DateID
lock sync.RWMutex
ai int
}
func NewInMemoryTrainingDateRepository() *InMemoryTrainingDateRepository {
return &InMemoryTrainingDateRepository{
trainingDates: make(map[TrainingDateID]TrainingDate),
trainingToDates: make(map[TrainingID][]TrainingDateID),
func NewInMemoryDateRepository() *InMemoryDateRepository {
return &InMemoryDateRepository{
trainingDates: make(map[DateID]Date),
trainingToDates: make(map[ID][]DateID),
ai: 1,
}
}
func (r *InMemoryTrainingDateRepository) Create(trainingID TrainingID, trainingDate *TrainingDate) error {
func (r *InMemoryDateRepository) Create(trainingID ID, trainingDate *Date) error {
r.lock.Lock()
defer r.lock.Unlock()
@ -100,7 +100,7 @@ func (r *InMemoryTrainingDateRepository) Create(trainingID TrainingID, trainingD
return nil
}
func (r *InMemoryTrainingDateRepository) FindByID(id TrainingDateID) (*TrainingDate, error) {
func (r *InMemoryDateRepository) FindByID(id DateID) (*Date, error) {
r.lock.RLock()
defer r.lock.RUnlock()
@ -111,11 +111,11 @@ func (r *InMemoryTrainingDateRepository) FindByID(id TrainingDateID) (*TrainingD
return &date, nil
}
func (r *InMemoryTrainingDateRepository) FindAll() ([]TrainingDate, error) {
func (r *InMemoryDateRepository) FindAll() ([]Date, error) {
r.lock.RLock()
defer r.lock.RUnlock()
dates := make([]TrainingDate, len(r.trainingDates))
dates := make([]Date, len(r.trainingDates))
for _, date := range r.trainingDates {
dates = append(dates, date)
}
@ -123,11 +123,11 @@ func (r *InMemoryTrainingDateRepository) FindAll() ([]TrainingDate, error) {
return dates, nil
}
func (r *InMemoryTrainingDateRepository) FindAllByTrainingID(trainingID TrainingID) ([]TrainingDate, error) {
func (r *InMemoryDateRepository) FindAllByTrainingID(trainingID ID) ([]Date, error) {
r.lock.RLock()
defer r.lock.RUnlock()
dates := make([]TrainingDate, 0)
dates := make([]Date, 0)
for _, id := range r.trainingToDates[trainingID] {
dates = append(dates, r.trainingDates[id])
}
@ -135,12 +135,12 @@ func (r *InMemoryTrainingDateRepository) FindAllByTrainingID(trainingID Training
return dates, nil
}
func (r *InMemoryTrainingDateRepository) FindUpcomingByTrainingID(trainingID TrainingID) ([]TrainingDate, error) {
func (r *InMemoryDateRepository) FindUpcomingByTrainingID(trainingID ID) ([]Date, error) {
r.lock.RLock()
defer r.lock.RUnlock()
now := time.Now()
var dates []TrainingDate
var dates []Date
for _, id := range r.trainingToDates[trainingID] {
date := r.trainingDates[id]
if date.Date.After(now) {
@ -151,7 +151,7 @@ func (r *InMemoryTrainingDateRepository) FindUpcomingByTrainingID(trainingID Tra
return dates, nil
}
func (r *InMemoryTrainingDateRepository) Update(trainingDate *TrainingDate) error {
func (r *InMemoryDateRepository) Update(trainingDate *Date) error {
r.lock.Lock()
defer r.lock.Unlock()
@ -161,7 +161,7 @@ func (r *InMemoryTrainingDateRepository) Update(trainingDate *TrainingDate) erro
return nil
}
func (r *InMemoryTrainingDateRepository) Delete(id TrainingDateID) error {
func (r *InMemoryDateRepository) Delete(id DateID) error {
r.lock.Lock()
defer r.lock.Unlock()
@ -182,23 +182,23 @@ func (r *InMemoryTrainingDateRepository) Delete(id TrainingDateID) error {
return nil
}
type InMemoryTrainingDateAttendeeRepository struct {
attendees map[TrainingDateAttendeeID]TrainingDateAttendee
dateToAttendees map[TrainingDateID][]TrainingDateAttendeeID
type InMemoryAttendeeRepository struct {
attendees map[AttendeeID]Attendee
dateToAttendees map[DateID][]AttendeeID
lock sync.RWMutex
ai int
}
func NewInMemoryTrainingDateAttendeeRepository() *InMemoryTrainingDateAttendeeRepository {
return &InMemoryTrainingDateAttendeeRepository{
attendees: make(map[TrainingDateAttendeeID]TrainingDateAttendee),
dateToAttendees: make(map[TrainingDateID][]TrainingDateAttendeeID),
func NewInMemoryAttendeeRepository() *InMemoryAttendeeRepository {
return &InMemoryAttendeeRepository{
attendees: make(map[AttendeeID]Attendee),
dateToAttendees: make(map[DateID][]AttendeeID),
ai: 1,
}
}
func (r *InMemoryTrainingDateAttendeeRepository) Create(trainingDateID TrainingDateID, attendee *TrainingDateAttendee) error {
func (r *InMemoryAttendeeRepository) Create(trainingDateID DateID, attendee *Attendee) error {
r.lock.Lock()
defer r.lock.Unlock()
@ -212,7 +212,7 @@ func (r *InMemoryTrainingDateAttendeeRepository) Create(trainingDateID TrainingD
return nil
}
func (r *InMemoryTrainingDateAttendeeRepository) FindByID(id TrainingDateAttendeeID) (*TrainingDateAttendee, error) {
func (r *InMemoryAttendeeRepository) FindByID(id AttendeeID) (*Attendee, error) {
r.lock.RLock()
defer r.lock.RUnlock()
@ -223,11 +223,11 @@ func (r *InMemoryTrainingDateAttendeeRepository) FindByID(id TrainingDateAttende
return &attendee, nil
}
func (r *InMemoryTrainingDateAttendeeRepository) FindAll() ([]TrainingDateAttendee, error) {
func (r *InMemoryAttendeeRepository) FindAll() ([]Attendee, error) {
r.lock.RLock()
defer r.lock.RUnlock()
attendees := make([]TrainingDateAttendee, len(r.attendees))
attendees := make([]Attendee, len(r.attendees))
for _, attendee := range r.attendees {
attendees = append(attendees, attendee)
}
@ -235,11 +235,11 @@ func (r *InMemoryTrainingDateAttendeeRepository) FindAll() ([]TrainingDateAttend
return attendees, nil
}
func (r *InMemoryTrainingDateAttendeeRepository) FindAllByTrainingDateID(trainingDateID TrainingDateID) ([]TrainingDateAttendee, error) {
func (r *InMemoryAttendeeRepository) FindAllByTrainingDateID(trainingDateID DateID) ([]Attendee, error) {
r.lock.RLock()
defer r.lock.RUnlock()
attendees := make([]TrainingDateAttendee, 0)
attendees := make([]Attendee, 0)
for _, id := range r.dateToAttendees[trainingDateID] {
attendees = append(attendees, r.attendees[id])
}
@ -247,7 +247,7 @@ func (r *InMemoryTrainingDateAttendeeRepository) FindAllByTrainingDateID(trainin
return attendees, nil
}
func (r *InMemoryTrainingDateAttendeeRepository) Update(attendee *TrainingDateAttendee) error {
func (r *InMemoryAttendeeRepository) Update(attendee *Attendee) error {
r.lock.Lock()
defer r.lock.Unlock()
@ -257,7 +257,7 @@ func (r *InMemoryTrainingDateAttendeeRepository) Update(attendee *TrainingDateAt
return nil
}
func (r *InMemoryTrainingDateAttendeeRepository) Delete(id TrainingDateAttendeeID) error {
func (r *InMemoryAttendeeRepository) Delete(id AttendeeID) error {
r.lock.Lock()
defer r.lock.Unlock()

View file

@ -6,35 +6,35 @@ import (
"time"
)
type TrainingID = int
type ID = int
type Training struct {
ID TrainingID
ID ID
Name string
Days int8
Description string
Pricing []TrainingPrice `db:"-"`
Pricing []Price `db:"-"`
}
type TrainingPrice struct {
type Price struct {
Amount decimal.Decimal
Currency money.Currency
Type TrainingPriceType
Type PriceType
}
type TrainingPriceType string
type PriceType string
const (
OpenTrainingPrice TrainingPriceType = "OPEN"
CorporateTrainingPrice TrainingPriceType = "CORPORATE"
OpenTrainingPrice PriceType = "OPEN"
CorporateTrainingPrice PriceType = "CORPORATE"
)
type TrainingDateID = int
type DateID = int
type TrainingDate struct {
trainingID TrainingID
type Date struct {
trainingID ID
ID TrainingDateID
ID DateID
Date time.Time
StartTime time.Time
Days int8
@ -46,12 +46,12 @@ type TrainingDate struct {
PriceCurrency money.Currency `db:"price_currency"`
}
type TrainingDateAttendeeID = int
type AttendeeID = int
type TrainingDateAttendee struct {
trainingDateID TrainingDateID
type Attendee struct {
trainingDateID DateID
ID TrainingDateAttendeeID
ID AttendeeID
Name string
Email string
Phone string

View file

@ -66,7 +66,7 @@ func (r *PostgresTrainingRepository) Create(training *Training) error {
return nil
}
func (r *PostgresTrainingRepository) FindByID(id TrainingID) (*Training, error) {
func (r *PostgresTrainingRepository) FindByID(id ID) (*Training, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -91,12 +91,12 @@ func (r *PostgresTrainingRepository) FindByID(id TrainingID) (*Training, error)
}
defer rows.Close()
training.Pricing = make([]TrainingPrice, 0)
training.Pricing, err = pgx.CollectRows[TrainingPrice](rows, func(row pgx.CollectableRow) (TrainingPrice, error) {
var price TrainingPrice
training.Pricing = make([]Price, 0)
training.Pricing, err = pgx.CollectRows[Price](rows, func(row pgx.CollectableRow) (Price, error) {
var price Price
err := row.Scan(&price.Amount, &price.Currency, &price.Type)
if err != nil {
return TrainingPrice{}, err
return Price{}, err
}
return price, nil
})
@ -132,7 +132,7 @@ func (r *PostgresTrainingRepository) FindAll() ([]Training, error) {
return Training{}, queryErr
}
training.Pricing, scanErr = pgx.CollectRows(priceRows, pgx.RowToStructByName[TrainingPrice])
training.Pricing, scanErr = pgx.CollectRows(priceRows, pgx.RowToStructByName[Price])
if scanErr != nil {
return Training{}, scanErr
}
@ -198,7 +198,7 @@ func (r *PostgresTrainingRepository) Update(training *Training) error {
return nil
}
func (r *PostgresTrainingRepository) Delete(id TrainingID) error {
func (r *PostgresTrainingRepository) Delete(id ID) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -233,15 +233,15 @@ func (r *PostgresTrainingRepository) Delete(id TrainingID) error {
return nil
}
type PostgresTrainingDateRepository struct {
type PostgresDateRepository struct {
pg *pgxpool.Pool
}
func NewPostgresTrainingDateRepository(pg *pgxpool.Pool) *PostgresTrainingDateRepository {
return &PostgresTrainingDateRepository{pg: pg}
func NewPostgresDateRepository(pg *pgxpool.Pool) *PostgresDateRepository {
return &PostgresDateRepository{pg: pg}
}
func (r *PostgresTrainingDateRepository) Create(trainingID TrainingID, trainingDate *TrainingDate) error {
func (r *PostgresDateRepository) Create(trainingID ID, trainingDate *Date) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -266,11 +266,11 @@ func (r *PostgresTrainingDateRepository) Create(trainingID TrainingID, trainingD
return nil
}
func (r *PostgresTrainingDateRepository) FindByID(id TrainingDateID) (*TrainingDate, error) {
func (r *PostgresDateRepository) FindByID(id DateID) (*Date, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
var trainingDate TrainingDate
var trainingDate Date
err := r.pg.QueryRow(ctx, `SELECT * FROM training.dates WHERE id = $1`, id).
Scan(
&trainingDate.ID,
@ -292,7 +292,7 @@ func (r *PostgresTrainingDateRepository) FindByID(id TrainingDateID) (*TrainingD
return &trainingDate, nil
}
func (r *PostgresTrainingDateRepository) FindAll() ([]TrainingDate, error) {
func (r *PostgresDateRepository) FindAll() ([]Date, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -302,9 +302,9 @@ func (r *PostgresTrainingDateRepository) FindAll() ([]TrainingDate, error) {
}
defer rows.Close()
var trainingDates []TrainingDate
var trainingDates []Date
for rows.Next() {
var trainingDate TrainingDate
var trainingDate Date
err := rows.Scan(
&trainingDate.ID,
&trainingDate.trainingID,
@ -328,7 +328,7 @@ func (r *PostgresTrainingDateRepository) FindAll() ([]TrainingDate, error) {
return trainingDates, nil
}
func (r *PostgresTrainingDateRepository) FindAllByTrainingID(trainingID TrainingID) ([]TrainingDate, error) {
func (r *PostgresDateRepository) FindAllByTrainingID(trainingID ID) ([]Date, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -338,9 +338,9 @@ func (r *PostgresTrainingDateRepository) FindAllByTrainingID(trainingID Training
}
defer rows.Close()
var trainingDates []TrainingDate
var trainingDates []Date
for rows.Next() {
var trainingDate TrainingDate
var trainingDate Date
err := rows.Scan(
&trainingDate.ID,
&trainingDate.trainingID,
@ -364,7 +364,7 @@ func (r *PostgresTrainingDateRepository) FindAllByTrainingID(trainingID Training
return trainingDates, nil
}
func (r *PostgresTrainingDateRepository) FindUpcomingByTrainingID(trainingID TrainingID) ([]TrainingDate, error) {
func (r *PostgresDateRepository) FindUpcomingByTrainingID(trainingID ID) ([]Date, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -377,9 +377,9 @@ func (r *PostgresTrainingDateRepository) FindUpcomingByTrainingID(trainingID Tra
}
defer rows.Close()
var trainingDates []TrainingDate
var trainingDates []Date
for rows.Next() {
var trainingDate TrainingDate
var trainingDate Date
err := rows.Scan(
&trainingDate.ID,
&trainingDate.trainingID,
@ -403,7 +403,7 @@ func (r *PostgresTrainingDateRepository) FindUpcomingByTrainingID(trainingID Tra
return trainingDates, nil
}
func (r *PostgresTrainingDateRepository) Update(trainingDate *TrainingDate) error {
func (r *PostgresDateRepository) Update(trainingDate *Date) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -419,7 +419,7 @@ func (r *PostgresTrainingDateRepository) Update(trainingDate *TrainingDate) erro
return nil
}
func (r *PostgresTrainingDateRepository) Delete(id TrainingDateID) error {
func (r *PostgresDateRepository) Delete(id DateID) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -431,20 +431,20 @@ func (r *PostgresTrainingDateRepository) Delete(id TrainingDateID) error {
return nil
}
type PostgresTrainingDateAttendeeRepository struct {
type PostgresAttendeeRepository struct {
pg *pgxpool.Pool
}
func NewPostgresTrainingDateAttendeeRepository(pg *pgxpool.Pool) *PostgresTrainingDateAttendeeRepository {
return &PostgresTrainingDateAttendeeRepository{pg: pg}
func NewPostgresAttendeeRepository(pg *pgxpool.Pool) *PostgresAttendeeRepository {
return &PostgresAttendeeRepository{pg: pg}
}
func (r *PostgresTrainingDateAttendeeRepository) Create(trainingDateID TrainingDateID, attendee *TrainingDateAttendee) error {
func (r *PostgresAttendeeRepository) Create(trainingDateID DateID, attendee *Attendee) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
err := r.pg.QueryRow(ctx, `
INSERT INTO training.date_attendees (date_id, name, email, phone, company, position, is_student, has_paid, has_attended, bill_amount, bill_currency)
INSERT INTO training.attendees (date_id, name, email, phone, company, position, is_student, has_paid, has_attended, bill_amount, bill_currency)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
RETURNING id
`, trainingDateID, attendee.Name, attendee.Email, attendee.Phone, attendee.Company, attendee.Position, attendee.IsStudent, attendee.HasPaid, attendee.HasAttended, attendee.BillAmount, attendee.BillCurrency).
@ -456,14 +456,14 @@ func (r *PostgresTrainingDateAttendeeRepository) Create(trainingDateID TrainingD
return nil
}
func (r *PostgresTrainingDateAttendeeRepository) FindByID(id TrainingDateAttendeeID) (*TrainingDateAttendee, error) {
func (r *PostgresAttendeeRepository) FindByID(id AttendeeID) (*Attendee, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
var attendee TrainingDateAttendee
var attendee Attendee
err := r.pg.QueryRow(ctx, `
SELECT id, date_id, name, email, phone, company, position, is_student, has_paid, has_attended, bill_amount, bill_currency
FROM training.date_attendees
FROM training.attendees
WHERE id = $1
`, id).Scan(&attendee.ID, &attendee.trainingDateID, &attendee.Name, &attendee.Email, &attendee.Phone, &attendee.Company, &attendee.Position, &attendee.IsStudent, &attendee.HasPaid, &attendee.HasAttended, &attendee.BillAmount, &attendee.BillCurrency)
if err != nil {
@ -473,22 +473,22 @@ func (r *PostgresTrainingDateAttendeeRepository) FindByID(id TrainingDateAttende
return &attendee, nil
}
func (r *PostgresTrainingDateAttendeeRepository) FindAll() ([]TrainingDateAttendee, error) {
func (r *PostgresAttendeeRepository) FindAll() ([]Attendee, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
rows, err := r.pg.Query(ctx, `
SELECT id, date_id, name, email, phone, company, position, is_student, has_paid, has_attended, bill_amount, bill_currency
FROM training.date_attendees
FROM training.attendees
`)
if err != nil {
return nil, err
}
defer rows.Close()
var attendees []TrainingDateAttendee
var attendees []Attendee
for rows.Next() {
var attendee TrainingDateAttendee
var attendee Attendee
err := rows.Scan(&attendee.ID, &attendee.trainingDateID, &attendee.Name, &attendee.Email, &attendee.Phone, &attendee.Company, &attendee.Position, &attendee.IsStudent, &attendee.HasPaid, &attendee.HasAttended, &attendee.BillAmount, &attendee.BillCurrency)
if err != nil {
return nil, err
@ -500,13 +500,13 @@ func (r *PostgresTrainingDateAttendeeRepository) FindAll() ([]TrainingDateAttend
return attendees, nil
}
func (r *PostgresTrainingDateAttendeeRepository) FindAllByTrainingDateID(trainingDateID TrainingDateID) ([]TrainingDateAttendee, error) {
func (r *PostgresAttendeeRepository) FindAllByTrainingDateID(trainingDateID DateID) ([]Attendee, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
rows, err := r.pg.Query(ctx, `
SELECT id, date_id, name, email, phone, company, position, is_student, has_paid, has_attended, bill_amount, bill_currency
FROM training.date_attendees
FROM training.attendees
WHERE date_id = $1
`, trainingDateID)
if err != nil {
@ -514,9 +514,9 @@ func (r *PostgresTrainingDateAttendeeRepository) FindAllByTrainingDateID(trainin
}
defer rows.Close()
var attendees []TrainingDateAttendee
var attendees []Attendee
for rows.Next() {
var attendee TrainingDateAttendee
var attendee Attendee
err := rows.Scan(&attendee.ID, &attendee.trainingDateID, &attendee.Name, &attendee.Email, &attendee.Phone, &attendee.Company, &attendee.Position, &attendee.IsStudent, &attendee.HasPaid, &attendee.HasAttended, &attendee.BillAmount, &attendee.BillCurrency)
if err != nil {
return nil, err
@ -528,12 +528,12 @@ func (r *PostgresTrainingDateAttendeeRepository) FindAllByTrainingDateID(trainin
return attendees, nil
}
func (r *PostgresTrainingDateAttendeeRepository) Update(attendee *TrainingDateAttendee) error {
func (r *PostgresAttendeeRepository) Update(attendee *Attendee) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err := r.pg.Exec(ctx, `
UPDATE training.date_attendees
UPDATE training.attendees
SET name = $1, email = $2, phone = $3, company = $4, position = $5, is_student = $6, has_paid = $7, has_attended = $8, bill_amount = $9, bill_currency = $10
WHERE id = $10
`, attendee.Name, attendee.Email, attendee.Phone, attendee.Company, attendee.Position, attendee.IsStudent, attendee.HasPaid, attendee.HasAttended, attendee.BillAmount, attendee.BillCurrency, attendee.ID)
@ -544,11 +544,11 @@ func (r *PostgresTrainingDateAttendeeRepository) Update(attendee *TrainingDateAt
return nil
}
func (r *PostgresTrainingDateAttendeeRepository) Delete(id TrainingDateAttendeeID) error {
func (r *PostgresAttendeeRepository) Delete(id AttendeeID) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err := r.pg.Exec(ctx, `DELETE FROM training.date_attendees WHERE id = $1`, id)
_, err := r.pg.Exec(ctx, `DELETE FROM training.attendees WHERE id = $1`, id)
if err != nil {
return err
}

View file

@ -1,28 +1,28 @@
package training
type TrainingRepository interface {
type Repository interface {
Create(training *Training) error
FindByID(id TrainingID) (*Training, error)
FindByID(id ID) (*Training, error)
FindAll() ([]Training, error)
Update(training *Training) error
Delete(id TrainingID) error
Delete(id ID) error
}
type TrainingDateRepository interface {
Create(trainingID TrainingID, trainingDate *TrainingDate) error
FindByID(id TrainingDateID) (*TrainingDate, error)
FindAll() ([]TrainingDate, error)
FindAllByTrainingID(trainingID TrainingID) ([]TrainingDate, error)
FindUpcomingByTrainingID(trainingID TrainingID) ([]TrainingDate, error)
Update(trainingDate *TrainingDate) error
Delete(id TrainingDateID) error
type DateRepository interface {
Create(trainingID ID, trainingDate *Date) error
FindByID(id DateID) (*Date, error)
FindAll() ([]Date, error)
FindAllByTrainingID(trainingID ID) ([]Date, error)
FindUpcomingByTrainingID(trainingID ID) ([]Date, error)
Update(trainingDate *Date) error
Delete(id DateID) error
}
type TrainingDateAttendeeRepository interface {
Create(trainingDateID TrainingDateID, attendee *TrainingDateAttendee) error
FindByID(id TrainingDateAttendeeID) (*TrainingDateAttendee, error)
FindAll() ([]TrainingDateAttendee, error)
FindAllByTrainingDateID(trainingDateID TrainingDateID) ([]TrainingDateAttendee, error)
Update(attendee *TrainingDateAttendee) error
Delete(id TrainingDateAttendeeID) error
type AttendeeRepository interface {
Create(trainingDateID DateID, attendee *Attendee) error
FindByID(id AttendeeID) (*Attendee, error)
FindAll() ([]Attendee, error)
FindAllByTrainingDateID(trainingDateID DateID) ([]Attendee, error)
Update(attendee *Attendee) error
Delete(id AttendeeID) error
}