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
1475ff59
Commit
1475ff59
authored
Jan 07, 2022
by
haoyanbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
赛事球员
parent
16f22790
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
191 additions
and
127 deletions
+191
-127
org_match.go
app/operate/apis/org_match.go
+32
-9
org_match_team_player.go
app/operate/models/org_match_team_player.go
+2
-4
org_match.go
app/operate/router/org_match.go
+1
-1
org_match_team_player.go
app/operate/service/dto/org_match_team_player.go
+16
-3
org_player.go
app/operate/service/dto/org_player.go
+75
-73
org_match_team_player.go
app/operate/service/org_match_team_player.go
+14
-10
org_player.go
app/operate/service/org_player.go
+27
-27
match.go
common/dto/match.go
+24
-0
No files found.
app/operate/apis/org_match.go
View file @
1475ff59
...
...
@@ -56,9 +56,9 @@ func (e OrgMatch) GetPage(c *gin.Context) {
e
.
PageOK
(
list
,
int
(
count
),
req
.
GetPageIndex
(),
req
.
GetPageSize
(),
"查询成功"
)
}
// Get <赛事>获取比赛
列表搜索数据
// @Summary <赛事>获取比赛
列表搜索数据
// @Description <赛事>获取比赛
列表搜索数据
// Get <赛事>获取比赛
附加数据(比赛详情,联赛,赛区,赛季,球队)
// @Summary <赛事>获取比赛
附加数据(比赛详情,联赛,赛区,赛季,球队)
// @Description <赛事>获取比赛
附加数据(比赛详情,联赛,赛区,赛季,球队)
// @Tags <赛事>比赛
// @Param id path string false "id"
// @Success 200 {string} string {data=models.OrgMatchGetInfoReq} "{"code": 200, "data": [...]}"
...
...
@@ -341,7 +341,7 @@ func (e OrgMatch) Delete(c *gin.Context) {
// @Tags <赛事>比赛
// @Param id path string false "id"
// @Success 200 {string} string {data=models.OrgMatch} "{"code": 200, "data": [...]}"
// @Router /api/v1/org-match/get-player
/{id}
[get]
// @Router /api/v1/org-match/get-player [get]
// @Security Bearer
func
(
e
OrgMatch
)
GetPlayer
(
c
*
gin
.
Context
)
{
req
:=
dto
.
OrgPlayerGetPageReq
{}
...
...
@@ -445,38 +445,45 @@ func (e OrgMatch) UpdatePlayer(c *gin.Context) {
}
p
:=
actions
.
GetPermissionFromContext
(
c
)
teamId
:=
""
for
_
,
v
:=
range
playersIds
{
orgPlayer
:=
new
(
models
.
OrgPlayer
)
id
,
_
:=
strconv
.
Atoi
(
v
)
reqOrgPlayer
:=
new
(
dto
.
OrgPlayerGetReq
)
reqOrgPlayer
.
Id
=
id
err
=
sOrgPlayer
.
Get
(
reqOrgPlayer
,
p
,
orgPlayer
)
_
=
sOrgPlayer
.
Get
(
reqOrgPlayer
,
p
,
orgPlayer
)
//if orgPlayer.Id == 0 {
// e.Error(500, err, "球员不存在")
// return
//}
if
err
!=
nil
{
teamId
=
orgPlayer
.
TeamId
err
,
playerId
:=
s
.
IsBeing
(
req
.
MatchId
,
req
.
Rounds
,
v
)
if
playerId
==
0
{
orgMatchPlayer
:=
dto
.
OrgMatchTeamPlayerInsertReq
{
MatchId
:
req
.
MatchId
,
Rounds
:
req
.
Rounds
,
ClubId
:
orgPlayer
.
ClubId
,
TeamId
:
orgPlayer
.
TeamId
,
OtherTeamId
:
req
.
OtherTeamId
,
PlayerId
:
v
,
PlayerName
:
orgPlayer
.
PlayerName
,
PlayerNumber
:
orgPlayer
.
PlayerNumber
,
Position
:
orgPlayer
.
Position
,
}
err
=
s
.
Insert
(
&
orgMatchPlayer
)
if
err
!=
nil
{
err
OrgMatchPlayer
:
=
s
.
Insert
(
&
orgMatchPlayer
)
if
err
OrgMatchPlayer
!=
nil
{
e
.
Error
(
500
,
err
,
fmt
.
Sprintf
(
"创建比赛球员数据 失败,
\r\n
失败信息 %s"
,
err
.
Error
()))
return
}
}
else
{
orgMatchPlayer
:=
dto
.
OrgMatchTeamPlayerUpdateReq
{
Id
:
playerId
,
MatchId
:
req
.
MatchId
,
Rounds
:
req
.
Rounds
,
ClubId
:
orgPlayer
.
ClubId
,
TeamId
:
orgPlayer
.
TeamId
,
OtherTeamId
:
req
.
OtherTeamId
,
PlayerId
:
v
,
PlayerName
:
orgPlayer
.
PlayerName
,
PlayerNumber
:
orgPlayer
.
PlayerNumber
,
...
...
@@ -490,6 +497,22 @@ func (e OrgMatch) UpdatePlayer(c *gin.Context) {
}
}
reqRemovePlayers
:=
new
(
dto
.
OrgMatchTeamPlayerDeleteReq
)
reqRemovePlayers
.
MatchId
=
req
.
MatchId
reqRemovePlayers
.
Rounds
=
req
.
Rounds
reqRemovePlayers
.
TeamId
=
teamId
delPlayerIds
:=
""
for
_
,
v
:=
range
playersIds
{
delPlayerIds
+=
"'"
+
v
+
"',"
}
delPlayerIds
=
strings
.
Trim
(
delPlayerIds
,
","
)
reqRemovePlayers
.
Ids
=
delPlayerIds
err
=
s
.
Remove
(
reqRemovePlayers
,
p
)
//if err != nil {
// e.Error(500, err, fmt.Sprintf("删除比赛球员数据失败,\r\n失败信息 %s", err.Error()))
// return
//}
e
.
OK
(
1
,
"修改成功"
)
}
...
...
app/operate/models/org_match_team_player.go
View file @
1475ff59
...
...
@@ -9,9 +9,10 @@ import (
type
OrgMatchTeamPlayer
struct
{
models
.
Model
MatchId
string
`json:"matchId" gorm:"type:bigint(20);comment:MatchId"`
Rounds
string
`json:"rounds"
comment:"
轮次"`
Rounds
string
`json:"rounds"
gorm:"type:bigint(20);comment:
轮次"`
ClubId
string
`json:"clubId" gorm:"type:bigint(20);comment:ClubId"`
TeamId
string
`json:"teamId" gorm:"type:bigint(20);comment:TeamId"`
OtherTeamId
string
`json:"otherTeamId" gorm:"type:bigint(20);comment:OtherTeamId"`
PlayerId
string
`json:"playerId" gorm:"type:bigint(20);comment:PlayerId"`
PlayerName
string
`json:"playerName" gorm:"type:varchar(60);comment:球员名称"`
PlayerNumber
string
`json:"playerNumber" gorm:"type:varchar(60);comment:球员号码"`
...
...
@@ -25,9 +26,6 @@ type OrgMatchTeamPlayer struct {
Foul
string
`json:"foul" gorm:"type:bigint(20);comment:犯规"`
TwoPointShot
string
`json:"twoPointShot" gorm:"type:bigint(20);comment:2分进球数量"`
ThreePointShot
string
`json:"threePointShot" gorm:"type:bigint(20);comment:3分进球数量"`
Grouping
string
`json:"grouping" comment:"分组"`
OtherTeam
string
`json:"otherTeam" comment:"对方球队"`
models
.
ModelTime
models
.
ControlBy
}
...
...
app/operate/router/org_match.go
View file @
1475ff59
...
...
@@ -23,7 +23,7 @@ func registerOrgMatchRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
r
.
POST
(
""
,
api
.
Insert
)
r
.
PUT
(
"/:id"
,
api
.
Update
)
r
.
DELETE
(
""
,
api
.
Delete
)
r
.
GET
(
"/get-player
/:id
"
,
api
.
GetPlayer
)
r
.
GET
(
"/get-player"
,
api
.
GetPlayer
)
r
.
GET
(
"/get-player-is-set/:id"
,
api
.
GetPlayerIsSet
)
r
.
PUT
(
"/update-player/:id"
,
api
.
UpdatePlayer
)
r
.
PUT
(
"/update-player-data/:id"
,
api
.
UpdatePlayerData
)
...
...
app/operate/service/dto/org_match_team_player.go
View file @
1475ff59
...
...
@@ -12,7 +12,9 @@ type OrgMatchTeamPlayerGetPageReq struct {
OrgMatchTeamPlayerOrder
}
type
UpdateOrgMatchTeamPlayerReq
struct
{
MatchId
string
`json:"matchId" gorm:"type:bigint(20);comment:MatchId"`
MatchId
string
`json:"matchId"`
Rounds
string
`json:"rounds"`
OtherTeamId
string
`json:"otherTeamId"`
PlayersIds
string
`json:"playersIds"`
}
...
...
@@ -48,8 +50,10 @@ func (m *OrgMatchTeamPlayerGetPageReq) GetNeedSearch() interface{} {
type
OrgMatchTeamPlayerInsertReq
struct
{
Id
int
`json:"-" comment:""`
//
MatchId
string
`json:"matchId" comment:""`
Rounds
string
`json:"rounds" comment:""`
ClubId
string
`json:"clubId" comment:""`
TeamId
string
`json:"teamId" comment:""`
OtherTeamId
string
`json:"otherTeamId" comment:""`
PlayerId
string
`json:"playerId" comment:""`
PlayerName
string
`json:"playerName" comment:"球员名称"`
PlayerNumber
string
`json:"playerNumber" comment:"球员号码"`
...
...
@@ -71,8 +75,10 @@ func (s *OrgMatchTeamPlayerInsertReq) Generate(model *models.OrgMatchTeamPlayer)
model
.
Model
=
common
.
Model
{
Id
:
s
.
Id
}
}
model
.
MatchId
=
s
.
MatchId
model
.
Rounds
=
s
.
Rounds
model
.
ClubId
=
s
.
ClubId
model
.
TeamId
=
s
.
TeamId
model
.
OtherTeamId
=
s
.
OtherTeamId
model
.
PlayerId
=
s
.
PlayerId
model
.
PlayerName
=
s
.
PlayerName
model
.
PlayerNumber
=
s
.
PlayerNumber
...
...
@@ -95,8 +101,10 @@ func (s *OrgMatchTeamPlayerInsertReq) GetId() interface{} {
type
OrgMatchTeamPlayerUpdateReq
struct
{
Id
int
`uri:"id" comment:""`
//
MatchId
string
`json:"matchId" comment:""`
Rounds
string
`json:"rounds" comment:""`
ClubId
string
`json:"clubId" comment:""`
TeamId
string
`json:"teamId" comment:""`
OtherTeamId
string
`json:"otherTeamId" comment:""`
PlayerId
string
`json:"playerId" comment:""`
PlayerName
string
`json:"playerName" comment:"球员名称"`
PlayerNumber
string
`json:"playerNumber" comment:"球员号码"`
...
...
@@ -118,8 +126,10 @@ func (s *OrgMatchTeamPlayerUpdateReq) Generate(model *models.OrgMatchTeamPlayer)
model
.
Model
=
common
.
Model
{
Id
:
s
.
Id
}
}
model
.
MatchId
=
s
.
MatchId
model
.
Rounds
=
s
.
Rounds
model
.
ClubId
=
s
.
ClubId
model
.
TeamId
=
s
.
TeamId
model
.
OtherTeamId
=
s
.
OtherTeamId
model
.
PlayerId
=
s
.
PlayerId
model
.
PlayerName
=
s
.
PlayerName
model
.
PlayerNumber
=
s
.
PlayerNumber
...
...
@@ -150,7 +160,10 @@ func (s *OrgMatchTeamPlayerGetReq) GetId() interface{} {
// OrgMatchTeamPlayerDeleteReq 功能删除请求参数
type
OrgMatchTeamPlayerDeleteReq
struct
{
Ids
[]
int
`json:"ids"`
MatchId
string
`json:"matchId"`
Rounds
string
`json:"rounds"`
TeamId
string
`json:"teamId"`
Ids
string
`json:"ids"`
}
func
(
s
*
OrgMatchTeamPlayerDeleteReq
)
GetId
()
interface
{}
{
...
...
app/operate/service/dto/org_player.go
View file @
1475ff59
...
...
@@ -9,10 +9,12 @@ import (
type
OrgPlayerGetPageReq
struct
{
dto
.
Pagination
`search:"-"`
TeamId
string
`form:"teamId" search:"type:exact;column:team_id;table:org_player" comment:""`
OrgPlayerOrder
}
type
OrgPlayerOrder
struct
{
Id
int
`form:"idOrder" search:"type:order;column:id;table:org_player"`
type
OrgPlayerOrder
struct
{
Id
int
`form:"idOrder" search:"type:order;column:id;table:org_player"`
ClubId
string
`form:"clubIdOrder" search:"type:order;column:club_id;table:org_player"`
TeamId
string
`form:"teamIdOrder" search:"type:order;column:team_id;table:org_player"`
PlayerName
string
`form:"playerNameOrder" search:"type:order;column:player_name;table:org_player"`
...
...
@@ -28,7 +30,6 @@ type OrgPlayerOrder struct {Id int `form:"idOrder" search:"type:order;column:id
CreatedAt
time
.
Time
`form:"createdAtOrder" search:"type:order;column:created_at;table:org_player"`
UpdatedAt
time
.
Time
`form:"updatedAtOrder" search:"type:order;column:updated_at;table:org_player"`
DeletedAt
time
.
Time
`form:"deletedAtOrder" search:"type:order;column:deleted_at;table:org_player"`
}
func
(
m
*
OrgPlayerGetPageReq
)
GetNeedSearch
()
interface
{}
{
...
...
@@ -52,7 +53,7 @@ type OrgPlayerInsertReq struct {
func
(
s
*
OrgPlayerInsertReq
)
Generate
(
model
*
models
.
OrgPlayer
)
{
if
s
.
Id
==
0
{
model
.
Model
=
common
.
Model
{
Id
:
s
.
Id
}
model
.
Model
=
common
.
Model
{
Id
:
s
.
Id
}
}
model
.
ClubId
=
s
.
ClubId
model
.
TeamId
=
s
.
TeamId
...
...
@@ -87,7 +88,7 @@ type OrgPlayerUpdateReq struct {
func
(
s
*
OrgPlayerUpdateReq
)
Generate
(
model
*
models
.
OrgPlayer
)
{
if
s
.
Id
==
0
{
model
.
Model
=
common
.
Model
{
Id
:
s
.
Id
}
model
.
Model
=
common
.
Model
{
Id
:
s
.
Id
}
}
model
.
ClubId
=
s
.
ClubId
model
.
TeamId
=
s
.
TeamId
...
...
@@ -109,6 +110,7 @@ func (s *OrgPlayerUpdateReq) GetId() interface{} {
type
OrgPlayerGetReq
struct
{
Id
int
`uri:"id"`
}
func
(
s
*
OrgPlayerGetReq
)
GetId
()
interface
{}
{
return
s
.
Id
}
...
...
app/operate/service/org_match_team_player.go
View file @
1475ff59
...
...
@@ -81,7 +81,7 @@ func (e *OrgMatchTeamPlayer) Update(c *dto.OrgMatchTeamPlayerUpdateReq, p *actio
)
.
First
(
&
data
,
c
.
GetId
())
c
.
Generate
(
&
data
)
db
:=
e
.
Orm
.
Save
(
&
data
)
db
:=
e
.
Orm
.
Updates
(
&
data
)
if
db
.
Error
!=
nil
{
e
.
Log
.
Errorf
(
"OrgMatchTeamPlayerService Save error:%s
\r\n
"
,
err
)
return
err
...
...
@@ -99,7 +99,11 @@ func (e *OrgMatchTeamPlayer) Remove(d *dto.OrgMatchTeamPlayerDeleteReq, p *actio
db
:=
e
.
Orm
.
Model
(
&
data
)
.
Scopes
(
actions
.
Permission
(
data
.
TableName
(),
p
),
)
.
Delete
(
&
data
,
d
.
GetId
())
cDto
.
SetWhere
(
""
,
"match_id"
,
d
.
MatchId
),
cDto
.
SetWhere
(
""
,
"rounds"
,
d
.
Rounds
),
cDto
.
SetWhere
(
""
,
"team_id"
,
d
.
TeamId
),
cDto
.
SetWhereNotIn
(
""
,
"player_id"
,
d
.
Ids
),
)
.
Delete
(
&
data
)
if
err
:=
db
.
Error
;
err
!=
nil
{
e
.
Log
.
Errorf
(
"Service RemoveOrgMatchTeamPlayer error:%s
\r\n
"
,
err
)
return
err
...
...
@@ -111,22 +115,22 @@ func (e *OrgMatchTeamPlayer) Remove(d *dto.OrgMatchTeamPlayerDeleteReq, p *actio
}
// Insert 创建OrgMatchTeamPlayer对象
func
(
e
*
OrgMatchTeamPlayer
)
IsBeing
(
d
*
dto
.
OrgMatchTeamPlayerGetReq
,
p
*
actions
.
DataPermission
,
model
*
models
.
OrgMatchTeamPlayer
)
error
{
func
(
e
*
OrgMatchTeamPlayer
)
IsBeing
(
matchId
string
,
rounds
string
,
playerId
string
)
(
error
,
int
)
{
var
data
models
.
OrgMatchTeamPlayer
err
:=
e
.
Orm
.
Model
(
&
data
)
.
Scopes
(
actions
.
Permission
(
data
.
TableName
(),
p
),
)
.
First
(
model
,
d
.
GetId
()
)
.
Error
Where
(
"match_id=?"
,
matchId
)
.
Where
(
"rounds=?"
,
rounds
)
.
Where
(
"player_id=?"
,
playerId
)
.
First
(
&
data
)
.
Error
if
err
!=
nil
&&
errors
.
Is
(
err
,
gorm
.
ErrRecordNotFound
)
{
err
=
errors
.
New
(
"查看对象不存在或无权查看"
)
e
.
Log
.
Errorf
(
"Service GetOrgMatchTeamPlayer error:%s
\r\n
"
,
err
)
return
err
return
err
,
0
}
if
err
!=
nil
{
e
.
Log
.
Errorf
(
"db error:%s"
,
err
)
return
err
return
err
,
0
}
return
nil
return
nil
,
data
.
Id
}
app/operate/service/org_player.go
View file @
1475ff59
...
...
@@ -2,7 +2,6 @@ package service
import
(
"errors"
"github.com/go-admin-team/go-admin-core/sdk/service"
"gorm.io/gorm"
...
...
@@ -26,6 +25,7 @@ func (e *OrgPlayer) GetPage(c *dto.OrgPlayerGetPageReq, p *actions.DataPermissio
cDto
.
MakeCondition
(
c
.
GetNeedSearch
()),
cDto
.
Paginate
(
c
.
GetPageSize
(),
c
.
GetPageIndex
()),
actions
.
Permission
(
data
.
TableName
(),
p
),
cDto
.
SetWhere
(
""
,
"team_id"
,
c
.
TeamId
),
)
.
Find
(
list
)
.
Limit
(
-
1
)
.
Offset
(
-
1
)
.
Count
(
count
)
.
Error
...
...
common/dto/match.go
View file @
1475ff59
...
...
@@ -64,3 +64,27 @@ func SetWhere(tableName string, fieldName string, fieldValue string) func(db *go
return
db
.
Where
(
tableName
+
"."
+
fieldName
+
" = ?"
,
fieldValue
)
}
}
func
SetWhereIn
(
tableName
string
,
fieldName
string
,
fieldValue
string
)
func
(
db
*
gorm
.
DB
)
*
gorm
.
DB
{
return
func
(
db
*
gorm
.
DB
)
*
gorm
.
DB
{
if
fieldValue
==
"0"
||
fieldValue
==
""
{
return
db
}
if
tableName
==
""
{
return
db
.
Where
(
fieldName
+
" in ("
+
fieldValue
+
")"
)
}
return
db
.
Where
(
tableName
+
"."
+
fieldName
+
" in ("
+
fieldValue
+
")"
)
}
}
func
SetWhereNotIn
(
tableName
string
,
fieldName
string
,
fieldValue
string
)
func
(
db
*
gorm
.
DB
)
*
gorm
.
DB
{
return
func
(
db
*
gorm
.
DB
)
*
gorm
.
DB
{
if
fieldValue
==
"0"
||
fieldValue
==
""
{
return
db
}
if
tableName
==
""
{
return
db
.
Where
(
fieldName
+
" not in ("
+
fieldValue
+
")"
)
}
return
db
.
Where
(
tableName
+
"."
+
fieldName
+
" not in ("
+
fieldValue
+
")"
)
}
}
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