added omitempty for settings firld in resp

This commit is contained in:
pasha1coil 2025-04-25 16:00:59 +03:00
parent 2e7d9fb5ee
commit 17fdefdd83

@ -79,7 +79,7 @@ type GetQuizDataReq struct {
// GetQuizDataResp response with prepared data for user // GetQuizDataResp response with prepared data for user
type GetQuizDataResp struct { type GetQuizDataResp struct {
Settings ShavedQuiz `json:"settings"` Settings *ShavedQuiz `json:"settings,omitempty"`
Items []ShavedQuestion `json:"items"` Items []ShavedQuestion `json:"items"`
Count uint64 `json:"cnt"` Count uint64 `json:"cnt"`
ShowBadge bool `json:"show_badge"` ShowBadge bool `json:"show_badge"`
@ -136,8 +136,9 @@ func (s *Service) GetQuizData(c *fiber.Ctx) error {
} }
if req.Limit == 0 && req.NeedConfig { if req.Limit == 0 && req.NeedConfig {
quizDto := dao2dtoQuiz(quiz)
return c.Status(fiber.StatusOK).JSON(GetQuizDataResp{ 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 { if req.NeedConfig {
result.Settings = dao2dtoQuiz(quiz) quizDto := dao2dtoQuiz(quiz)
result.Settings = &quizDto
} }
for _, q := range questions { for _, q := range questions {