Commit 1539b3c7 authored by haoyanbin's avatar haoyanbin

1

parent e5105abb
...@@ -2,6 +2,8 @@ package apis ...@@ -2,6 +2,8 @@ package apis
import ( import (
"fmt" "fmt"
cDto "go-admin/common/dto"
"strconv"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/sdk/api" "github.com/go-admin-team/go-admin-core/sdk/api"
...@@ -62,8 +64,8 @@ func (e OrgTeamTeam) GetPage(c *gin.Context) { ...@@ -62,8 +64,8 @@ func (e OrgTeamTeam) GetPage(c *gin.Context) {
// @Router /api/v1/org-team-team/get-match [get] // @Router /api/v1/org-team-team/get-match [get]
// @Security Bearer // @Security Bearer
func (e OrgTeamTeam) GetPageMatch(c *gin.Context) { func (e OrgTeamTeam) GetPageMatch(c *gin.Context) {
req := dto.OrgTeamGetPageReq{} req := dto.GetPageMatchTeamTeamReq{}
s := service.OrgTeam{} s := service.OrgTeamTeam{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req). Bind(&req).
...@@ -76,16 +78,33 @@ func (e OrgTeamTeam) GetPageMatch(c *gin.Context) { ...@@ -76,16 +78,33 @@ func (e OrgTeamTeam) GetPageMatch(c *gin.Context) {
} }
p := actions.GetPermissionFromContext(c) p := actions.GetPermissionFromContext(c)
list := make([]dto.OrgTeamGetPageReply, 0) reply := new(dto.GetPageMatchReply)
var count int64
err = s.GetPage(&req, p, &list, &count) replyGetMatchInfo := new(cDto.PageMatchInfo)
err = s.GetMatchInfo(strconv.Itoa(req.TeamId), p, replyGetMatchInfo)
if err != nil { if err != nil {
e.Error(500, err, fmt.Sprintf("获取球队 失败,\r\n失败信息 %s", err.Error())) e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return return
} }
reply.MatchInfo = *replyGetMatchInfo
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") replyGetRoundsScoring := make([]cDto.RoundsScoring, 0)
err = s.GetRoundsScoring(replyGetMatchInfo.PlayerId, replyGetMatchInfo.Rounds, &replyGetRoundsScoring)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reply.RoundsScoring = replyGetRoundsScoring
replyGetTotalScoring := make([]cDto.TotalScoring, 0)
err = s.GetTotalScoring(replyGetMatchInfo.PlayerId, replyGetMatchInfo.Rounds, replyGetMatchInfo.SeasonId, &replyGetTotalScoring)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reply.TotalScoring = replyGetTotalScoring
e.OK(reply, "查询成功")
} }
// Get <球队>获取球队表现比赛详情 // Get <球队>获取球队表现比赛详情
......
...@@ -35,7 +35,7 @@ func (e *OrgClubTeam) GetPage(c *dto.OrgClubTeamGetPageReq, p *actions.DataPermi ...@@ -35,7 +35,7 @@ func (e *OrgClubTeam) GetPage(c *dto.OrgClubTeamGetPageReq, p *actions.DataPermi
cDto.MakeCondition(c.GetNeedSearch()), cDto.MakeCondition(c.GetNeedSearch()),
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
actions.Permission(data.TableName(), p), actions.Permission(data.TableName(), p),
cDto.PassDel("ompt"), cDto.PassDel("omtp"),
). ).
Group("omtp.team_id"). Group("omtp.team_id").
Find(list).Limit(-1).Offset(-1). Find(list).Limit(-1).Offset(-1).
...@@ -132,7 +132,6 @@ func (e *OrgClubTeam) statisticsScoring(teamId string, rounds string, seasonId s ...@@ -132,7 +132,6 @@ func (e *OrgClubTeam) statisticsScoring(teamId string, rounds string, seasonId s
var err error var err error
field := "" field := ""
//if statistics == "sum" {
field += "sum(omtp.scoring)as scoring," + field += "sum(omtp.scoring)as scoring," +
"sum(omtp.rebound)as rebound," + "sum(omtp.rebound)as rebound," +
"sum(omtp.assist)as assist," + "sum(omtp.assist)as assist," +
...@@ -142,7 +141,6 @@ func (e *OrgClubTeam) statisticsScoring(teamId string, rounds string, seasonId s ...@@ -142,7 +141,6 @@ func (e *OrgClubTeam) statisticsScoring(teamId string, rounds string, seasonId s
"sum(omtp.foul)as foul," + "sum(omtp.foul)as foul," +
"sum(omtp.two_point_shot)as two_point_shot," + "sum(omtp.two_point_shot)as two_point_shot," +
"sum(omtp.three_point_shot)as three_point_shot" "sum(omtp.three_point_shot)as three_point_shot"
//}
err = e.Orm.Table("org_match_team_player as omtp"). err = e.Orm.Table("org_match_team_player as omtp").
Joins("left join org_match as om on omtp.match_id = om.id and omtp.rounds = om.rounds"). Joins("left join org_match as om on omtp.match_id = om.id and omtp.rounds = om.rounds").
...@@ -158,7 +156,6 @@ func (e *OrgClubTeam) statisticsScoring(teamId string, rounds string, seasonId s ...@@ -158,7 +156,6 @@ func (e *OrgClubTeam) statisticsScoring(teamId string, rounds string, seasonId s
Select(field). Select(field).
Scopes(cDto.SetWhere("om", "season_id", seasonId)). Scopes(cDto.SetWhere("om", "season_id", seasonId)).
Count(&teamCount).Error Count(&teamCount).Error
//_, _, teamCount := e.GetPageForTeam(seasonId)
data.Scoring = utils.GetAvg(data.Scoring, teamCount) data.Scoring = utils.GetAvg(data.Scoring, teamCount)
data.Rebound = utils.GetAvg(data.Rebound, teamCount) data.Rebound = utils.GetAvg(data.Rebound, teamCount)
......
...@@ -32,6 +32,7 @@ func (e *OrgMatchEvaluate) GetPage(c *dto.OrgMatchEvaluateGetPageReq, p *actions ...@@ -32,6 +32,7 @@ func (e *OrgMatchEvaluate) GetPage(c *dto.OrgMatchEvaluateGetPageReq, p *actions
cDto.MakeCondition(c.GetNeedSearch()), cDto.MakeCondition(c.GetNeedSearch()),
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
actions.Permission("omtp", p), actions.Permission("omtp", p),
cDto.PassDel("omtp"),
). ).
Find(list).Limit(-1).Offset(-1). Find(list).Limit(-1).Offset(-1).
Count(count).Error Count(count).Error
......
...@@ -34,6 +34,7 @@ func (e *OrgTeamMatch) GetPage(c *dto.OrgTeamMatchGetPageReq, p *actions.DataPer ...@@ -34,6 +34,7 @@ func (e *OrgTeamMatch) GetPage(c *dto.OrgTeamMatchGetPageReq, p *actions.DataPer
cDto.MakeCondition(c.GetNeedSearch()), cDto.MakeCondition(c.GetNeedSearch()),
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
actions.Permission(data.TableName(), p), actions.Permission(data.TableName(), p),
cDto.PassDel("om"),
). ).
Find(list).Limit(-1).Offset(-1). Find(list).Limit(-1).Offset(-1).
Count(count).Error Count(count).Error
......
...@@ -32,6 +32,7 @@ func (e *OrgTeamMatchEvaluate) GetPage(c *dto.OrgMatchEvaluateGetPageReq, p *act ...@@ -32,6 +32,7 @@ func (e *OrgTeamMatchEvaluate) GetPage(c *dto.OrgMatchEvaluateGetPageReq, p *act
cDto.MakeCondition(c.GetNeedSearch()), cDto.MakeCondition(c.GetNeedSearch()),
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
actions.Permission("omtp", p), actions.Permission("omtp", p),
cDto.PassDel("omtp"),
). ).
Find(list).Limit(-1).Offset(-1). Find(list).Limit(-1).Offset(-1).
Count(count).Error Count(count).Error
......
...@@ -30,6 +30,7 @@ func (e *OrgTeamPlayer) GetPage(c *dto.OrgTeamPlayerGetPageReq, p *actions.DataP ...@@ -30,6 +30,7 @@ func (e *OrgTeamPlayer) GetPage(c *dto.OrgTeamPlayerGetPageReq, p *actions.DataP
cDto.MakeCondition(c.GetNeedSearch()), cDto.MakeCondition(c.GetNeedSearch()),
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
actions.Permission("omtp", p), actions.Permission("omtp", p),
cDto.PassDel("omtp"),
). ).
Find(list).Limit(-1).Offset(-1). Find(list).Limit(-1).Offset(-1).
Count(count).Error Count(count).Error
......
...@@ -35,6 +35,7 @@ func (e *OrgTeamTeam) GetPage(c *dto.OrgTeamTeamGetPageReq, p *actions.DataPermi ...@@ -35,6 +35,7 @@ func (e *OrgTeamTeam) GetPage(c *dto.OrgTeamTeamGetPageReq, p *actions.DataPermi
cDto.MakeCondition(c.GetNeedSearch()), cDto.MakeCondition(c.GetNeedSearch()),
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
actions.Permission(data.TableName(), p), actions.Permission(data.TableName(), p),
cDto.PassDel("omtp"),
). ).
Group("omtp.team_id"). Group("omtp.team_id").
Find(list).Limit(-1).Offset(-1). Find(list).Limit(-1).Offset(-1).
...@@ -131,7 +132,6 @@ func (e *OrgTeamTeam) statisticsScoring(teamId string, rounds string, seasonId s ...@@ -131,7 +132,6 @@ func (e *OrgTeamTeam) statisticsScoring(teamId string, rounds string, seasonId s
var err error var err error
field := "" field := ""
if statistics == "sum" {
field += "sum(omtp.scoring)as scoring," + field += "sum(omtp.scoring)as scoring," +
"sum(omtp.rebound)as rebound," + "sum(omtp.rebound)as rebound," +
"sum(omtp.assist)as assist," + "sum(omtp.assist)as assist," +
...@@ -141,7 +141,6 @@ func (e *OrgTeamTeam) statisticsScoring(teamId string, rounds string, seasonId s ...@@ -141,7 +141,6 @@ func (e *OrgTeamTeam) statisticsScoring(teamId string, rounds string, seasonId s
"sum(omtp.foul)as foul," + "sum(omtp.foul)as foul," +
"sum(omtp.two_point_shot)as two_point_shot," + "sum(omtp.two_point_shot)as two_point_shot," +
"sum(omtp.three_point_shot)as three_point_shot" "sum(omtp.three_point_shot)as three_point_shot"
}
err = e.Orm.Table("org_match_team_player as omtp"). err = e.Orm.Table("org_match_team_player as omtp").
Joins("left join org_match as om on omtp.match_id = om.id and omtp.rounds = om.rounds"). Joins("left join org_match as om on omtp.match_id = om.id and omtp.rounds = om.rounds").
...@@ -151,7 +150,12 @@ func (e *OrgTeamTeam) statisticsScoring(teamId string, rounds string, seasonId s ...@@ -151,7 +150,12 @@ func (e *OrgTeamTeam) statisticsScoring(teamId string, rounds string, seasonId s
First(data).Error First(data).Error
if statistics == "avg" { if statistics == "avg" {
_, _, teamCount := e.GetPageForTeam(seasonId) var teamCount int64 = 0
err = e.Orm.Table("org_match_team_player as omtp").
Joins("left join org_match as om on omtp.match_id = om.id and omtp.rounds = om.rounds").
Select(field).
Scopes(cDto.SetWhere("om", "season_id", seasonId)).
Count(&teamCount).Error
data.Scoring = utils.GetAvg(data.Scoring, teamCount) data.Scoring = utils.GetAvg(data.Scoring, teamCount)
data.Rebound = utils.GetAvg(data.Rebound, teamCount) data.Rebound = utils.GetAvg(data.Rebound, teamCount)
...@@ -222,7 +226,7 @@ func (e *OrgTeamTeam) rankingScoring(replyGetPlayerRank []models.OrgMatchTeamPla ...@@ -222,7 +226,7 @@ func (e *OrgTeamTeam) rankingScoring(replyGetPlayerRank []models.OrgMatchTeamPla
return replyGetPlayerRank[i].Scoring > replyGetPlayerRank[j].Scoring return replyGetPlayerRank[i].Scoring > replyGetPlayerRank[j].Scoring
}) })
for k, v := range replyGetPlayerRank { for k, v := range replyGetPlayerRank {
if v.PlayerId == playerId { if v.TeamId == playerId {
scoring.Scoring = strconv.Itoa(k + 1) scoring.Scoring = strconv.Itoa(k + 1)
} }
} }
...@@ -232,7 +236,7 @@ func (e *OrgTeamTeam) rankingRebound(replyGetPlayerRank []models.OrgMatchTeamPla ...@@ -232,7 +236,7 @@ func (e *OrgTeamTeam) rankingRebound(replyGetPlayerRank []models.OrgMatchTeamPla
return replyGetPlayerRank[i].Rebound > replyGetPlayerRank[j].Rebound return replyGetPlayerRank[i].Rebound > replyGetPlayerRank[j].Rebound
}) })
for k, v := range replyGetPlayerRank { for k, v := range replyGetPlayerRank {
if v.PlayerId == playerId { if v.TeamId == playerId {
scoring.Rebound = strconv.Itoa(k + 1) scoring.Rebound = strconv.Itoa(k + 1)
} }
} }
...@@ -242,7 +246,7 @@ func (e *OrgTeamTeam) rankingAssist(replyGetPlayerRank []models.OrgMatchTeamPlay ...@@ -242,7 +246,7 @@ func (e *OrgTeamTeam) rankingAssist(replyGetPlayerRank []models.OrgMatchTeamPlay
return replyGetPlayerRank[i].Assist > replyGetPlayerRank[j].Assist return replyGetPlayerRank[i].Assist > replyGetPlayerRank[j].Assist
}) })
for k, v := range replyGetPlayerRank { for k, v := range replyGetPlayerRank {
if v.PlayerId == playerId { if v.TeamId == playerId {
scoring.Assist = strconv.Itoa(k + 1) scoring.Assist = strconv.Itoa(k + 1)
} }
} }
...@@ -252,7 +256,7 @@ func (e *OrgTeamTeam) rankingSteal(replyGetPlayerRank []models.OrgMatchTeamPlaye ...@@ -252,7 +256,7 @@ func (e *OrgTeamTeam) rankingSteal(replyGetPlayerRank []models.OrgMatchTeamPlaye
return replyGetPlayerRank[i].Steal > replyGetPlayerRank[j].Steal return replyGetPlayerRank[i].Steal > replyGetPlayerRank[j].Steal
}) })
for k, v := range replyGetPlayerRank { for k, v := range replyGetPlayerRank {
if v.PlayerId == playerId { if v.TeamId == playerId {
scoring.Steal = strconv.Itoa(k + 1) scoring.Steal = strconv.Itoa(k + 1)
} }
} }
...@@ -262,7 +266,7 @@ func (e *OrgTeamTeam) rankingFreeThrow(replyGetPlayerRank []models.OrgMatchTeamP ...@@ -262,7 +266,7 @@ func (e *OrgTeamTeam) rankingFreeThrow(replyGetPlayerRank []models.OrgMatchTeamP
return replyGetPlayerRank[i].FreeThrow > replyGetPlayerRank[j].FreeThrow return replyGetPlayerRank[i].FreeThrow > replyGetPlayerRank[j].FreeThrow
}) })
for k, v := range replyGetPlayerRank { for k, v := range replyGetPlayerRank {
if v.PlayerId == playerId { if v.TeamId == playerId {
scoring.FreeThrow = strconv.Itoa(k + 1) scoring.FreeThrow = strconv.Itoa(k + 1)
} }
} }
...@@ -272,7 +276,7 @@ func (e *OrgTeamTeam) rankingBlockShot(replyGetPlayerRank []models.OrgMatchTeamP ...@@ -272,7 +276,7 @@ func (e *OrgTeamTeam) rankingBlockShot(replyGetPlayerRank []models.OrgMatchTeamP
return replyGetPlayerRank[i].BlockShot > replyGetPlayerRank[j].BlockShot return replyGetPlayerRank[i].BlockShot > replyGetPlayerRank[j].BlockShot
}) })
for k, v := range replyGetPlayerRank { for k, v := range replyGetPlayerRank {
if v.PlayerId == playerId { if v.TeamId == playerId {
scoring.BlockShot = strconv.Itoa(k + 1) scoring.BlockShot = strconv.Itoa(k + 1)
} }
} }
...@@ -282,7 +286,7 @@ func (e *OrgTeamTeam) rankingFoul(replyGetPlayerRank []models.OrgMatchTeamPlayer ...@@ -282,7 +286,7 @@ func (e *OrgTeamTeam) rankingFoul(replyGetPlayerRank []models.OrgMatchTeamPlayer
return replyGetPlayerRank[i].Foul > replyGetPlayerRank[j].Foul return replyGetPlayerRank[i].Foul > replyGetPlayerRank[j].Foul
}) })
for k, v := range replyGetPlayerRank { for k, v := range replyGetPlayerRank {
if v.PlayerId == playerId { if v.TeamId == playerId {
scoring.Foul = strconv.Itoa(k + 1) scoring.Foul = strconv.Itoa(k + 1)
} }
} }
...@@ -292,7 +296,7 @@ func (e *OrgTeamTeam) rankingTwoPointShot(replyGetPlayerRank []models.OrgMatchTe ...@@ -292,7 +296,7 @@ func (e *OrgTeamTeam) rankingTwoPointShot(replyGetPlayerRank []models.OrgMatchTe
return replyGetPlayerRank[i].TwoPointShot > replyGetPlayerRank[j].TwoPointShot return replyGetPlayerRank[i].TwoPointShot > replyGetPlayerRank[j].TwoPointShot
}) })
for k, v := range replyGetPlayerRank { for k, v := range replyGetPlayerRank {
if v.PlayerId == playerId { if v.TeamId == playerId {
scoring.TwoPointShot = strconv.Itoa(k + 1) scoring.TwoPointShot = strconv.Itoa(k + 1)
} }
} }
...@@ -302,7 +306,7 @@ func (e *OrgTeamTeam) rankingThreePointShot(replyGetPlayerRank []models.OrgMatch ...@@ -302,7 +306,7 @@ func (e *OrgTeamTeam) rankingThreePointShot(replyGetPlayerRank []models.OrgMatch
return replyGetPlayerRank[i].ThreePointShot > replyGetPlayerRank[j].ThreePointShot return replyGetPlayerRank[i].ThreePointShot > replyGetPlayerRank[j].ThreePointShot
}) })
for k, v := range replyGetPlayerRank { for k, v := range replyGetPlayerRank {
if v.PlayerId == playerId { if v.TeamId == playerId {
scoring.ThreePointShot = strconv.Itoa(k + 1) scoring.ThreePointShot = strconv.Itoa(k + 1)
} }
} }
...@@ -310,7 +314,7 @@ func (e *OrgTeamTeam) rankingThreePointShot(replyGetPlayerRank []models.OrgMatch ...@@ -310,7 +314,7 @@ func (e *OrgTeamTeam) rankingThreePointShot(replyGetPlayerRank []models.OrgMatch
func (e *OrgTeamTeam) statisticsRanking(seasonId string, data *[]models.OrgMatchTeamPlayer) error { func (e *OrgTeamTeam) statisticsRanking(seasonId string, data *[]models.OrgMatchTeamPlayer) error {
var err error var err error
field := "team_id," + field := "omtp.team_id," +
"sum(omtp.scoring)as scoring," + "sum(omtp.scoring)as scoring," +
"sum(omtp.rebound)as rebound," + "sum(omtp.rebound)as rebound," +
"sum(omtp.assist)as assist," + "sum(omtp.assist)as assist," +
...@@ -324,7 +328,7 @@ func (e *OrgTeamTeam) statisticsRanking(seasonId string, data *[]models.OrgMatch ...@@ -324,7 +328,7 @@ func (e *OrgTeamTeam) statisticsRanking(seasonId string, data *[]models.OrgMatch
Select(field). Select(field).
Joins("left join org_match as om on omtp.match_id = om.id and omtp.rounds = om.rounds"). Joins("left join org_match as om on omtp.match_id = om.id and omtp.rounds = om.rounds").
Where("om.season_id = ?", seasonId). Where("om.season_id = ?", seasonId).
Group("team_id"). Group("omtp.team_id").
Find(&data).Error Find(&data).Error
if err != nil { if err != nil {
......
...@@ -33,6 +33,7 @@ func (e *OrgTeamUser) GetPage(c *dto.OrgTeamUserGetPageReq, p *actions.DataPermi ...@@ -33,6 +33,7 @@ func (e *OrgTeamUser) GetPage(c *dto.OrgTeamUserGetPageReq, p *actions.DataPermi
cDto.MakeCondition(c.GetNeedSearch()), cDto.MakeCondition(c.GetNeedSearch()),
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
actions.Permission(data.TableName(), p), actions.Permission(data.TableName(), p),
cDto.PassDel("otu"),
). ).
Find(list).Limit(-1).Offset(-1). Find(list).Limit(-1).Offset(-1).
Count(count).Error Count(count).Error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment