增加一个分页查询用户积分记录的接口
This commit is contained in:
parent
2a145b7f37
commit
4aa9443c89
40
docs/uaw.md
40
docs/uaw.md
@ -1209,3 +1209,43 @@ body:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### 41.\* 积分详情列表(分页)
|
||||||
|
|
||||||
|
#### Request
|
||||||
|
|
||||||
|
- URL:`/api/activity/user_score_list`
|
||||||
|
- 方法:`POST`
|
||||||
|
- 头部:
|
||||||
|
- Authorization: Bearer JWT_token
|
||||||
|
|
||||||
|
body:
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"page": 0, // 第几页
|
||||||
|
"limit": 8, // 每页数据数量
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
####
|
||||||
|
|
||||||
|
#### Response
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"page": 0,
|
||||||
|
"limit": 8,
|
||||||
|
"total": 1000,
|
||||||
|
"records": [{
|
||||||
|
"score": 100, // 获得的积分
|
||||||
|
"type": "", // 获取原因
|
||||||
|
"time": 111 // 开启时间
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
###
|
@ -145,6 +145,37 @@ export default class ActivityController extends BaseController {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@router('post /api/activity/user_score_list')
|
||||||
|
async myScoreList(req) {
|
||||||
|
let user = req.user
|
||||||
|
let { page, limit } = req.params
|
||||||
|
page = parseInt(page || '0')
|
||||||
|
limit = parseInt(limit || 8)
|
||||||
|
page = page < 0 ? 0 : page
|
||||||
|
const _records = await ScoreRecord.find({ user: user.id })
|
||||||
|
.sort({
|
||||||
|
createdAt: -1,
|
||||||
|
})
|
||||||
|
.skip(page * limit)
|
||||||
|
.limit(limit)
|
||||||
|
|
||||||
|
const total = await ScoreRecord.countDocuments({ user: user.id })
|
||||||
|
let records = _records.map(record => {
|
||||||
|
return {
|
||||||
|
score: formatNumShow(record.score),
|
||||||
|
type: record.type,
|
||||||
|
//@ts-ignore
|
||||||
|
time: record.createdAt.getTime(),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
total,
|
||||||
|
records,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@role(ROLE_ANON)
|
@role(ROLE_ANON)
|
||||||
@router('get /api/activity/leaderboard/:activity/:page')
|
@router('get /api/activity/leaderboard/:activity/:page')
|
||||||
async inviteCode(req) {
|
async inviteCode(req) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user