From d3eefdbc39a0cf009cfc9cfd0e1b526b557fa22b Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 11 May 2021 18:34:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=92=E8=A1=8C=E6=A6=9C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/api.md | 35 ++++++++++++++++++++++-- src/api/controllers/puzzle.controller.ts | 10 +++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/doc/api.md b/doc/api.md index fedc594..9090742 100644 --- a/doc/api.md +++ b/doc/api.md @@ -160,9 +160,40 @@ "type": 1, // 题目类型 1: 普通的文字选择题, 2: 图形 "quality": 1 // 题目难度 }] +``` + +### 5. 获取排行榜 + +1. Method: POST +2. URI: /api/:accountid/puzzle/rank + +| 字段 | 说明 | +| -------- | -------------------------------------- | +| accountid | 帐号id | + +> POST参数 +| 字段 | 说明 | +| -------- | -------------------------------------- | +| shop | 店铺id | +| level | 关卡id | +| mode | 游戏类型, 0: 单人, 1: 多人 | +| skip | 数据开始的偏移值, 从0开始, 默认0 | +| limit | 每次返回的数量条数, 默认10 | +3. Response: JSON - - +```js +{ + userRank: 1, //当前帐号的排名 + rankList: [ + [ + 'account id', 帐号id + 'rank', 排名 + 'nickname', 昵称(暂无) + 'avatar' 头像 + ] + ] +} +``` \ No newline at end of file diff --git a/src/api/controllers/puzzle.controller.ts b/src/api/controllers/puzzle.controller.ts index 6fbbabf..81f7e6d 100644 --- a/src/api/controllers/puzzle.controller.ts +++ b/src/api/controllers/puzzle.controller.ts @@ -284,4 +284,14 @@ class PuzzleController extends BaseController { return { roomId, beginTime,sessionId, session: sessionMatch } } + + @role('anon') + @router('post /api/:accounid/puzzle/rank') + async singleRank(req, res) { + let {shop, level, accountid, mode, skip, limit} = req.params + skip = skip || 0 + limit = limit || 10 + let {rankList, userRank } = await getRank({shop, level, accountId: accountid, mode, skip, limit}) + return {rankList, userRank} + } }