1
0
Fork 0

refactor(server): trainingDate.date using oapi-codegen type date instead of time.Time

This commit is contained in:
Vojtěch Mareš 2024-05-13 22:21:06 +02:00
parent 6f360d9a5d
commit d62a942b41
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D

View file

@ -230,7 +230,7 @@ func (h *APIHandlers) ListTrainingDates(ctx context.Context, req ListTrainingDat
for idx, td := range trainingDates {
data[idx] = TrainingDate{
Id: td.ID,
Date: td.Date,
Date: types.Date{Time: td.Date},
StartTime: td.StartTime.Format(trainingDateStartTimeFormat),
Days: td.Days,
IsOnline: td.IsOnline,
@ -263,7 +263,7 @@ func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTraining
Currency: req.Body.Price.Currency,
}
startTime, err := time.Parse(time.RFC3339, "2000-01-01T"+req.Body.StartTime)
startTime, err := time.Parse(time.RFC3339, "2000-01-01T"+req.Body.StartTime+":00Z")
if err != nil {
return CreateTrainingDate400ApplicationProblemPlusJSONResponse{
InvalidInputErrorApplicationProblemPlusJSONResponse: InvalidInputErrorApplicationProblemPlusJSONResponse{
@ -274,7 +274,7 @@ func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTraining
}
td := training.TrainingDate{
Date: req.Body.Date,
Date: req.Body.Date.Time,
StartTime: startTime,
Days: req.Body.Days,
IsOnline: req.Body.IsOnline,
@ -296,7 +296,7 @@ func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTraining
return CreateTrainingDate201JSONResponse{
Id: td.ID,
Date: td.Date,
Date: types.Date{Time: td.Date},
StartTime: td.StartTime.Format(trainingDateStartTimeFormat),
Days: td.Days,
IsOnline: td.IsOnline,
@ -349,7 +349,7 @@ func (h *APIHandlers) GetTrainingDate(ctx context.Context, req GetTrainingDateRe
return GetTrainingDate200JSONResponse{
Id: td.ID,
Date: td.Date,
Date: types.Date{Time: td.Date},
StartTime: td.StartTime.Format(trainingDateStartTimeFormat),
Days: td.Days,
IsOnline: td.IsOnline,
@ -379,7 +379,7 @@ func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTraining
Currency: req.Body.Price.Currency,
}
startTime, err := time.Parse(time.RFC3339, "2000-01-01T"+req.Body.StartTime)
startTime, err := time.Parse(time.RFC3339, "2000-01-01T"+req.Body.StartTime+":00Z")
if err != nil {
return UpdateTrainingDate400ApplicationProblemPlusJSONResponse{
InvalidInputErrorApplicationProblemPlusJSONResponse: InvalidInputErrorApplicationProblemPlusJSONResponse{
@ -391,7 +391,7 @@ func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTraining
td := training.TrainingDate{
ID: req.TrainingDateID,
Date: req.Body.Date,
Date: req.Body.Date.Time,
StartTime: startTime,
Days: req.Body.Days,
IsOnline: req.Body.IsOnline,
@ -413,7 +413,7 @@ func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTraining
return UpdateTrainingDate200JSONResponse{
Id: td.ID,
Date: td.Date,
Date: types.Date{Time: td.Date},
StartTime: td.StartTime.Format(trainingDateStartTimeFormat),
Days: td.Days,
IsOnline: td.IsOnline,
@ -455,7 +455,7 @@ func (h *APIHandlers) ListAllUpcomingTrainingDates(ctx context.Context, req List
for j, td := range trainingDates {
response[i].Dates[j] = TrainingDate{
Id: td.ID,
Date: td.Date,
Date: types.Date{Time: td.Date},
StartTime: td.StartTime.Format(trainingDateStartTimeFormat),
Days: td.Days,
IsOnline: td.IsOnline,
@ -488,7 +488,7 @@ func (h *APIHandlers) ListTrainingUpcomingDates(ctx context.Context, req ListTra
for idx, td := range trainingDates {
data[idx] = TrainingDate{
Id: td.ID,
Date: td.Date,
Date: types.Date{Time: td.Date},
StartTime: td.StartTime.Format(trainingDateStartTimeFormat),
Days: td.Days,
IsOnline: td.IsOnline,