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
5a8f5e4d
Commit
5a8f5e4d
authored
Apr 12, 2022
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生成漫游归集日志
parent
72f9f420
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
236 additions
and
5 deletions
+236
-5
SportUserTrainingLog.java
.../server/repository/sport/entity/SportUserTrainingLog.java
+119
-0
SportUserTrainingLogMapper.java
...r/repository/sport/mapper/SportUserTrainingLogMapper.java
+16
-0
SportUserTrainingLogMapper.xml
...ain/resources/mapper/sport/SportUserTrainingLogMapper.xml
+5
-0
ReqPraise.java
...http/server/server/api/business/praise/dto/ReqPraise.java
+1
-1
TourService.java
.../server/server/api/business/tour/service/TourService.java
+15
-3
SportUserTrainingLogConverter.java
.../traininglog/converter/SportUserTrainingLogConverter.java
+11
-0
SportUserTrainingLogService.java
...ness/traininglog/service/SportUserTrainingLogService.java
+68
-0
application.yaml
server-api/src/main/resources/application.yaml
+1
-1
No files found.
repository/src/main/java/com/antai/sport/http/server/repository/sport/entity/SportUserTrainingLog.java
0 → 100644
View file @
5a8f5e4d
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
sport
.
entity
;
import
java.math.BigDecimal
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
*
* </p>
*
* @author liming
* @since 2022-04-12
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
SportUserTrainingLog
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 比赛类型 1:自行车 2:跑步
*/
private
Integer
sportType
;
/**
* 比赛模式 10:漫游 20:日常赛 30:系列赛 40:训练模式 50: 团练 60:娱乐赛
*/
private
Integer
gameMode
;
/**
* 玩家id
*/
private
Long
playerId
;
/**
* 源头id 比如娱乐房间id 赛事id等
*/
private
Long
sourceId
;
/**
* 运动记录id
*/
private
Long
recordId
;
/**
* 地图key
*/
private
String
map
;
/**
* 赛道key
*/
private
String
path
;
/**
* 卡路里
*/
private
Integer
calorie
;
/**
* 比赛用时(秒)
*/
private
Integer
duration
;
/**
* 比赛名次
*/
private
Integer
matchRank
;
/**
* 骑行总长度
*/
private
BigDecimal
distance
;
/**
* 爬坡距离
*/
private
BigDecimal
climbDistance
;
/**
* 平均功率
*/
private
BigDecimal
avgFtp
;
/**
* 平均速度
*/
private
BigDecimal
avgSpeed
;
/**
* 获攒数量
*/
private
Integer
praiseNum
;
/**
* 创建日期不带时分秒
*/
private
LocalDate
createDate
;
/**
* 创建时间
*/
private
LocalDateTime
createTime
;
}
repository/src/main/java/com/antai/sport/http/server/repository/sport/mapper/SportUserTrainingLogMapper.java
0 → 100644
View file @
5a8f5e4d
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
sport
.
mapper
;
import
com.antai.sport.http.server.repository.sport.entity.SportUserTrainingLog
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author liming
* @since 2022-04-12
*/
public
interface
SportUserTrainingLogMapper
extends
BaseMapper
<
SportUserTrainingLog
>
{
}
repository/src/main/resources/mapper/sport/SportUserTrainingLogMapper.xml
0 → 100644
View file @
5a8f5e4d
<?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.sport.mapper.SportUserTrainingLogMapper"
>
</mapper>
server-api/src/main/java/com/antai/sport/http/server/server/api/business/praise/dto/ReqPraise.java
View file @
5a8f5e4d
...
@@ -7,7 +7,7 @@ import lombok.Data;
...
@@ -7,7 +7,7 @@ import lombok.Data;
@Data
@Data
@ApiModel
(
"点赞请求"
)
@ApiModel
(
"点赞请求"
)
public
class
ReqPraise
{
public
class
ReqPraise
{
@ApiModelProperty
(
"点赞类型 10:漫游 20:日常赛 30:系列赛 40:课程训练 50: 团练"
)
@ApiModelProperty
(
"点赞类型 10:漫游 20:日常赛 30:系列赛 40:课程训练 50: 团练
60:房间模式
"
)
private
Integer
gameMode
;
private
Integer
gameMode
;
@ApiModelProperty
(
"骑行记录id"
)
@ApiModelProperty
(
"骑行记录id"
)
private
Long
recordId
;
private
Long
recordId
;
...
...
server-api/src/main/java/com/antai/sport/http/server/server/api/business/tour/service/TourService.java
View file @
5a8f5e4d
...
@@ -9,8 +9,10 @@ import com.antai.sport.http.server.server.api.business.praise.service.PraiseServ
...
@@ -9,8 +9,10 @@ import com.antai.sport.http.server.server.api.business.praise.service.PraiseServ
import
com.antai.sport.http.server.server.api.business.tour.converter.TourRecordConverter
;
import
com.antai.sport.http.server.server.api.business.tour.converter.TourRecordConverter
;
import
com.antai.sport.http.server.server.api.business.tour.dto.ReqTourRecordInit
;
import
com.antai.sport.http.server.server.api.business.tour.dto.ReqTourRecordInit
;
import
com.antai.sport.http.server.server.api.business.tour.dto.RespTourRecordInit
;
import
com.antai.sport.http.server.server.api.business.tour.dto.RespTourRecordInit
;
import
com.antai.sport.http.server.server.api.business.traininglog.service.SportUserTrainingLogService
;
import
com.antai.sport.http.server.server.api.common.dto.CyclingDataDTO
;
import
com.antai.sport.http.server.server.api.common.dto.CyclingDataDTO
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -27,6 +29,8 @@ public class TourService {
...
@@ -27,6 +29,8 @@ public class TourService {
@Resource
@Resource
private
PraiseService
praiseService
;
private
PraiseService
praiseService
;
@Resource
private
SportUserTrainingLogService
sportUserTrainingLogService
;
/**
/**
* 初始化漫游记录
* 初始化漫游记录
...
@@ -55,11 +59,19 @@ public class TourService {
...
@@ -55,11 +59,19 @@ public class TourService {
*
*
* @param tourRecordList
* @param tourRecordList
*/
*/
@Transactional
public
void
upload
(
List
<
CyclingDataDTO
>
tourRecordList
)
{
public
void
upload
(
List
<
CyclingDataDTO
>
tourRecordList
)
{
tourRecordList
.
forEach
(
item
->
{
tourRecordList
.
forEach
(
item
->
{
TourRecord
tourRecord
=
tourRecordConverter
.
convertToTourRecord
(
item
,
TourRecordStatus
.
COMMITTED
);
TourRecord
oldRecord
=
tourRecordMapper
.
selectById
(
item
.
getRecordId
());
tourRecord
.
setPraiseNum
(
praiseService
.
getPraiseByGameModeAndRecordId
(
GameMode
.
TOUR
,
item
.
getRecordId
()));
if
(
oldRecord
!=
null
&&
oldRecord
.
getStatus
().
equals
(
TourRecordStatus
.
UNCOMMITTED
))
{
tourRecordMapper
.
updateById
(
tourRecord
);
TourRecord
tourRecord
=
tourRecordConverter
.
convertToTourRecord
(
item
,
TourRecordStatus
.
COMMITTED
);
tourRecord
.
setPraiseNum
(
praiseService
.
getPraiseByGameModeAndRecordId
(
GameMode
.
TOUR
,
item
.
getRecordId
()));
tourRecordMapper
.
updateById
(
tourRecord
);
//生成骑行日志
sportUserTrainingLogService
.
createBicycleTrainingLog
(
oldRecord
.
getPlayerId
(),
GameMode
.
TOUR
,
oldRecord
.
getId
(),
oldRecord
.
getMap
(),
oldRecord
.
getPath
(),
tourRecord
.
getPraiseNum
(),
item
);
}
});
});
}
}
}
}
server-api/src/main/java/com/antai/sport/http/server/server/api/business/traininglog/converter/SportUserTrainingLogConverter.java
0 → 100644
View file @
5a8f5e4d
package
com
.
antai
.
sport
.
http
.
server
.
server
.
api
.
business
.
traininglog
.
converter
;
import
com.antai.sport.http.server.repository.sport.entity.SportUserTrainingLog
;
import
com.antai.sport.http.server.server.api.common.dto.CyclingDataDTO
;
import
org.mapstruct.Mapper
;
@Mapper
(
componentModel
=
"spring"
)
public
interface
SportUserTrainingLogConverter
{
SportUserTrainingLog
toSportUserTrainingLog
(
CyclingDataDTO
source
);
}
server-api/src/main/java/com/antai/sport/http/server/server/api/business/traininglog/service/SportUserTrainingLogService.java
0 → 100644
View file @
5a8f5e4d
package
com
.
antai
.
sport
.
http
.
server
.
server
.
api
.
business
.
traininglog
.
service
;
import
com.antai.sport.http.server.constants.DeleteStatus
;
import
com.antai.sport.http.server.constants.SportType
;
import
com.antai.sport.http.server.repository.sport.entity.SportUserSummary
;
import
com.antai.sport.http.server.repository.sport.entity.SportUserTrainingLog
;
import
com.antai.sport.http.server.repository.sport.mapper.SportUserSummaryMapper
;
import
com.antai.sport.http.server.repository.sport.mapper.SportUserTrainingLogMapper
;
import
com.antai.sport.http.server.server.api.business.traininglog.converter.SportUserTrainingLogConverter
;
import
com.antai.sport.http.server.server.api.common.dto.CyclingDataDTO
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
@Service
public
class
SportUserTrainingLogService
{
@Resource
private
SportUserTrainingLogMapper
sportUserTrainingLogMapper
;
@Resource
private
SportUserSummaryMapper
sportUserSummaryMapper
;
@Resource
private
SportUserTrainingLogConverter
sportUserTrainingLogConverter
;
public
void
createBicycleTrainingLog
(
Long
playerId
,
Integer
gameMode
,
Long
sourceId
,
String
map
,
String
path
,
Integer
praiseNum
,
CyclingDataDTO
sportData
)
{
SportUserTrainingLog
log
=
sportUserTrainingLogConverter
.
toSportUserTrainingLog
(
sportData
);
log
.
setSportType
(
SportType
.
BICYCLE
);
log
.
setGameMode
(
gameMode
);
log
.
setPlayerId
(
playerId
);
log
.
setSourceId
(
sourceId
);
log
.
setMap
(
map
);
log
.
setPath
(
path
);
log
.
setPraiseNum
(
praiseNum
);
log
.
setCreateTime
(
LocalDateTime
.
now
());
log
.
setCreateDate
(
LocalDate
.
now
());
sportUserTrainingLogMapper
.
insert
(
log
);
QueryWrapper
<
SportUserSummary
>
summaryQuery
=
new
QueryWrapper
<>();
summaryQuery
.
eq
(
"deleted"
,
DeleteStatus
.
UNDELETED
);
summaryQuery
.
eq
(
"user_id"
,
playerId
);
summaryQuery
.
eq
(
"type"
,
SportType
.
BICYCLE
);
SportUserSummary
summary
=
sportUserSummaryMapper
.
selectOne
(
summaryQuery
);
if
(
summary
==
null
)
{
summary
=
new
SportUserSummary
();
summary
.
setUserId
(
playerId
);
summary
.
setType
(
SportType
.
BICYCLE
);
summary
.
setTotalDistance
(
BigDecimal
.
ZERO
);
summary
.
setTotalClimbDistance
(
BigDecimal
.
ZERO
);
summary
.
setTotalDuration
(
0
);
}
summary
.
setTotalDuration
(
summary
.
getTotalDuration
()
+
log
.
getDuration
());
summary
.
setTotalDistance
(
summary
.
getTotalDistance
().
add
(
log
.
getDistance
()));
summary
.
setTotalClimbDistance
(
summary
.
getTotalClimbDistance
().
add
(
log
.
getClimbDistance
()));
if
(
summary
.
getId
()
==
null
)
{
sportUserSummaryMapper
.
insert
(
summary
);
}
else
{
sportUserSummaryMapper
.
updateById
(
summary
);
}
}
}
server-api/src/main/resources/application.yaml
View file @
5a8f5e4d
server
:
server
:
port
:
808
1
port
:
808
8
spring
:
spring
:
application
:
application
:
name
:
"
antai-sport-http-server-server-api"
name
:
"
antai-sport-http-server-server-api"
...
...
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