Skip to content

Commit

Permalink
fix: groups user
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacelocust committed Jul 16, 2024
1 parent a54eb63 commit a4bf7d6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions api/internal/server/mission.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a4bf7d6

Please sign in to comment.