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
99c6f5ec
Commit
99c6f5ec
authored
Jan 04, 2022
by
haoyanbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
4691a15e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
242 additions
and
33 deletions
+242
-33
org_match_evaluate.go
app/operate/apis/org_match_evaluate.go
+28
-5
org_match_evaluate.go
app/operate/router/org_match_evaluate.go
+1
-1
org_match_evaluate.go
app/operate/service/dto/org_match_evaluate.go
+13
-4
org_match_evaluate.go
app/operate/service/org_match_evaluate.go
+153
-23
match.go
common/dto/match.go
+47
-0
No files found.
app/operate/apis/org_match_evaluate.go
View file @
99c6f5ec
...
...
@@ -2,6 +2,7 @@ package apis
import
(
"fmt"
cDto
"go-admin/common/dto"
"github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/sdk/api"
...
...
@@ -64,7 +65,7 @@ func (e OrgMatchEvaluate) GetPage(c *gin.Context) {
// @Router /api/v1/org-match-evaluate/get-match [get]
// @Security Bearer
func
(
e
OrgMatchEvaluate
)
GetPageMatch
(
c
*
gin
.
Context
)
{
req
:=
dto
.
OrgMatchEvaluateGetPage
Req
{}
req
:=
dto
.
GetPageMatch
Req
{}
s
:=
service
.
OrgMatchEvaluate
{}
err
:=
e
.
MakeContext
(
c
)
.
MakeOrm
()
.
...
...
@@ -78,16 +79,38 @@ func (e OrgMatchEvaluate) GetPageMatch(c *gin.Context) {
}
p
:=
actions
.
GetPermissionFromContext
(
c
)
list
:=
make
([]
dto
.
OrgMatchEvaluateGetPageReply
,
0
)
var
count
int64
reply
:=
new
(
dto
.
GetPageMatchReply
)
err
=
s
.
GetPage
(
&
req
,
p
,
&
list
,
&
count
)
replyGetMatchInfo
:=
new
(
cDto
.
PageMatchInfo
)
err
=
s
.
GetMatchInfo
(
req
.
Id
,
p
,
replyGetMatchInfo
)
if
err
!=
nil
{
e
.
Error
(
500
,
err
,
fmt
.
Sprintf
(
"获取比赛球员信息 失败,
\r\n
失败信息 %s"
,
err
.
Error
()))
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
)
//replyGetTotalScoring1 := new(cDto.TotalScoring)
//s.StatisticsScoring(replyGetMatchInfo.PlayerId, replyGetMatchInfo.Rounds, "0", "sum", replyGetTotalScoring1)
//replyGetTotalScoring = append(replyGetTotalScoring, *replyGetTotalScoring1)
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 <赛事>赛后评价比赛详情
...
...
app/operate/router/org_match_evaluate.go
View file @
99c6f5ec
...
...
@@ -23,4 +23,4 @@ func registerOrgMatchEvaluateRouter(v1 *gin.RouterGroup, authMiddleware *jwt.Gin
r
.
PUT
(
"/:id"
,
api
.
Update
)
r
.
PUT
(
"/status/:id"
,
api
.
Status
)
}
}
\ No newline at end of file
}
app/operate/service/dto/org_match_evaluate.go
View file @
99c6f5ec
...
...
@@ -26,10 +26,19 @@ type OrgMatchEvaluateGetPageReply struct {
SeasonName
string
`json:"seasonName"`
Rounds
string
`json:"rounds"`
PlayerName
string
`json:"playerName"`
MatchStartTime
time
.
Time
`form:"matchStartTimeOrder" search:"type:order;column:match_start_time;table:org_match"`
MatchEndTime
time
.
Time
`form:"matchEndTimeOrder" search:"type:order;column:match_end_time;table:org_match"`
MvStatus
string
`json:"mvStatus" gorm:"type:bigint(20);comment:视频维护状态 1 待维护 2 维护完成 3 驳回 4 维护完成"`
Status
string
`json:"status" gorm:"type:bigint(20);comment:发布状态 1 待审核 3 驳回 4 发布完成"`
MatchStartTime
time
.
Time
`json:"matchStartTimeOrder"`
MatchEndTime
time
.
Time
`json:"matchEndTimeOrder"`
MvStatus
string
`json:"mvStatus"`
Status
string
`json:"status"`
}
type
GetPageMatchReq
struct
{
Id
string
`form:"id" json:"id"`
}
type
GetPageMatchReply
struct
{
MatchInfo
dto
.
PageMatchInfo
`json:"matchInfo"`
TotalScoring
[]
dto
.
TotalScoring
`json:"totalScoring"`
RoundsScoring
[]
dto
.
RoundsScoring
`json:"roundsScoring"`
}
//ol.league_name, od.division_name, os.season_name, om.rounds, omtp.player_name, om.match_start_time, om.match_end_time, ome.mv_status, ome.status, ome.remark
...
...
app/operate/service/org_match_evaluate.go
View file @
99c6f5ec
...
...
@@ -15,29 +15,6 @@ type OrgMatchEvaluate struct {
service
.
Service
}
func
CreateSearch
(
key
string
,
act
string
,
value
string
)
func
(
db
*
gorm
.
DB
)
*
gorm
.
DB
{
return
func
(
db
*
gorm
.
DB
)
*
gorm
.
DB
{
if
value
!=
""
{
switch
act
{
case
"="
:
return
db
.
Where
(
key
+
" = ?"
,
value
)
case
"like"
:
return
db
.
Where
(
key
+
" like '%?%'"
,
value
)
case
">"
:
return
db
.
Where
(
key
+
" > ?"
,
value
)
case
"<"
:
return
db
.
Where
(
key
+
" > ?"
,
value
)
case
"<>"
:
return
db
.
Where
(
key
+
" <> ?"
,
value
)
default
:
return
db
}
}
else
{
return
db
}
}
}
// GetPage 获取OrgMatchEvaluate列表
func
(
e
*
OrgMatchEvaluate
)
GetPage
(
c
*
dto
.
OrgMatchEvaluateGetPageReq
,
p
*
actions
.
DataPermission
,
list
*
[]
dto
.
OrgMatchEvaluateGetPageReply
,
count
*
int64
)
error
{
var
err
error
...
...
@@ -63,6 +40,159 @@ func (e *OrgMatchEvaluate) GetPage(c *dto.OrgMatchEvaluateGetPageReq, p *actions
return
nil
}
// GetPage 获取OrgMatchEvaluate列表
func
(
e
*
OrgMatchEvaluate
)
GetMatchInfo
(
id
string
,
p
*
actions
.
DataPermission
,
data
*
cDto
.
PageMatchInfo
)
error
{
var
err
error
err
=
e
.
Orm
.
Table
(
"org_match_team_player as omtp"
)
.
Select
(
"omtp.id, ol.league_name, od.division_name, os.season_name, om.rounds,"
+
"oc.club_name, ot.team_name, omtp.player_name, omtp.player_number, omtp.position,"
+
"ome.wonderful_moment_img, ome.wonderful_moment_mv,ome.wonderful_moment_img_title,"
+
"ome.wonderful_moment_mv_title, omtp.player_id, om.season_id"
)
.
Joins
(
"left join org_match_evaluate as ome on omtp.player_id = ome.player_id"
)
.
Joins
(
"left join org_club as oc on omtp.club_id = oc.id"
)
.
Joins
(
"left join org_team as ot on omtp.team_id = ot.id"
)
.
Joins
(
"left join org_match as om on omtp.match_id = om.id"
)
.
Joins
(
"left join org_league as ol on ol.id = om.league_id"
)
.
Joins
(
"left join org_division as od on od.id = om.division_id"
)
.
Joins
(
"left join org_season as os on os.id = om.season_id"
)
.
Scopes
(
actions
.
Permission
(
"omtp"
,
p
),
)
.
First
(
data
,
id
)
.
Error
if
err
!=
nil
{
e
.
Log
.
Errorf
(
"OrgMatchService GetMatchInfo error:%s
\r\n
"
,
err
)
return
err
}
return
nil
}
func
(
e
*
OrgMatchEvaluate
)
GetRoundsScoring
(
playerId
string
,
rounds
string
,
data
*
[]
cDto
.
RoundsScoring
)
error
{
var
err
error
err
=
e
.
Orm
.
Table
(
"org_match_team_player as omtp"
)
.
Select
(
"omtp.id, om.match_start_time, om.rounds, om.grouping, ot.team_name as other_team, "
+
"omtp.scoring, omtp.scoring, omtp.rebound, omtp.assist, omtp.steal, omtp.free_throw, "
+
"omtp.block_shot, omtp.foul, omtp.two_point_shot, omtp.three_point_shot"
)
.
Joins
(
"left join org_match as om on omtp.match_id = om.id"
)
.
Joins
(
"left join org_team as ot on omtp.other_team_id = ot.id"
)
.
Where
(
"omtp.player_id = ?"
,
playerId
)
.
Where
(
"omtp.rounds = ?"
,
rounds
)
.
Find
(
data
)
.
Error
if
err
!=
nil
{
e
.
Log
.
Errorf
(
"OrgMatchService GetRoundsScoring error:%s
\r\n
"
,
err
)
return
err
}
return
nil
}
func
(
e
*
OrgMatchEvaluate
)
statisticsScoring
(
playerId
string
,
rounds
string
,
seasonId
string
,
statistics
string
,
data
*
cDto
.
TotalScoring
)
error
{
var
err
error
field
:=
""
if
statistics
==
"sum"
{
field
+=
"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"
}
if
statistics
==
"avg"
{
field
+=
"avg(omtp.scoring)as scoring,"
+
"avg(omtp.rebound)as rebound,"
+
"avg(omtp.assist)as assist,"
+
"avg(omtp.steal)as steal,"
+
"avg(omtp.free_throw)as free_throw,"
+
"avg(omtp.block_shot)as block_shot,"
+
"avg(omtp.foul)as foul,"
+
"avg(omtp.two_point_shot)as two_point_shot,"
+
"avg(omtp.three_point_shot)as three_point_shot"
}
err
=
e
.
Orm
.
Table
(
"org_match_team_player as omtp"
)
.
Joins
(
"left join org_match as om on omtp.match_id = om.id"
)
.
Select
(
field
)
.
Where
(
"omtp.player_id = ?"
,
playerId
)
.
Where
(
"omtp.rounds = ?"
,
rounds
)
.
Scopes
(
seasonIdWhere
(
"om"
,
seasonId
))
.
First
(
data
)
.
Error
if
err
!=
nil
{
e
.
Log
.
Errorf
(
"OrgMatchService GetTotalScoring error:%s
\r\n
"
,
err
)
return
err
}
return
nil
}
func
seasonIdWhere
(
tableName
string
,
seasonId
string
)
func
(
db
*
gorm
.
DB
)
*
gorm
.
DB
{
return
func
(
db
*
gorm
.
DB
)
*
gorm
.
DB
{
if
seasonId
==
"0"
{
return
db
}
return
db
.
Where
(
tableName
+
".season_id = ?"
,
seasonId
)
}
}
// Get 获取OrgMatchEvaluate对象
func
(
e
*
OrgMatchEvaluate
)
GetTotalScoring
(
playerId
string
,
rounds
string
,
seasonId
string
,
data
*
[]
cDto
.
TotalScoring
)
error
{
replyGetTotalScoring1
:=
new
(
cDto
.
TotalScoring
)
e
.
statisticsScoring
(
playerId
,
rounds
,
"0"
,
"sum"
,
replyGetTotalScoring1
)
*
data
=
append
(
*
data
,
*
replyGetTotalScoring1
)
replyGetTotalScoring2
:=
new
(
cDto
.
TotalScoring
)
e
.
statisticsScoring
(
playerId
,
rounds
,
"0"
,
"avg"
,
replyGetTotalScoring2
)
*
data
=
append
(
*
data
,
*
replyGetTotalScoring2
)
replyGetTotalScoring3
:=
new
(
cDto
.
TotalScoring
)
e
.
statisticsScoring
(
playerId
,
rounds
,
seasonId
,
"sum"
,
replyGetTotalScoring3
)
*
data
=
append
(
*
data
,
*
replyGetTotalScoring3
)
replyGetTotalScoring4
:=
new
(
cDto
.
TotalScoring
)
e
.
statisticsScoring
(
playerId
,
rounds
,
seasonId
,
"avg"
,
replyGetTotalScoring4
)
*
data
=
append
(
*
data
,
*
replyGetTotalScoring4
)
//replyGetTotalScoring5 := new(cDto.TotalScoring)
//e.statisticsRankingList(playerId, seasonId, replyGetTotalScoring5)
//*data = append(*data, *replyGetTotalScoring5)
return
nil
}
func
(
e
*
OrgMatchEvaluate
)
statisticsRankingList
(
playerId
string
,
seasonId
string
,
scoring
*
cDto
.
TotalScoring
)
error
{
scoring
.
Scoring
=
e
.
statisticsRanking
(
playerId
,
seasonId
,
"scoring"
)
scoring
.
Scoring
=
e
.
statisticsRanking
(
playerId
,
seasonId
,
"scoring"
)
scoring
.
Scoring
=
e
.
statisticsRanking
(
playerId
,
seasonId
,
"scoring"
)
return
nil
}
func
(
e
*
OrgMatchEvaluate
)
statisticsRanking
(
playerId
string
,
seasonId
string
,
queryV
string
)
string
{
var
err
error
field
:=
"(@rowNum:=@rowNum+1) AS rank, sum(omtp."
+
queryV
+
")as "
+
queryV
var
rankData
struct
{
rank
string
}
e
.
Orm
.
Table
(
"org_match_team_player as omtp"
)
.
Select
(
field
)
.
Joins
(
"left join org_match as om on omtp.match_id = om.id"
)
.
Where
(
"omtp.player_id = ?"
,
playerId
)
.
Where
(
"om.season_id = ?"
,
seasonId
)
.
Order
(
queryV
+
" DESC"
)
err
=
e
.
Orm
.
First
(
&
rankData
)
.
Error
if
err
!=
nil
{
e
.
Log
.
Errorf
(
"OrgMatchService GetTotalScoring error:%s
\r\n
"
,
err
)
return
"0"
}
return
rankData
.
rank
}
// Get 获取OrgMatchEvaluate对象
func
(
e
*
OrgMatchEvaluate
)
Get
(
d
*
dto
.
OrgMatchEvaluateGetReq
,
p
*
actions
.
DataPermission
,
model
*
models
.
OrgMatchEvaluate
)
error
{
var
data
models
.
OrgMatchEvaluate
...
...
common/dto/match.go
0 → 100644
View file @
99c6f5ec
package
dto
type
PageMatchInfo
struct
{
Id
string
`json:"id"`
LeagueName
string
`json:"leagueName"`
DivisionName
string
`json:"divisionName"`
SeasonId
string
`json:"seasonId"`
SeasonName
string
`json:"seasonName"`
Rounds
string
`json:"rounds"`
ClubName
string
`json:"clubName"`
TeamName
string
`json:"teamName"`
PlayerId
string
`json:"playerId"`
PlayerName
string
`json:"playerName"`
PlayerNumber
string
`json:"playerNumber"`
Position
string
`json:"position"`
WonderfulMomentImg
string
`json:"wonderfulMomentImg" comment:"精彩时刻图"`
WonderfulMomentMv
string
`json:"wonderfulMomentMv" comment:"精彩时刻视频"`
WonderfulMomentImgTitle
string
`json:"wonderfulMomentImgTitle" comment:"精彩时刻图标题"`
WonderfulMomentMvTitle
string
`json:"wonderfulMomentMvTitle" comment:"精彩时刻视频标题"`
}
type
TotalScoring
struct
{
Scoring
string
`json:"scoring" comment:"得分"`
Rebound
string
`json:"rebound" comment:"篮板"`
Assist
string
`json:"assist" comment:"助攻"`
Steal
string
`json:"steal" comment:"抢断"`
FreeThrow
string
`json:"freeThrow" comment:"罚球"`
BlockShot
string
`json:"blockShot" comment:"盖帽"`
Foul
string
`json:"foul" comment:"犯规"`
TwoPointShot
string
`json:"twoPointShot" comment:"2分进球数量"`
ThreePointShot
string
`json:"threePointShot" comment:"3分进球数量"`
}
type
RoundsScoring
struct
{
Rounds
string
`json:"rounds" comment:"轮次"`
Grouping
string
`json:"grouping" comment:"分组"`
OtherTeam
string
`json:"otherTeam" comment:"对方球队"`
Scoring
string
`json:"scoring" comment:"得分"`
Rebound
string
`json:"rebound" comment:"篮板"`
Assist
string
`json:"assist" comment:"助攻"`
Steal
string
`json:"steal" comment:"抢断"`
FreeThrow
string
`json:"freeThrow" comment:"罚球"`
BlockShot
string
`json:"blockShot" comment:"盖帽"`
Foul
string
`json:"foul" comment:"犯规"`
TwoPointShot
string
`json:"twoPointShot" comment:"2分进球数量"`
ThreePointShot
string
`json:"threePointShot" comment:"3分进球数量"`
}
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