From d62a942b41c87b869f5b0fba60fd38e8160b185d Mon Sep 17 00:00:00 2001 From: Vojtech Mares Date: Mon, 13 May 2024 22:21:06 +0200 Subject: [PATCH] refactor(server): trainingDate.date using oapi-codegen type date instead of time.Time --- internal/server/api.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/server/api.go b/internal/server/api.go index 1d97a58..dd34d0f 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -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,