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
684c36b5
Commit
684c36b5
authored
Jan 26, 2022
by
haoyanbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
5c583e9d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
7 deletions
+38
-7
org_player.go
app/mobile/apis/org_player.go
+11
-3
org_player.go
app/mobile/service/dto/org_player.go
+18
-0
org_player.go
app/mobile/service/org_player.go
+5
-2
common.go
common/utils/common.go
+4
-2
No files found.
app/mobile/apis/org_player.go
View file @
684c36b5
...
@@ -165,13 +165,21 @@ func (e OrgPlayer) GetInfo(c *gin.Context) {
...
@@ -165,13 +165,21 @@ func (e OrgPlayer) GetInfo(c *gin.Context) {
reply
:=
new
(
dto
.
OrgPlayerGetInfoReply
)
reply
:=
new
(
dto
.
OrgPlayerGetInfoReply
)
reply
.
OrgPlayerInfo
=
object
reply
.
OrgPlayerInfo
=
object
reply
OrgMatchInfo
:=
new
(
dto
.
OrgMatchInfo
)
reply
DataAvg
:=
dto
.
OrgMatchInfo
{}
err
=
s
.
StatisticsScoringAvg
(
strconv
.
Itoa
(
req
.
PlayerId
),
seasonId
,
"avg"
,
replyOrgMatchInfo
)
err
=
s
.
StatisticsScoringAvg
(
""
,
seasonId
,
"avg"
,
&
replyDataAvg
)
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
.
OrgMatchInfo
=
*
replyOrgMatchInfo
reply
.
DataAvg
=
replyDataAvg
replyOrgMatchInfo
:=
dto
.
OrgMatchInfo
{}
err
=
s
.
StatisticsScoringAvg
(
strconv
.
Itoa
(
req
.
PlayerId
),
seasonId
,
"avg"
,
&
replyOrgMatchInfo
)
if
err
!=
nil
{
e
.
Error
(
500
,
err
,
fmt
.
Sprintf
(
"获取比赛球员信息 失败,
\r\n
失败信息 %s"
,
err
.
Error
()))
return
}
reply
.
OrgMatchInfo
=
replyOrgMatchInfo
err
,
matchId
:=
s
.
GetMatchId
(
strconv
.
Itoa
(
req
.
PlayerId
),
seasonId
)
err
,
matchId
:=
s
.
GetMatchId
(
strconv
.
Itoa
(
req
.
PlayerId
),
seasonId
)
var
count
int64
var
count
int64
...
...
app/mobile/service/dto/org_player.go
View file @
684c36b5
...
@@ -74,10 +74,28 @@ type OrgPlayerGetInfoReq struct {
...
@@ -74,10 +74,28 @@ type OrgPlayerGetInfoReq struct {
type
OrgPlayerGetInfoReply
struct
{
type
OrgPlayerGetInfoReply
struct
{
OrgPlayerInfo
OrgPlayerGetReply
`json:"orgPlayerInfo"`
OrgPlayerInfo
OrgPlayerGetReply
`json:"orgPlayerInfo"`
DataAvg
OrgMatchInfo
`json:"dataAvg"`
OrgMatchInfo
OrgMatchInfo
`json:"orgMatchInfo"`
OrgMatchInfo
OrgMatchInfo
`json:"orgMatchInfo"`
RoundsScoring
[]
OrgPlayerRoundsScoring
`json:"roundsScoring"`
RoundsScoring
[]
OrgPlayerRoundsScoring
`json:"roundsScoring"`
}
}
type
DataAvg
struct
{
//ScoringAvg string `json:"scoringAvg" comment:"得分"`
//ReboundAvg string `json:"reboundAvg" comment:"篮板"`
//AssistAvg string `json:"assistAvg" comment:"助攻"`
//StealAvg string `json:"stealAvg" comment:"抢断"`
//FreeThrowAvg string `json:"freeThrowAvg" comment:"罚球"`
//BlockShotAvg string `json:"blockShotAvg" comment:"盖帽"`
//FoulAvg string `json:"foulAvg" comment:"犯规"`
//TwoPointShotAvg string `json:"twoPointShotAvg" comment:"2分进球数量"`
//ThreePointShotAvg string `json:"threePointShotAvg" comment:"3分进球数量"`
Scoring
string
`json:"scoring" comment:"得分"`
Rebound
string
`json:"rebound" comment:"篮板"`
Assist
string
`json:"assist" comment:"助攻"`
Steal
string
`json:"steal" comment:"抢断"`
BlockShot
string
`json:"blockShot" comment:"盖帽"`
}
type
OrgMatchInfo
struct
{
type
OrgMatchInfo
struct
{
Id
string
`json:"id"`
Id
string
`json:"id"`
SeasonId
string
`json:"seasonId" comment:"赛季id"`
SeasonId
string
`json:"seasonId" comment:"赛季id"`
...
...
app/mobile/service/org_player.go
View file @
684c36b5
...
@@ -181,8 +181,8 @@ func (e *OrgPlayer) StatisticsScoringAvg(playerId string, seasonId string, stati
...
@@ -181,8 +181,8 @@ func (e *OrgPlayer) StatisticsScoringAvg(playerId string, seasonId string, stati
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"
)
.
Joins
(
"left join org_league as ol on ol.id = om.league_id"
)
.
Joins
(
"left join org_league as ol on ol.id = om.league_id"
)
.
Joins
(
"left join org_season as os on os.id = om.season_id"
)
.
Joins
(
"left join org_season as os on os.id = om.season_id"
)
.
Scopes
(
cDto
.
SetWhere
(
"omtp"
,
"player_id"
,
playerId
))
.
Where
(
"om.season_id = ?"
,
seasonId
)
.
Where
(
"om.season_id = ?"
,
seasonId
)
.
Where
(
"omtp.player_id = ?"
,
playerId
)
.
Group
(
"om.season_id"
)
.
Group
(
"om.season_id"
)
.
First
(
data
)
.
Error
First
(
data
)
.
Error
...
@@ -191,7 +191,10 @@ func (e *OrgPlayer) StatisticsScoringAvg(playerId string, seasonId string, stati
...
@@ -191,7 +191,10 @@ func (e *OrgPlayer) StatisticsScoringAvg(playerId string, seasonId string, stati
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"
)
.
Select
(
field
)
.
Select
(
field
)
.
Scopes
(
cDto
.
SetWhere
(
"om"
,
"season_id"
,
seasonId
))
.
Scopes
(
cDto
.
SetWhere
(
"om"
,
"season_id"
,
seasonId
),
cDto
.
SetWhere
(
"omtp"
,
"player_id"
,
playerId
),
)
.
Count
(
&
teamCount
)
.
Error
Count
(
&
teamCount
)
.
Error
data
.
Scoring
=
utils
.
GetAvg
(
data
.
Scoring
,
teamCount
)
data
.
Scoring
=
utils
.
GetAvg
(
data
.
Scoring
,
teamCount
)
...
...
common/utils/common.go
View file @
684c36b5
...
@@ -22,8 +22,10 @@ func StringToInt(data string) int {
...
@@ -22,8 +22,10 @@ func StringToInt(data string) int {
func
GetAvg
(
data
string
,
count
int64
)
string
{
func
GetAvg
(
data
string
,
count
int64
)
string
{
floatData
,
_
:=
strconv
.
ParseFloat
(
data
,
64
)
floatData
,
_
:=
strconv
.
ParseFloat
(
data
,
64
)
res
:=
fmt
.
Sprintf
(
"%.2f"
,
floatData
/
float64
(
count
))
return
strconv
.
FormatFloat
(
floatData
/
float64
(
count
),
'f'
,
2
,
64
)
return
res
//res := fmt.Sprintf("%.2f", floatData/float64(count))
//return res
}
}
func
StringToFloat
(
data
string
)
float64
{
func
StringToFloat
(
data
string
)
float64
{
...
...
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