From 4aa9443c89365197bd1b3e2fce233e30bf4bef64 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Sat, 11 May 2024 10:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E6=9F=A5=E8=AF=A2=E7=94=A8=E6=88=B7=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/uaw.md | 42 +++++++++++++++++++++++++- src/controllers/activity.controller.ts | 31 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) 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) {