|
|
@ -13,17 +13,6 @@ type TugOfWarCtl struct { |
|
|
|
controllers.AuthorCtl |
|
|
|
} |
|
|
|
|
|
|
|
// 获取当前状态(废弃)
|
|
|
|
// @Summary client tug war
|
|
|
|
// @Description get current status
|
|
|
|
// @Tags client tug war
|
|
|
|
// @Accept json
|
|
|
|
// @Produce json
|
|
|
|
// @Param bahe_activity_id query int true "Bahe Activity ID"
|
|
|
|
// @Success 0 {object} models.TugOfWar
|
|
|
|
// @Failure 503 {string} string "参数不存在"
|
|
|
|
// @Failure 504 {object} string "用户不存在"
|
|
|
|
// @Router /Client/TugOfWarCtl/status [get]
|
|
|
|
func (t *TugOfWarCtl) Status() { |
|
|
|
// 获取此次活动的状态
|
|
|
|
baheId := t.MustGetInt64("bahe_activity_id") |
|
|
@ -119,12 +108,6 @@ func (t *TugOfWarCtl) Shake() { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
type JoinTeamResult struct { |
|
|
|
Number int |
|
|
|
TeamId int64 |
|
|
|
TeamName string |
|
|
|
} |
|
|
|
|
|
|
|
func (t *TugOfWarCtl) JoinTeam() { |
|
|
|
teamId := t.MustGetInt64("bahe_team_id") |
|
|
|
baheActivityId := t.MustGetInt64("bahe_activity_id") |
|
|
@ -154,9 +137,26 @@ func (t *TugOfWarCtl) JoinTeam() { |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
team := new(JoinTeamResult) |
|
|
|
exist, err = models.GetJoinTeamByBaheId(team, bahe.Id, teamId, activity.RehearsalId) |
|
|
|
//
|
|
|
|
//team := new(JoinTeamResult)
|
|
|
|
//session := 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=?", activity.RehearsalId)
|
|
|
|
//if teamId == 0 { // 人数最少的一队
|
|
|
|
// session = session.Where("t.is_delete=0 and t.bahe_activity_id=? ", bahe.Id).
|
|
|
|
// GroupBy("t.id").Asc("number")
|
|
|
|
//} else {
|
|
|
|
// session = session.Where("t.is_delete=0 and t.id=?", teamId).GroupBy("t.id")
|
|
|
|
//}
|
|
|
|
//exist, err = session.Get(team)
|
|
|
|
|
|
|
|
var team *bahe_service.JoinTeamResult |
|
|
|
if teamId == 0 { |
|
|
|
team, exist, err = bahe_service.GetJoinTeamByBaheId(bahe.Id, activity.RehearsalId) |
|
|
|
} else { |
|
|
|
team, exist, err = bahe_service.GetJoinTeamByTeamId(teamId, activity.RehearsalId) |
|
|
|
} |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_ERR, "队伍信息错误, 请重新扫码") |
|
|
|
t.Assert(team.Number < bahe.Number, code.MSG_TUGWAR_TEAM_OVER_LIMIT, "队伍满人,请等待下一轮") |
|
|
|