Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
antai-sport-http-server
Project
Project
Details
Activity
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
antai-sport
antai-sport-http-server
Commits
6e68d241
Commit
6e68d241
authored
Sep 23, 2021
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加比赛创建删除接口
parent
ae274dbc
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
94 additions
and
1 deletion
+94
-1
MatchBicycleBusinessMapper.java
...pi/business/match/bicycle/MatchBicycleBusinessMapper.java
+4
-0
MatchBicycleController.java
...me/api/business/match/bicycle/MatchBicycleController.java
+14
-0
MatchBicycleService.java
.../game/api/business/match/bicycle/MatchBicycleService.java
+33
-0
ReqMatchBicycleSave.java
...e/api/business/match/bicycle/dto/ReqMatchBicycleSave.java
+24
-0
RespMatchBicycleList.java
.../api/business/match/bicycle/dto/RespMatchBicycleList.java
+4
-0
application-dev.yaml
game-api/src/main/resources/application-dev.yaml
+1
-1
application.yaml
game-api/src/main/resources/application.yaml
+1
-0
MatchBicycleBusinessMapper.xml
...urces/mapper/match/bicycle/MatchBicycleBusinessMapper.xml
+13
-0
No files found.
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/MatchBicycleBusinessMapper.java
View file @
6e68d241
...
...
@@ -2,7 +2,9 @@ package com.antai.sport.http.server.game.api.business.match.bicycle;
import
com.antai.sport.http.server.game.api.business.match.bicycle.dto.DtoMatchBicycleResult
;
import
com.antai.sport.http.server.game.api.business.match.bicycle.dto.RespMatchBicycleList
;
import
org.apache.ibatis.annotations.Param
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
...
...
@@ -15,4 +17,6 @@ public interface MatchBicycleBusinessMapper {
List
<
RespMatchBicycleList
>
getMatchBicycleList
();
List
<
DtoMatchBicycleResult
>
getMatchBicyclePlayerRecord
(
Long
matchId
);
Boolean
checkMatchRepeat
(
@Param
(
"entryTime"
)
LocalDateTime
entryTime
,
@Param
(
"endTime"
)
LocalDateTime
endTime
);
}
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/MatchBicycleController.java
View file @
6e68d241
...
...
@@ -3,6 +3,7 @@ package com.antai.sport.http.server.game.api.business.match.bicycle;
import
com.antai.sport.http.server.common.annotation.LoginSportUser
;
import
com.antai.sport.http.server.common.base.Result
;
import
com.antai.sport.http.server.game.api.business.match.bicycle.dto.DtoMatchBicycleResult
;
import
com.antai.sport.http.server.game.api.business.match.bicycle.dto.ReqMatchBicycleSave
;
import
com.antai.sport.http.server.game.api.business.match.bicycle.dto.RespMatchBicycleList
;
import
com.antai.sport.http.server.repository.sport.entity.SportUser
;
import
io.swagger.annotations.Api
;
...
...
@@ -30,12 +31,25 @@ public class MatchBicycleController {
@Resource
private
MatchBicyclePlayerService
matchBicyclePlayerService
;
@PostMapping
@ApiOperation
(
value
=
"创建比赛"
,
notes
=
"data 为创建成功的比赛Id"
)
public
ResponseEntity
<
Result
<
Long
>>
saveMatchBicycle
(
@RequestBody
ReqMatchBicycleSave
data
)
{
return
success
(
matchBicycleService
.
saveMatchBicycle
(
data
));
}
@GetMapping
()
@ApiOperation
(
value
=
"获取比赛列表接口"
,
notes
=
"data为比赛列表数据"
)
public
ResponseEntity
<
Result
<
List
<
RespMatchBicycleList
>>>
getMatchBicycleList
()
{
return
success
(
matchBicycleService
.
getMatchBicycleList
());
}
@DeleteMapping
(
"/{matchId}"
)
@ApiOperation
(
value
=
"删除比赛接口"
)
public
ResponseEntity
<
Result
>
deleteMatchBicycle
(
@PathVariable
Long
matchId
)
{
matchBicycleService
.
removeById
(
matchId
);
return
success
();
}
@PostMapping
(
"/entry/{matchId}"
)
@ApiOperation
(
value
=
"加入比赛接口"
)
public
ResponseEntity
<
Result
>
entryMatchBicycle
(
@LoginSportUser
SportUser
loginUser
,
@PathVariable
Long
matchId
)
{
...
...
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/MatchBicycleService.java
View file @
6e68d241
package
com
.
antai
.
sport
.
http
.
server
.
game
.
api
.
business
.
match
.
bicycle
;
import
com.antai.sport.http.server.common.exception.BusinessException
;
import
com.antai.sport.http.server.game.api.business.match.bicycle.dto.ReqMatchBicycleSave
;
import
com.antai.sport.http.server.game.api.business.match.bicycle.dto.RespMatchBicycleList
;
import
com.antai.sport.http.server.repository.match.entity.MatchBicycle
;
import
com.antai.sport.http.server.repository.match.mapper.MatchBicycleMapper
;
import
com.antai.sport.http.server.repository.sport.entity.SportUser
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
...
...
@@ -23,6 +26,36 @@ public class MatchBicycleService extends ServiceImpl<MatchBicycleMapper, MatchBi
@Resource
private
MatchBicycleBusinessMapper
matchBicycleBusinessMapper
;
public
Long
saveMatchBicycle
(
@RequestBody
ReqMatchBicycleSave
data
)
{
if
(
StringUtils
.
isBlank
(
data
.
getName
()))
{
throw
new
BusinessException
(
"比赛名称不能为空"
);
}
if
(
data
.
getEntryTime
()
==
null
||
data
.
getStartTime
()
==
null
||
data
.
getEndTime
()
==
null
)
{
throw
new
BusinessException
(
"所有输入时间不能为空"
);
}
if
(
data
.
getEntryTime
().
equals
(
data
.
getStartTime
())
||
data
.
getEntryTime
().
isAfter
(
data
.
getStartTime
()))
{
throw
new
BusinessException
(
"允许进入时间必须早于比赛开始时间"
);
}
if
(
data
.
getStartTime
().
equals
(
data
.
getEndTime
())
||
data
.
getStartTime
().
isAfter
(
data
.
getEndTime
()))
{
throw
new
BusinessException
(
"比赛开始时间必须早于比赛结束时间"
);
}
if
(
matchBicycleBusinessMapper
.
checkMatchRepeat
(
data
.
getEntryTime
(),
data
.
getEndTime
()))
{
throw
new
BusinessException
(
"比赛时间段有冲突,请修改比赛时间"
);
}
MatchBicycle
match
=
new
MatchBicycle
();
match
.
setName
(
data
.
getName
());
match
.
setEntryTime
(
data
.
getEntryTime
());
match
.
setStartTime
(
data
.
getStartTime
());
match
.
setEndTime
(
data
.
getEndTime
());
this
.
save
(
match
);
return
match
.
getId
();
}
public
List
<
RespMatchBicycleList
>
getMatchBicycleList
()
{
return
matchBicycleBusinessMapper
.
getMatchBicycleList
();
}
...
...
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/dto/ReqMatchBicycleSave.java
0 → 100644
View file @
6e68d241
package
com
.
antai
.
sport
.
http
.
server
.
game
.
api
.
business
.
match
.
bicycle
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
@Data
@ApiModel
(
"创建比赛"
)
public
class
ReqMatchBicycleSave
{
@ApiModelProperty
(
"比赛名称"
)
private
String
name
;
@ApiModelProperty
(
"允许进入时间 yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
entryTime
;
@ApiModelProperty
(
"开始比赛时间 yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
startTime
;
@ApiModelProperty
(
"比赛结束时间 yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
endTime
;
}
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/dto/RespMatchBicycleList.java
View file @
6e68d241
package
com
.
antai
.
sport
.
http
.
server
.
game
.
api
.
business
.
match
.
bicycle
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -20,9 +21,12 @@ public class RespMatchBicycleList {
@ApiModelProperty
(
"比赛名称"
)
private
String
name
;
@ApiModelProperty
(
"允许进入时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
entryTime
;
@ApiModelProperty
(
"开始比赛时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
startTime
;
@ApiModelProperty
(
"比赛结束时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
endTime
;
}
game-api/src/main/resources/application-dev.yaml
View file @
6e68d241
...
...
@@ -8,7 +8,7 @@ spring:
database
:
0
host
:
127.0.0.1
port
:
6379
password
:
123
password
:
123
456
swagger
:
enable
:
true
game-api/src/main/resources/application.yaml
View file @
6e68d241
...
...
@@ -46,6 +46,7 @@ project:
-
/login
-
/login/sms/**
-
/match/bicycle
-
/match/bicycle/*
-
/match/bicycle/player/record
swagger
:
...
...
game-api/src/main/resources/mapper/match/bicycle/MatchBicycleBusinessMapper.xml
View file @
6e68d241
...
...
@@ -9,6 +9,17 @@
order by end_time desc
</select>
<select
id=
"checkMatchRepeat"
resultType=
"java.lang.Boolean"
>
select count(1)>0
from match_bicycle
where deleted = 0 and (
(entry_time
>
= #{entryTime} and entry_time
<
= #{endTime}) or
(end_time
>
= #{entryTime} and end_time
<
= #{endTime}) or
(entry_time
<
= #{entryTime} and end_time
>
= #{endTime})
)
</select>
<select
id=
"getMatchBicyclePlayerRecord"
resultType=
"com.antai.sport.http.server.game.api.business.match.bicycle.dto.DtoMatchBicycleResult"
>
select *
...
...
@@ -16,4 +27,6 @@
where deleted = 0
order by match_rank
</select>
</mapper>
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