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
ef2c8c1a
Commit
ef2c8c1a
authored
Aug 19, 2022
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
积分查询接口
parent
c7f82a46
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
SportUserTrainingLogService.java
...ness/traininglog/service/SportUserTrainingLogService.java
+30
-0
SportUserController.java
...ver/api/business/user/controller/SportUserController.java
+14
-2
CalcCurrencyDTO.java
.../server/server/api/business/user/dto/CalcCurrencyDTO.java
+12
-0
No files found.
server-api/src/main/java/com/antai/sport/http/server/server/api/business/traininglog/service/SportUserTrainingLogService.java
View file @
ef2c8c1a
...
...
@@ -138,6 +138,36 @@ public class SportUserTrainingLogService {
achievementService
.
handleSportAchievement
(
gameMode
,
summary
);
}
/**
* 计算积分
* @param gameMode
* @param calorie
* @param rank
* @return
*/
public
Integer
calcCurrency
(
Integer
gameMode
,
Integer
calorie
,
Integer
rank
){
if
(
calorie
==
null
||
calorie
==
0
)
{
return
0
;
}
List
<
SportUserGameCurrencyBaseRule
>
baseRule
=
sportUserGameCurrencyBaseRuleMapper
.
selectList
(
null
);
if
(
baseRule
.
size
()
==
0
||
baseRule
.
get
(
0
).
getCoefficient
()
==
null
)
{
return
0
;
}
Integer
coefficient
=
baseRule
.
get
(
0
).
getCoefficient
();
Integer
currency
=
calorie
/
coefficient
;
if
(
currency
==
0
)
{
return
0
;
}
if
(
rank
!=
null
){
SportUserGameCurrencyMatchRule
matchRule
=
sportUserGameCurrencyMatchRuleMapper
.
selectOne
(
new
QueryWrapper
<
SportUserGameCurrencyMatchRule
>().
lambda
().
eq
(
SportUserGameCurrencyMatchRule:
:
getGameMode
,
gameMode
).
le
(
SportUserGameCurrencyMatchRule:
:
getRankStart
,
rank
).
ge
(
SportUserGameCurrencyMatchRule:
:
getRankEnd
,
rank
));
if
(
matchRule
!=
null
&&
matchRule
.
getRate
()
!=
null
)
{
currency
=
matchRule
.
getRate
().
multiply
(
BigDecimal
.
valueOf
(
currency
)).
intValue
();
}
}
return
currency
;
}
/**
* 处理用户积分
*
...
...
server-api/src/main/java/com/antai/sport/http/server/server/api/business/user/controller/SportUserController.java
View file @
ef2c8c1a
...
...
@@ -45,7 +45,10 @@ public class SportUserController {
@ApiOperation
(
"查询我的排名 type: 1能力榜 2活跃度榜"
)
@GetMapping
(
"/{userId}/rank"
)
public
ResponseEntity
<
Result
<
SportUserMonthRankResponseDTO
>>
getMyRank
(
@PathVariable
(
"userId"
)
Long
userId
,
@RequestParam
Integer
type
,
@RequestParam
Integer
year
,
@RequestParam
Integer
month
)
{
public
ResponseEntity
<
Result
<
SportUserMonthRankResponseDTO
>>
getMyRank
(
@PathVariable
(
"userId"
)
Long
userId
,
@RequestParam
Integer
type
,
@RequestParam
Integer
year
,
@RequestParam
Integer
month
)
{
return
success
(
sportUserTrainingLogService
.
getMyRank
(
userId
,
type
,
year
,
month
));
}
...
...
@@ -59,7 +62,9 @@ public class SportUserController {
@ApiOperation
(
"查询玩家运动日历"
)
@PostMapping
(
"/{userId}/schedule"
)
public
ResponseEntity
<
Result
<
List
<
ScheduleResponseDTO
>>>
getSchedule
(
@PathVariable
(
"userId"
)
Long
userId
,
@RequestParam
Integer
year
,
@RequestParam
Integer
month
)
{
public
ResponseEntity
<
Result
<
List
<
ScheduleResponseDTO
>>>
getSchedule
(
@PathVariable
(
"userId"
)
Long
userId
,
@RequestParam
Integer
year
,
@RequestParam
Integer
month
)
{
return
success
(
sportUserTrainingLogService
.
getSchedule
(
userId
,
year
,
month
));
}
...
...
@@ -94,4 +99,11 @@ public class SportUserController {
public
ResponseEntity
<
Result
<
NewMessageVO
>>
getUserNewMessage
(
@PathVariable
(
"sportUserId"
)
Long
sportUserId
)
{
return
success
(
sportUserService
.
getUserNewMessage
(
sportUserId
));
}
@ApiOperation
(
"根据卡路里、排名计算积分"
)
@GetMapping
(
"/calc/currency"
)
public
ResponseEntity
<
Result
<
Integer
>>
calcCurrency
(
@RequestBody
CalcCurrencyDTO
param
)
{
return
success
(
sportUserTrainingLogService
.
calcCurrency
(
param
.
getGameMode
(),
param
.
getCalorie
(),
param
.
getRank
()));
}
}
server-api/src/main/java/com/antai/sport/http/server/server/api/business/user/dto/CalcCurrencyDTO.java
0 → 100644
View file @
ef2c8c1a
package
com
.
antai
.
sport
.
http
.
server
.
server
.
api
.
business
.
user
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
@Data
@ApiModel
(
"积分计算接口"
)
public
class
CalcCurrencyDTO
{
private
Integer
gameMode
;
private
Integer
calorie
;
private
Integer
rank
;
}
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