From 17fdefdd83108c4b6920c1af692783c2ccc195a1 Mon Sep 17 00:00:00 2001 From: pasha1coil Date: Fri, 25 Apr 2025 16:00:59 +0300 Subject: [PATCH] added omitempty for settings firld in resp --- service/service.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/service/service.go b/service/service.go index 70b9253..8b295ee 100644 --- a/service/service.go +++ b/service/service.go @@ -79,7 +79,7 @@ type GetQuizDataReq struct { // GetQuizDataResp response with prepared data for user type GetQuizDataResp struct { - Settings ShavedQuiz `json:"settings"` + Settings *ShavedQuiz `json:"settings,omitempty"` Items []ShavedQuestion `json:"items"` Count uint64 `json:"cnt"` ShowBadge bool `json:"show_badge"` @@ -136,8 +136,9 @@ func (s *Service) GetQuizData(c *fiber.Ctx) error { } if req.Limit == 0 && req.NeedConfig { + quizDto := dao2dtoQuiz(quiz) return c.Status(fiber.StatusOK).JSON(GetQuizDataResp{ - Settings: dao2dtoQuiz(quiz), + Settings: &quizDto, }) } @@ -199,7 +200,8 @@ func (s *Service) GetQuizData(c *fiber.Ctx) error { } if req.NeedConfig { - result.Settings = dao2dtoQuiz(quiz) + quizDto := dao2dtoQuiz(quiz) + result.Settings = &quizDto } for _, q := range questions {