From 6484683ba9ff93ee18f964757ecfd51bd45dba60 Mon Sep 17 00:00:00 2001 From: yoneyan Date: Thu, 22 Jul 2021 23:30:37 +0900 Subject: [PATCH] [fix] Fixed group added process. --- pkg/api/core/group/v0/group.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/api/core/group/v0/group.go b/pkg/api/core/group/v0/group.go index 49945b9b..baf9ced6 100644 --- a/pkg/api/core/group/v0/group.go +++ b/pkg/api/core/group/v0/group.go @@ -73,7 +73,7 @@ func Add(c *gin.Context) { log.Println("Error: " + err.Error()) } - result, err := dbGroup.Create(&core.Group{ + groupData := core.Group{ Agree: &[]bool{*input.Agree}[0], StripeCustomerID: &cus.ID, Question: input.Question, @@ -91,7 +91,9 @@ func Add(c *gin.Context) { Open: &[]bool{false}[0], Pass: &[]bool{false}[0], AddAllow: &[]bool{true}[0], - }) + } + + _, err = dbGroup.Create(&groupData) if err != nil { c.JSON(http.StatusInternalServerError, common.Error{Error: err.Error()}) return @@ -107,8 +109,8 @@ func Add(c *gin.Context) { notification.SendSlack(notification.Slack{Attachment: attachment, ID: "main", Status: true}) - if err = dbUser.Update(user.UpdateGID, &core.User{Model: gorm.Model{ID: userResult.User.ID}, GroupID: &result.Model.ID}); err != nil { - log.Println(dbGroup.Delete(&core.Group{Model: gorm.Model{ID: result.ID}})) + if err = dbUser.Update(user.UpdateGID, &core.User{Model: gorm.Model{ID: userResult.User.ID}, GroupID: &groupData.ID}); err != nil { + log.Println(dbGroup.Delete(&core.Group{Model: gorm.Model{ID: groupData.ID}})) c.JSON(http.StatusInternalServerError, common.Error{Error: err.Error()}) } else { c.JSON(http.StatusOK, common.Result{})