From a4bf7d66cee597f2ccbcb16d116dc1058b863727 Mon Sep 17 00:00:00 2001 From: spacelocust <39099403+Spacelocust@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:49:30 +0200 Subject: [PATCH] fix: groups user --- api/internal/server/mission.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/api/internal/server/mission.go b/api/internal/server/mission.go index cb4e1da..dcbbd49 100644 --- a/api/internal/server/mission.go +++ b/api/internal/server/mission.go @@ -495,7 +495,7 @@ func (s *Server) JoinMission(c *gin.Context) { if err := db. Preload("Stratagems"). - Preload("User"). + Preload("GroupUser.User"). First(&newGroupUserMission, "id = ?", newGroupUserMission.ID). Error; err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { @@ -725,7 +725,21 @@ func (s *Server) UpdateGroupUserMission(c *gin.Context) { } // Update the group user mission - if err := db.Model(&groupUserMission).Preload("GroupUser.User").Association("Stratagems").Replace(newStratagems); err != nil { + if err := db.Model(&groupUserMission).Association("Stratagems").Replace(newStratagems); err != nil { + s.InternalErrorResponse(c, err) + return + } + + if err := db. + Preload("Stratagems"). + Preload("GroupUser.User"). + First(&groupUserMission, "id = ?", groupUserMission.ID). + Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + s.NotFoundResponse(c, "group user mission") + return + } + s.InternalErrorResponse(c, err) return }