feat: add postgres repository for training
This commit is contained in:
parent
8c277ef692
commit
ff7e320481
19 changed files with 1277 additions and 414 deletions
|
|
@ -238,8 +238,8 @@ func (h *APIHandlers) ListTrainingDates(ctx context.Context, req ListTrainingDat
|
|||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount.String(),
|
||||
Currency: td.Price.Currency,
|
||||
Amount: td.PriceAmount.String(),
|
||||
Currency: td.PriceCurrency,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTraining
|
|||
}}, nil
|
||||
}
|
||||
|
||||
price := money.Price{
|
||||
price := money.Money{
|
||||
Amount: amount,
|
||||
Currency: req.Body.Price.Currency,
|
||||
}
|
||||
|
|
@ -274,14 +274,15 @@ func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTraining
|
|||
}
|
||||
|
||||
td := training.TrainingDate{
|
||||
Date: req.Body.Date.Time,
|
||||
StartTime: startTime,
|
||||
Days: req.Body.Days,
|
||||
IsOnline: req.Body.IsOnline,
|
||||
Location: req.Body.Location,
|
||||
Address: req.Body.Address,
|
||||
Capacity: req.Body.Capacity,
|
||||
Price: price,
|
||||
Date: req.Body.Date.Time,
|
||||
StartTime: startTime,
|
||||
Days: req.Body.Days,
|
||||
IsOnline: req.Body.IsOnline,
|
||||
Location: req.Body.Location,
|
||||
Address: req.Body.Address,
|
||||
Capacity: req.Body.Capacity,
|
||||
PriceAmount: price.Amount,
|
||||
PriceCurrency: price.Currency,
|
||||
}
|
||||
|
||||
err = h.trainingDateRepository.Create(req.TrainingID, &td)
|
||||
|
|
@ -304,8 +305,8 @@ func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTraining
|
|||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount.String(),
|
||||
Currency: td.Price.Currency,
|
||||
Amount: td.PriceAmount.String(),
|
||||
Currency: td.PriceCurrency,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -357,8 +358,8 @@ func (h *APIHandlers) GetTrainingDate(ctx context.Context, req GetTrainingDateRe
|
|||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount.String(),
|
||||
Currency: td.Price.Currency,
|
||||
Amount: td.PriceAmount.String(),
|
||||
Currency: td.PriceCurrency,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -374,7 +375,7 @@ func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTraining
|
|||
}}, nil
|
||||
}
|
||||
|
||||
price := money.Price{
|
||||
price := money.Money{
|
||||
Amount: amount,
|
||||
Currency: req.Body.Price.Currency,
|
||||
}
|
||||
|
|
@ -390,15 +391,16 @@ func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTraining
|
|||
}
|
||||
|
||||
td := training.TrainingDate{
|
||||
ID: req.TrainingDateID,
|
||||
Date: req.Body.Date.Time,
|
||||
StartTime: startTime,
|
||||
Days: req.Body.Days,
|
||||
IsOnline: req.Body.IsOnline,
|
||||
Location: req.Body.Location,
|
||||
Address: req.Body.Address,
|
||||
Capacity: req.Body.Capacity,
|
||||
Price: price,
|
||||
ID: req.TrainingDateID,
|
||||
Date: req.Body.Date.Time,
|
||||
StartTime: startTime,
|
||||
Days: req.Body.Days,
|
||||
IsOnline: req.Body.IsOnline,
|
||||
Location: req.Body.Location,
|
||||
Address: req.Body.Address,
|
||||
Capacity: req.Body.Capacity,
|
||||
PriceAmount: price.Amount,
|
||||
PriceCurrency: price.Currency,
|
||||
}
|
||||
|
||||
err = h.trainingDateRepository.Update(&td)
|
||||
|
|
@ -421,8 +423,8 @@ func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTraining
|
|||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount.String(),
|
||||
Currency: td.Price.Currency,
|
||||
Amount: td.PriceAmount.String(),
|
||||
Currency: td.PriceCurrency,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -463,8 +465,8 @@ func (h *APIHandlers) ListAllUpcomingTrainingDates(ctx context.Context, req List
|
|||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount.String(),
|
||||
Currency: td.Price.Currency,
|
||||
Amount: td.PriceAmount.String(),
|
||||
Currency: td.PriceCurrency,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -496,8 +498,8 @@ func (h *APIHandlers) ListTrainingUpcomingDates(ctx context.Context, req ListTra
|
|||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount.String(),
|
||||
Currency: td.Price.Currency,
|
||||
Amount: td.PriceAmount.String(),
|
||||
Currency: td.PriceCurrency,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -529,8 +531,8 @@ func (h *APIHandlers) ListTrainingDateAttendees(ctx context.Context, req ListTra
|
|||
HasPaid: a.HasPaid,
|
||||
HasAttended: a.HasAttended,
|
||||
Bill: Price{
|
||||
Amount: a.Bill.Amount.String(),
|
||||
Currency: a.Bill.Currency,
|
||||
Amount: a.BillAmount.String(),
|
||||
Currency: a.BillCurrency,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -576,15 +578,16 @@ func (h *APIHandlers) CreateTrainingDateAttendee(ctx context.Context, req Create
|
|||
}
|
||||
|
||||
ta := training.TrainingDateAttendee{
|
||||
Name: req.Body.Name,
|
||||
Email: string(req.Body.Email),
|
||||
Phone: req.Body.Phone,
|
||||
Company: req.Body.Company,
|
||||
Position: req.Body.Position,
|
||||
IsStudent: *req.Body.IsStudent,
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
Bill: td.Price,
|
||||
Name: req.Body.Name,
|
||||
Email: string(req.Body.Email),
|
||||
Phone: req.Body.Phone,
|
||||
Company: req.Body.Company,
|
||||
Position: req.Body.Position,
|
||||
IsStudent: *req.Body.IsStudent,
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
BillAmount: td.PriceAmount,
|
||||
BillCurrency: td.PriceCurrency,
|
||||
}
|
||||
|
||||
err = h.trainingDateAttendeeRepository.Create(req.TrainingDateID, &ta)
|
||||
|
|
@ -608,8 +611,8 @@ func (h *APIHandlers) CreateTrainingDateAttendee(ctx context.Context, req Create
|
|||
HasAttended: ta.HasAttended,
|
||||
HasPaid: ta.HasPaid,
|
||||
Bill: Price{
|
||||
Amount: ta.Bill.Amount.String(),
|
||||
Currency: ta.Bill.Currency,
|
||||
Amount: ta.BillAmount.String(),
|
||||
Currency: ta.BillCurrency,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -714,8 +717,8 @@ func (h *APIHandlers) GetTrainingDateAttendee(ctx context.Context, req GetTraini
|
|||
HasAttended: ta.HasAttended,
|
||||
HasPaid: ta.HasPaid,
|
||||
Bill: Price{
|
||||
Amount: ta.Bill.Amount.String(),
|
||||
Currency: ta.Bill.Currency,
|
||||
Amount: ta.BillAmount.String(),
|
||||
Currency: ta.BillCurrency,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -803,8 +806,8 @@ func (h *APIHandlers) UpdateTrainingDateAttendee(ctx context.Context, req Update
|
|||
HasAttended: ta.HasAttended,
|
||||
HasPaid: ta.HasPaid,
|
||||
Bill: Price{
|
||||
Amount: ta.Bill.Amount.String(),
|
||||
Currency: ta.Bill.Currency,
|
||||
Amount: ta.BillAmount.String(),
|
||||
Currency: ta.BillCurrency,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -887,8 +890,8 @@ func (h *APIHandlers) UpdateTrainingDateAttendeePayment(ctx context.Context, req
|
|||
HasAttended: ta.HasAttended,
|
||||
HasPaid: ta.HasPaid,
|
||||
Bill: Price{
|
||||
Amount: ta.Bill.Amount.String(),
|
||||
Currency: ta.Bill.Currency,
|
||||
Amount: ta.BillAmount.String(),
|
||||
Currency: ta.BillCurrency,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -971,8 +974,8 @@ func (h *APIHandlers) UpdateTrainingDateAttendeeAttendance(ctx context.Context,
|
|||
HasAttended: ta.HasAttended,
|
||||
HasPaid: ta.HasPaid,
|
||||
Bill: Price{
|
||||
Amount: ta.Bill.Amount.String(),
|
||||
Currency: ta.Bill.Currency,
|
||||
Amount: ta.BillAmount.String(),
|
||||
Currency: ta.BillCurrency,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue