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
ae274dbc
Commit
ae274dbc
authored
Sep 11, 2021
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(比赛模块): 比赛接口
parent
f3461d18
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
999 additions
and
12 deletions
+999
-12
sport.pdm
doc/sport.pdm
+472
-12
MatchBicycleBusinessMapper.java
...pi/business/match/bicycle/MatchBicycleBusinessMapper.java
+18
-0
MatchBicycleController.java
...me/api/business/match/bicycle/MatchBicycleController.java
+58
-0
MatchBicyclePlayerService.java
...api/business/match/bicycle/MatchBicyclePlayerService.java
+55
-0
MatchBicycleService.java
.../game/api/business/match/bicycle/MatchBicycleService.java
+47
-0
DtoMatchBicycleResult.java
...api/business/match/bicycle/dto/DtoMatchBicycleResult.java
+45
-0
RespMatchBicycleList.java
.../api/business/match/bicycle/dto/RespMatchBicycleList.java
+28
-0
application.yaml
game-api/src/main/resources/application.yaml
+2
-0
MatchBicycleBusinessMapper.xml
...urces/mapper/match/bicycle/MatchBicycleBusinessMapper.xml
+19
-0
MatchBicycle.java
...ort/http/server/repository/match/entity/MatchBicycle.java
+91
-0
MatchBicyclePlayer.java
...tp/server/repository/match/entity/MatchBicyclePlayer.java
+122
-0
MatchBicycleMapper.java
...tp/server/repository/match/mapper/MatchBicycleMapper.java
+16
-0
MatchBicyclePlayerMapper.java
...ver/repository/match/mapper/MatchBicyclePlayerMapper.java
+16
-0
MatchBicycleMapper.xml
...ry/src/main/resources/mapper/match/MatchBicycleMapper.xml
+5
-0
MatchBicyclePlayerMapper.xml
.../main/resources/mapper/match/MatchBicyclePlayerMapper.xml
+5
-0
No files found.
doc/sport.pdm
View file @
ae274dbc
This diff is collapsed.
Click to expand it.
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/MatchBicycleBusinessMapper.java
0 → 100644
View file @
ae274dbc
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
java.util.List
;
/**
* @Author liming
* @Date 2021/9/11 19:04
* @Email lmmax@126.com
* @Description:
*/
public
interface
MatchBicycleBusinessMapper
{
List
<
RespMatchBicycleList
>
getMatchBicycleList
();
List
<
DtoMatchBicycleResult
>
getMatchBicyclePlayerRecord
(
Long
matchId
);
}
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/MatchBicycleController.java
0 → 100644
View file @
ae274dbc
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.RespMatchBicycleList
;
import
com.antai.sport.http.server.repository.sport.entity.SportUser
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
static
com
.
antai
.
sport
.
http
.
server
.
common
.
util
.
ResultUtil
.
success
;
/**
* @Author liming
* @Date 2021/9/11 18:31
* @Email lmmax@126.com
* @Description:
*/
@RestController
()
@RequestMapping
(
"/match/bicycle"
)
@Api
(
tags
=
{
"比赛相关接口"
})
public
class
MatchBicycleController
{
@Resource
private
MatchBicycleService
matchBicycleService
;
@Resource
private
MatchBicyclePlayerService
matchBicyclePlayerService
;
@GetMapping
()
@ApiOperation
(
value
=
"获取比赛列表接口"
,
notes
=
"data为比赛列表数据"
)
public
ResponseEntity
<
Result
<
List
<
RespMatchBicycleList
>>>
getMatchBicycleList
()
{
return
success
(
matchBicycleService
.
getMatchBicycleList
());
}
@PostMapping
(
"/entry/{matchId}"
)
@ApiOperation
(
value
=
"加入比赛接口"
)
public
ResponseEntity
<
Result
>
entryMatchBicycle
(
@LoginSportUser
SportUser
loginUser
,
@PathVariable
Long
matchId
)
{
matchBicycleService
.
entryMatchBicycle
(
loginUser
,
matchId
);
return
success
();
}
@PostMapping
(
"/player/record"
)
@ApiOperation
(
value
=
"比赛数据保存"
)
public
ResponseEntity
<
Result
>
saveMatchBicyclePlayerRecord
(
@RequestBody
List
<
DtoMatchBicycleResult
>
resultList
)
{
matchBicyclePlayerService
.
saveMatchBicyclePlayerRecord
(
resultList
);
return
success
();
}
@GetMapping
(
"/player/record/{matchId}"
)
@ApiOperation
(
value
=
"比赛数据查询"
)
public
ResponseEntity
<
Result
<
List
<
DtoMatchBicycleResult
>>>
getMatchBicyclePlayerRecord
(
@PathVariable
Long
matchId
)
{
return
success
(
matchBicyclePlayerService
.
getMatchBicyclePlayerRecord
(
matchId
));
}
}
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/MatchBicyclePlayerService.java
0 → 100644
View file @
ae274dbc
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.repository.match.entity.MatchBicyclePlayer
;
import
com.antai.sport.http.server.repository.match.mapper.MatchBicyclePlayerMapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @Author liming
* @Date 2021/9/11 18:32
* @Email lmmax@126.com
* @Description:
*/
@Service
public
class
MatchBicyclePlayerService
extends
ServiceImpl
<
MatchBicyclePlayerMapper
,
MatchBicyclePlayer
>
{
@Resource
private
MatchBicycleBusinessMapper
matchBicycleBusinessMapper
;
/**
* 保存比赛结果
*
* @param resultList
*/
public
void
saveMatchBicyclePlayerRecord
(
List
<
DtoMatchBicycleResult
>
resultList
)
{
if
(
resultList
==
null
||
resultList
.
isEmpty
())
{
return
;
}
List
<
MatchBicyclePlayer
>
saveList
=
new
ArrayList
<>(
resultList
.
size
());
for
(
DtoMatchBicycleResult
item
:
resultList
)
{
MatchBicyclePlayer
record
=
new
MatchBicyclePlayer
();
record
.
setMatchId
(
item
.
getMatchId
());
record
.
setUserId
(
item
.
getUserId
());
record
.
setEntryTime
(
item
.
getEntryTime
());
record
.
setFinishTime
(
item
.
getFinishTime
());
record
.
setDuration
(
item
.
getDuration
());
record
.
setMatchRank
(
item
.
getMatchRank
());
record
.
setClimbDistance
(
item
.
getClimbDistance
());
record
.
setDistance
(
item
.
getDistance
());
record
.
setAvgFtp
(
item
.
getAvgFtp
());
record
.
setAvgSpeed
(
item
.
getAvgSpeed
());
record
.
setStatus
(
item
.
getStatus
());
saveList
.
add
(
record
);
}
this
.
saveBatch
(
saveList
);
}
public
List
<
DtoMatchBicycleResult
>
getMatchBicyclePlayerRecord
(
Long
matchId
)
{
return
matchBicycleBusinessMapper
.
getMatchBicyclePlayerRecord
(
matchId
);
}
}
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/MatchBicycleService.java
0 → 100644
View file @
ae274dbc
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.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.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* @Author liming
* @Date 2021/9/11 18:32
* @Email lmmax@126.com
* @Description:
*/
@Service
public
class
MatchBicycleService
extends
ServiceImpl
<
MatchBicycleMapper
,
MatchBicycle
>
{
@Resource
private
MatchBicycleBusinessMapper
matchBicycleBusinessMapper
;
public
List
<
RespMatchBicycleList
>
getMatchBicycleList
()
{
return
matchBicycleBusinessMapper
.
getMatchBicycleList
();
}
public
void
entryMatchBicycle
(
SportUser
loginUser
,
Long
matchId
)
{
MatchBicycle
match
=
this
.
getById
(
matchId
);
if
(
match
==
null
||
match
.
getEndTime
()
==
null
)
{
throw
new
BusinessException
(
"您报名的比赛不存在"
);
}
LocalDateTime
now
=
LocalDateTime
.
now
();
if
(
now
.
isBefore
(
match
.
getEntryTime
()))
{
throw
new
BusinessException
(
"当前比赛还没到进入时间,请查看比赛详情"
);
}
if
(
now
.
isAfter
(
match
.
getEndTime
()))
{
throw
new
BusinessException
(
"当前比赛已经结束,您已无法参加"
);
}
if
(
now
.
isAfter
(
match
.
getStartTime
()))
{
throw
new
BusinessException
(
"当前比赛已经开始,您已无法加入"
);
}
}
}
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/dto/DtoMatchBicycleResult.java
0 → 100644
View file @
ae274dbc
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.math.BigDecimal
;
import
java.time.LocalDateTime
;
/**
* @Author liming
* @Date 2021/9/11 19:48
* @Email lmmax@126.com
* @Description:
*/
@Data
@ApiModel
(
"比赛结果"
)
public
class
DtoMatchBicycleResult
{
@ApiModelProperty
(
"比赛id"
)
private
Long
matchId
;
@ApiModelProperty
(
"用户id"
)
private
Long
userId
;
@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
finishTime
;
@ApiModelProperty
(
"比赛用时(秒)"
)
private
Integer
duration
;
@ApiModelProperty
(
"比赛名次"
)
private
Integer
matchRank
;
@ApiModelProperty
(
"骑行总长度"
)
private
BigDecimal
distance
;
@ApiModelProperty
(
"爬坡高度"
)
private
BigDecimal
climbDistance
;
@ApiModelProperty
(
"平均功率"
)
private
BigDecimal
avgFtp
;
@ApiModelProperty
(
"平均速度"
)
private
BigDecimal
avgSpeed
;
@ApiModelProperty
(
"比赛状态1.完成比赛 2.未完成比赛"
)
private
Integer
status
;
}
game-api/src/main/java/com/antai/sport/http/server/game/api/business/match/bicycle/dto/RespMatchBicycleList.java
0 → 100644
View file @
ae274dbc
package
com
.
antai
.
sport
.
http
.
server
.
game
.
api
.
business
.
match
.
bicycle
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
/**
* @Author liming
* @Date 2021/9/11 18:57
* @Email lmmax@126.com
* @Description:
*/
@Data
@ApiModel
(
"比赛列表"
)
public
class
RespMatchBicycleList
{
@ApiModelProperty
(
"比赛id"
)
private
Long
id
;
@ApiModelProperty
(
"比赛名称"
)
private
String
name
;
@ApiModelProperty
(
"允许进入时间"
)
private
LocalDateTime
entryTime
;
@ApiModelProperty
(
"开始比赛时间"
)
private
LocalDateTime
startTime
;
@ApiModelProperty
(
"比赛结束时间"
)
private
LocalDateTime
endTime
;
}
game-api/src/main/resources/application.yaml
View file @
ae274dbc
...
@@ -45,6 +45,8 @@ project:
...
@@ -45,6 +45,8 @@ project:
-
/error
-
/error
-
/login
-
/login
-
/login/sms/**
-
/login/sms/**
-
/match/bicycle
-
/match/bicycle/player/record
swagger
:
swagger
:
enable
:
false
enable
:
false
...
...
game-api/src/main/resources/mapper/match/bicycle/MatchBicycleBusinessMapper.xml
0 → 100644
View file @
ae274dbc
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.antai.sport.http.server.game.api.business.match.bicycle.MatchBicycleBusinessMapper"
>
<select
id=
"getMatchBicycleList"
resultType=
"com.antai.sport.http.server.game.api.business.match.bicycle.dto.RespMatchBicycleList"
>
select *
from match_bicycle
where deleted = 0
order by end_time desc
</select>
<select
id=
"getMatchBicyclePlayerRecord"
resultType=
"com.antai.sport.http.server.game.api.business.match.bicycle.dto.DtoMatchBicycleResult"
>
select *
from match_bicycle_player
where deleted = 0
order by match_rank
</select>
</mapper>
repository/src/main/java/com/antai/sport/http/server/repository/match/entity/MatchBicycle.java
0 → 100644
View file @
ae274dbc
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
match
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDateTime
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
* 比赛信息表
* </p>
*
* @author liming
* @since 2021-09-11
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
MatchBicycle
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 比赛名称
*/
private
String
name
;
/**
* 允许进入时间
*/
private
LocalDateTime
entryTime
;
/**
* 比赛开始时间
*/
private
LocalDateTime
startTime
;
/**
* 比赛结束时间
*/
private
LocalDateTime
endTime
;
/**
* 显示顺序
*/
private
Integer
showOrder
;
/**
* 版本号
*/
private
Long
version
;
/**
* 删除标记
*/
private
Integer
deleted
;
/**
* 创建部门id
*/
private
Long
ctDeptId
;
/**
* 创建人id
*/
private
Long
ctUserId
;
/**
* 创建时间
*/
private
LocalDateTime
ctDate
;
/**
* 修改人id
*/
private
Long
lmUserId
;
/**
* 修改时间
*/
private
LocalDateTime
lmDate
;
}
repository/src/main/java/com/antai/sport/http/server/repository/match/entity/MatchBicyclePlayer.java
0 → 100644
View file @
ae274dbc
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
match
.
entity
;
import
java.math.BigDecimal
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDateTime
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
* 比赛玩家
* </p>
*
* @author liming
* @since 2021-09-11
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
MatchBicyclePlayer
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 比赛id
*/
private
Long
matchId
;
/**
* 比赛用户id
*/
private
Long
userId
;
/**
* 比赛进入时间
*/
private
LocalDateTime
entryTime
;
/**
* 比赛完成时间
*/
private
LocalDateTime
finishTime
;
/**
* 比赛用时(秒)
*/
private
Integer
duration
;
/**
* 比赛名次
*/
private
Integer
matchRank
;
/**
* 爬坡距离
*/
private
BigDecimal
climbDistance
;
/**
* 骑行总长度
*/
private
BigDecimal
distance
;
/**
* 平均功率
*/
private
BigDecimal
avgFtp
;
/**
* 平均速度
*/
private
BigDecimal
avgSpeed
;
/**
* 比赛状态1.完成比赛 2.未完成比赛
*/
private
Integer
status
;
/**
* 版本号
*/
private
Long
version
;
/**
* 删除标记
*/
private
Integer
deleted
;
/**
* 创建部门id
*/
private
Long
ctDeptId
;
/**
* 创建人id
*/
private
Long
ctUserId
;
/**
* 创建时间
*/
private
LocalDateTime
ctDate
;
/**
* 修改人id
*/
private
Long
lmUserId
;
/**
* 修改时间
*/
private
LocalDateTime
lmDate
;
}
repository/src/main/java/com/antai/sport/http/server/repository/match/mapper/MatchBicycleMapper.java
0 → 100644
View file @
ae274dbc
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
match
.
mapper
;
import
com.antai.sport.http.server.repository.match.entity.MatchBicycle
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* 比赛信息表 Mapper 接口
* </p>
*
* @author liming
* @since 2021-09-11
*/
public
interface
MatchBicycleMapper
extends
BaseMapper
<
MatchBicycle
>
{
}
repository/src/main/java/com/antai/sport/http/server/repository/match/mapper/MatchBicyclePlayerMapper.java
0 → 100644
View file @
ae274dbc
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
match
.
mapper
;
import
com.antai.sport.http.server.repository.match.entity.MatchBicyclePlayer
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* 比赛玩家 Mapper 接口
* </p>
*
* @author liming
* @since 2021-09-11
*/
public
interface
MatchBicyclePlayerMapper
extends
BaseMapper
<
MatchBicyclePlayer
>
{
}
repository/src/main/resources/mapper/match/MatchBicycleMapper.xml
0 → 100644
View file @
ae274dbc
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.antai.sport.http.server.repository.match.mapper.MatchBicycleMapper"
>
</mapper>
repository/src/main/resources/mapper/match/MatchBicyclePlayerMapper.xml
0 → 100644
View file @
ae274dbc
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.antai.sport.http.server.repository.match.mapper.MatchBicyclePlayerMapper"
>
</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