From 543a0360d731f7c100305e53afaaa65a22557efc Mon Sep 17 00:00:00 2001 From: trpdjke Date: Thu, 29 Aug 2024 03:15:52 +0300 Subject: [PATCH] change requests --- internal/service/handlers/daily_question_edit.go | 3 +-- internal/service/requests/daily_question_create.go | 9 +++------ internal/service/requests/daily_question_edit.go | 9 +++------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/internal/service/handlers/daily_question_edit.go b/internal/service/handlers/daily_question_edit.go index 85c284d..b1ae6b7 100644 --- a/internal/service/handlers/daily_question_edit.go +++ b/internal/service/handlers/daily_question_edit.go @@ -33,7 +33,6 @@ func EditDailyQuestion(w http.ResponseWriter, r *http.Request) { req, err := requests.NewDailyQuestionEdit(r) if err != nil { - Log(r).WithError(err).Error("Error creating daily question edit request") ape.RenderErr(w, problems.InternalError()) return @@ -87,7 +86,7 @@ func EditDailyQuestion(w http.ResponseWriter, r *http.Request) { return } if question != nil && ID != question.ID { - Log(r).Errorf("Error on this day %v, the daily question already has %v", question.StartsAt, question) + Log(r).Errorf("Error on this day %s, the daily question already has %s", question.StartsAt.String(), question) ape.RenderErr(w, problems.Conflict()) return } diff --git a/internal/service/requests/daily_question_create.go b/internal/service/requests/daily_question_create.go index 5c101e7..f844d59 100644 --- a/internal/service/requests/daily_question_create.go +++ b/internal/service/requests/daily_question_create.go @@ -15,11 +15,8 @@ func NewDailyQuestion(r *http.Request) (req resources.DailyQuestionCreateRespons } return req, validation.Errors{ - "data/attributes/time_for_answer": validation.Validate(req.Data.Attributes.TimeForAnswer, validation.Required), - "data/attributes/correct_answer": validation.Validate(req.Data.Attributes.CorrectAnswer, validation.Required), - "data/attributes/starts_at": validation.Validate(req.Data.Attributes.StartsAt, validation.Required), - "data/attributes/options": validation.Validate(req.Data.Attributes.Options, validation.Required), - "data/attributes/reward": validation.Validate(req.Data.Attributes.Reward, validation.Required), - "data/attributes/title": validation.Validate(req.Data.Attributes.Title, validation.Required), + "data/id": validation.Validate(&req.Data.ID, validation.Required), + "data/type": validation.Validate(&req.Data.Type, validation.Required), + "data/attributes": validation.Validate(&req.Data.Attributes, validation.Required), }.Filter() } diff --git a/internal/service/requests/daily_question_edit.go b/internal/service/requests/daily_question_edit.go index 6bb6e2f..2b43e93 100644 --- a/internal/service/requests/daily_question_edit.go +++ b/internal/service/requests/daily_question_edit.go @@ -15,11 +15,8 @@ func NewDailyQuestionEdit(r *http.Request) (req resources.DailyQuestionEditRespo } return req, validation.Errors{ - "time_for_answer": validation.Validate(&req.Data.Attributes.TimeForAnswer), - "correct_answer": validation.Validate(&req.Data.Attributes.CorrectAnswer), - "starts_at": validation.Validate(&req.Data.Attributes.StartsAt), - "options": validation.Validate(&req.Data.Attributes.Options), - "reward": validation.Validate(&req.Data.Attributes.Reward), - "title": validation.Validate(&req.Data.Attributes.Title), + "data/id": validation.Validate(&req.Data.ID, validation.Required), + "data/type": validation.Validate(&req.Data.Type, validation.Required), + "data/attributes": validation.Validate(&req.Data.Attributes, validation.Required), }.Filter() }