diff --git a/controllers/client/tug_war.go b/controllers/client/tug_war.go index 7e8f314..d24d5e0 100644 --- a/controllers/client/tug_war.go +++ b/controllers/client/tug_war.go @@ -138,7 +138,7 @@ func (t *TugOfWarCtl) JoinTeam() { var team *bahe_service.JoinTeamResult if teamId == 0 { - team, exist, err = bahe_service.GetJoinTeamByBaheId(bahe.Id, activity.RehearsalId) + team, exist, err = bahe_service.GetJoinTeamByBaheId(bahe.Id, activity.RehearsalId, activity.ArchId) } else { team, exist, err = bahe_service.GetJoinTeamByTeamId(teamId, activity.RehearsalId) } diff --git a/services/bahe/tug_war.go b/services/bahe/tug_war.go index ea5bbfd..78ea45e 100644 --- a/services/bahe/tug_war.go +++ b/services/bahe/tug_war.go @@ -76,23 +76,23 @@ type JoinTeamResult struct { TeamName string } -func GetJoinTeamByTeamId(teamId, rehearsalId interface{}) (*JoinTeamResult, bool, error) { +func GetJoinTeamByTeamId(teamId, rehearsalId, archId interface{}) (*JoinTeamResult, bool, error) { result := new(JoinTeamResult) exist, err := core.GetXormAuto().Table(new(models.BaheTeam)).Alias("t"). Select("t.id as team_id, t.bahe_team_name as team_name, count(m.id) as number"). - Join("LEFT", new(models.BaheTeamMember).Alias("m"), - "m.team_id=t.id and m.is_delete=0 and m.rehearsal_id=?", rehearsalId). - Where("t.is_delete=0 and t.id=?", teamId).GroupBy("t.id").Get(result) + Join("LEFT", new(models.BaheTeamMember).Alias("m"), "m.team_id=t.id"). + Where("t.is_delete=0 and t.id=? and m.rehearsal_id=? and m.arch_id=?", teamId, archId). + GroupBy("t.id").Get(result) return result, exist, err } -func GetJoinTeamByBaheId(baheId, rehearsalId interface{}) (*JoinTeamResult, bool, error) { +func GetJoinTeamByBaheId(baheId, rehearsalId, archId interface{}) (*JoinTeamResult, bool, error) { result := new(JoinTeamResult) exist, err := core.GetXormAuto().Table(new(models.BaheTeam)).Alias("t"). Select("t.id as team_id, t.bahe_team_name as team_name, count(m.id) as number"). - Join("LEFT", new(models.BaheTeamMember).Alias("m"), - "m.team_id=t.id and m.is_delete=0 and m.rehearsal_id=?", rehearsalId). - Where("t.is_delete=0 and t.bahe_activity_id=? ", baheId). + Join("LEFT", new(models.BaheTeamMember).Alias("m"), "m.team_id=t.id"). + Where("t.is_delete=0 and t.bahe_activity_id=? and m.rehearsal_id=? and m.arch_id=? ", + baheId, rehearsalId, archId). GroupBy("t.id").Asc("number").Get(result) return result, exist, err }