diff --git a/docs/uaw.md b/docs/uaw.md index 48b55f2..e529a18 100644 --- a/docs/uaw.md +++ b/docs/uaw.md @@ -1208,4 +1208,44 @@ body: "rarity": "", // Common, Rare, Legendary } ] -``` \ No newline at end of file +``` + + + +### 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 // 开启时间 + }] +} +``` + +### \ No newline at end of file diff --git a/src/controllers/activity.controller.ts b/src/controllers/activity.controller.ts index 5b7ca1e..c14f3ea 100644 --- a/src/controllers/activity.controller.ts +++ b/src/controllers/activity.controller.ts @@ -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) @router('get /api/activity/leaderboard/:activity/:page') async inviteCode(req) {