diff --git a/controller/register/login.go b/controller/register/login.go index 81e48f6..6c8f2f9 100644 --- a/controller/register/login.go +++ b/controller/register/login.go @@ -40,7 +40,7 @@ func Login(context *gin.Context) { return } if user.Status == 2 { - err = teamService.UpdateCaptain(user.TeamId, user.OpenId) + err = teamService.UpdateCaptain(user.TeamId, jwtData.OpenID) if err != nil { utility.ResponseError(context, "更新队长失败") return diff --git a/service/teamService/update.go b/service/teamService/update.go index e8c959d..2c2b523 100644 --- a/service/teamService/update.go +++ b/service/teamService/update.go @@ -18,5 +18,5 @@ func Create(a model.Team) { } func UpdateCaptain(teamID int, openID string) error { - return global.DB.Exec("UPDATE teams SET captain = ? WHERE id = ?", openID, teamID).Error + return global.DB.Model(&model.Team{}).Where("id = ?", teamID).Update("captain", openID).Error }