Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nbya
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoyanbin
nbya
Commits
bef2d9de
Commit
bef2d9de
authored
Jan 05, 2022
by
haoyanbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
排名
parent
99c6f5ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
25 deletions
+136
-25
org_match_evaluate.go
app/operate/apis/org_match_evaluate.go
+7
-7
org_match_evaluate.go
app/operate/service/org_match_evaluate.go
+129
-18
No files found.
app/operate/apis/org_match_evaluate.go
View file @
bef2d9de
...
@@ -89,13 +89,13 @@ func (e OrgMatchEvaluate) GetPageMatch(c *gin.Context) {
...
@@ -89,13 +89,13 @@ func (e OrgMatchEvaluate) GetPageMatch(c *gin.Context) {
}
}
reply
.
MatchInfo
=
*
replyGetMatchInfo
reply
.
MatchInfo
=
*
replyGetMatchInfo
replyGetRoundsScoring
:=
make
([]
cDto
.
RoundsScoring
,
0
)
//
replyGetRoundsScoring := make([]cDto.RoundsScoring, 0)
err
=
s
.
GetRoundsScoring
(
replyGetMatchInfo
.
PlayerId
,
replyGetMatchInfo
.
Rounds
,
&
replyGetRoundsScoring
)
//
err = s.GetRoundsScoring(replyGetMatchInfo.PlayerId, replyGetMatchInfo.Rounds, &replyGetRoundsScoring)
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
.
RoundsScoring
=
replyGetRoundsScoring
//
reply.RoundsScoring = replyGetRoundsScoring
replyGetTotalScoring
:=
make
([]
cDto
.
TotalScoring
,
0
)
replyGetTotalScoring
:=
make
([]
cDto
.
TotalScoring
,
0
)
...
...
app/operate/service/org_match_evaluate.go
View file @
bef2d9de
...
@@ -5,6 +5,8 @@ import (
...
@@ -5,6 +5,8 @@ import (
"github.com/go-admin-team/go-admin-core/sdk/service"
"github.com/go-admin-team/go-admin-core/sdk/service"
cDto
"go-admin/common/dto"
cDto
"go-admin/common/dto"
"gorm.io/gorm"
"gorm.io/gorm"
"sort"
"strconv"
"go-admin/app/operate/models"
"go-admin/app/operate/models"
"go-admin/app/operate/service/dto"
"go-admin/app/operate/service/dto"
...
@@ -156,41 +158,150 @@ func (e *OrgMatchEvaluate) GetTotalScoring(playerId string, rounds string, seaso
...
@@ -156,41 +158,150 @@ func (e *OrgMatchEvaluate) GetTotalScoring(playerId string, rounds string, seaso
e
.
statisticsScoring
(
playerId
,
rounds
,
seasonId
,
"avg"
,
replyGetTotalScoring4
)
e
.
statisticsScoring
(
playerId
,
rounds
,
seasonId
,
"avg"
,
replyGetTotalScoring4
)
*
data
=
append
(
*
data
,
*
replyGetTotalScoring4
)
*
data
=
append
(
*
data
,
*
replyGetTotalScoring4
)
//
replyGetTotalScoring5 := new(cDto.TotalScoring)
replyGetTotalScoring5
:=
new
(
cDto
.
TotalScoring
)
//
e.statisticsRankingList(playerId, seasonId, replyGetTotalScoring5)
e
.
statisticsRankingList
(
playerId
,
seasonId
,
replyGetTotalScoring5
)
//
*data = append(*data, *replyGetTotalScoring5)
*
data
=
append
(
*
data
,
*
replyGetTotalScoring5
)
return
nil
return
nil
}
}
func
(
e
*
OrgMatchEvaluate
)
statisticsRankingList
(
playerId
string
,
seasonId
string
,
scoring
*
cDto
.
TotalScoring
)
error
{
func
(
e
*
OrgMatchEvaluate
)
statisticsRankingList
(
playerId
string
,
seasonId
string
,
scoring
*
cDto
.
TotalScoring
)
error
{
scoring
.
Scoring
=
e
.
statisticsRanking
(
playerId
,
seasonId
,
"scoring"
)
replyGetPlayerRank
:=
make
([]
models
.
OrgMatchTeamPlayer
,
0
)
scoring
.
Scoring
=
e
.
statisticsRanking
(
playerId
,
seasonId
,
"scoring"
)
err
:=
e
.
statisticsRanking
(
playerId
,
seasonId
,
&
replyGetPlayerRank
)
scoring
.
Scoring
=
e
.
statisticsRanking
(
playerId
,
seasonId
,
"scoring"
)
if
err
!=
nil
{
e
.
Log
.
Errorf
(
"OrgMatchService GetTotalScoring error:%s
\r\n
"
,
err
)
return
err
}
e
.
rankingScoring
(
replyGetPlayerRank
,
playerId
,
scoring
)
e
.
rankingRebound
(
replyGetPlayerRank
,
playerId
,
scoring
)
e
.
rankingAssist
(
replyGetPlayerRank
,
playerId
,
scoring
)
e
.
rankingSteal
(
replyGetPlayerRank
,
playerId
,
scoring
)
e
.
rankingFreeThrow
(
replyGetPlayerRank
,
playerId
,
scoring
)
e
.
rankingBlockShot
(
replyGetPlayerRank
,
playerId
,
scoring
)
e
.
rankingFoul
(
replyGetPlayerRank
,
playerId
,
scoring
)
e
.
rankingTwoPointShot
(
replyGetPlayerRank
,
playerId
,
scoring
)
e
.
rankingThreePointShot
(
replyGetPlayerRank
,
playerId
,
scoring
)
return
nil
return
nil
}
}
func
(
e
*
OrgMatchEvaluate
)
statisticsRanking
(
playerId
string
,
seasonId
string
,
queryV
string
)
string
{
func
(
e
*
OrgMatchEvaluate
)
rankingScoring
(
replyGetPlayerRank
[]
models
.
OrgMatchTeamPlayer
,
playerId
string
,
scoring
*
cDto
.
TotalScoring
)
{
var
err
error
sort
.
Slice
(
replyGetPlayerRank
,
func
(
i
,
j
int
)
bool
{
field
:=
"(@rowNum:=@rowNum+1) AS rank, sum(omtp."
+
queryV
+
")as "
+
queryV
return
replyGetPlayerRank
[
i
]
.
Scoring
>
replyGetPlayerRank
[
j
]
.
Scoring
})
var
rankData
struct
{
for
k
,
v
:=
range
replyGetPlayerRank
{
rank
string
if
v
.
PlayerId
==
playerId
{
scoring
.
Scoring
=
strconv
.
Itoa
(
k
+
1
)
}
}
}
func
(
e
*
OrgMatchEvaluate
)
rankingRebound
(
replyGetPlayerRank
[]
models
.
OrgMatchTeamPlayer
,
playerId
string
,
scoring
*
cDto
.
TotalScoring
)
{
sort
.
Slice
(
replyGetPlayerRank
,
func
(
i
,
j
int
)
bool
{
return
replyGetPlayerRank
[
i
]
.
Rebound
>
replyGetPlayerRank
[
j
]
.
Rebound
})
for
k
,
v
:=
range
replyGetPlayerRank
{
if
v
.
PlayerId
==
playerId
{
scoring
.
Rebound
=
strconv
.
Itoa
(
k
+
1
)
}
}
}
func
(
e
*
OrgMatchEvaluate
)
rankingAssist
(
replyGetPlayerRank
[]
models
.
OrgMatchTeamPlayer
,
playerId
string
,
scoring
*
cDto
.
TotalScoring
)
{
sort
.
Slice
(
replyGetPlayerRank
,
func
(
i
,
j
int
)
bool
{
return
replyGetPlayerRank
[
i
]
.
Assist
>
replyGetPlayerRank
[
j
]
.
Assist
})
for
k
,
v
:=
range
replyGetPlayerRank
{
if
v
.
PlayerId
==
playerId
{
scoring
.
Assist
=
strconv
.
Itoa
(
k
+
1
)
}
}
}
func
(
e
*
OrgMatchEvaluate
)
rankingSteal
(
replyGetPlayerRank
[]
models
.
OrgMatchTeamPlayer
,
playerId
string
,
scoring
*
cDto
.
TotalScoring
)
{
sort
.
Slice
(
replyGetPlayerRank
,
func
(
i
,
j
int
)
bool
{
return
replyGetPlayerRank
[
i
]
.
Steal
>
replyGetPlayerRank
[
j
]
.
Steal
})
for
k
,
v
:=
range
replyGetPlayerRank
{
if
v
.
PlayerId
==
playerId
{
scoring
.
Steal
=
strconv
.
Itoa
(
k
+
1
)
}
}
}
func
(
e
*
OrgMatchEvaluate
)
rankingFreeThrow
(
replyGetPlayerRank
[]
models
.
OrgMatchTeamPlayer
,
playerId
string
,
scoring
*
cDto
.
TotalScoring
)
{
sort
.
Slice
(
replyGetPlayerRank
,
func
(
i
,
j
int
)
bool
{
return
replyGetPlayerRank
[
i
]
.
FreeThrow
>
replyGetPlayerRank
[
j
]
.
FreeThrow
})
for
k
,
v
:=
range
replyGetPlayerRank
{
if
v
.
PlayerId
==
playerId
{
scoring
.
FreeThrow
=
strconv
.
Itoa
(
k
+
1
)
}
}
}
e
.
Orm
.
Table
(
"org_match_team_player as omtp"
)
.
}
func
(
e
*
OrgMatchEvaluate
)
rankingBlockShot
(
replyGetPlayerRank
[]
models
.
OrgMatchTeamPlayer
,
playerId
string
,
scoring
*
cDto
.
TotalScoring
)
{
sort
.
Slice
(
replyGetPlayerRank
,
func
(
i
,
j
int
)
bool
{
return
replyGetPlayerRank
[
i
]
.
BlockShot
>
replyGetPlayerRank
[
j
]
.
BlockShot
})
for
k
,
v
:=
range
replyGetPlayerRank
{
if
v
.
PlayerId
==
playerId
{
scoring
.
BlockShot
=
strconv
.
Itoa
(
k
+
1
)
}
}
}
func
(
e
*
OrgMatchEvaluate
)
rankingFoul
(
replyGetPlayerRank
[]
models
.
OrgMatchTeamPlayer
,
playerId
string
,
scoring
*
cDto
.
TotalScoring
)
{
sort
.
Slice
(
replyGetPlayerRank
,
func
(
i
,
j
int
)
bool
{
return
replyGetPlayerRank
[
i
]
.
Foul
>
replyGetPlayerRank
[
j
]
.
Foul
})
for
k
,
v
:=
range
replyGetPlayerRank
{
if
v
.
PlayerId
==
playerId
{
scoring
.
Foul
=
strconv
.
Itoa
(
k
+
1
)
}
}
}
func
(
e
*
OrgMatchEvaluate
)
rankingTwoPointShot
(
replyGetPlayerRank
[]
models
.
OrgMatchTeamPlayer
,
playerId
string
,
scoring
*
cDto
.
TotalScoring
)
{
sort
.
Slice
(
replyGetPlayerRank
,
func
(
i
,
j
int
)
bool
{
return
replyGetPlayerRank
[
i
]
.
TwoPointShot
>
replyGetPlayerRank
[
j
]
.
TwoPointShot
})
for
k
,
v
:=
range
replyGetPlayerRank
{
if
v
.
PlayerId
==
playerId
{
scoring
.
TwoPointShot
=
strconv
.
Itoa
(
k
+
1
)
}
}
}
func
(
e
*
OrgMatchEvaluate
)
rankingThreePointShot
(
replyGetPlayerRank
[]
models
.
OrgMatchTeamPlayer
,
playerId
string
,
scoring
*
cDto
.
TotalScoring
)
{
sort
.
Slice
(
replyGetPlayerRank
,
func
(
i
,
j
int
)
bool
{
return
replyGetPlayerRank
[
i
]
.
ThreePointShot
>
replyGetPlayerRank
[
j
]
.
ThreePointShot
})
for
k
,
v
:=
range
replyGetPlayerRank
{
if
v
.
PlayerId
==
playerId
{
scoring
.
ThreePointShot
=
strconv
.
Itoa
(
k
+
1
)
}
}
}
func
(
e
*
OrgMatchEvaluate
)
statisticsRanking
(
playerId
string
,
seasonId
string
,
data
*
[]
models
.
OrgMatchTeamPlayer
)
error
{
var
err
error
field
:=
"player_id,"
+
"sum(omtp.scoring)as scoring,"
+
"sum(omtp.rebound)as rebound,"
+
"sum(omtp.assist)as assist,"
+
"sum(omtp.steal)as steal,"
+
"sum(omtp.free_throw)as free_throw,"
+
"sum(omtp.block_shot)as block_shot,"
+
"sum(omtp.foul)as foul,"
+
"sum(omtp.two_point_shot)as two_point_shot,"
+
"sum(omtp.three_point_shot)as three_point_shot"
err
=
e
.
Orm
.
Table
(
"org_match_team_player as omtp"
)
.
Select
(
field
)
.
Select
(
field
)
.
Joins
(
"left join org_match as om on omtp.match_id = om.id"
)
.
Joins
(
"left join org_match as om on omtp.match_id = om.id"
)
.
Where
(
"omtp.player_id = ?"
,
playerId
)
.
Where
(
"om.season_id = ?"
,
seasonId
)
.
Where
(
"om.season_id = ?"
,
seasonId
)
.
Order
(
queryV
+
" DESC"
)
Order
(
"player_id asc"
)
.
err
=
e
.
Orm
.
First
(
&
rankData
)
.
Error
Group
(
"player_id"
)
.
Find
(
&
data
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
e
.
Log
.
Errorf
(
"OrgMatchService GetTotalScoring error:%s
\r\n
"
,
err
)
e
.
Log
.
Errorf
(
"OrgMatchService GetTotalScoring error:%s
\r\n
"
,
err
)
return
"0"
return
err
}
}
return
rankData
.
rank
return
nil
}
}
// Get 获取OrgMatchEvaluate对象
// Get 获取OrgMatchEvaluate对象
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment