增加boost接口

This commit is contained in:
CounterFire2023 2024-01-08 16:37:35 +08:00
parent c8500e9654
commit 171749b486
2 changed files with 32 additions and 2 deletions

View File

@ -312,4 +312,22 @@ body:
"invite": "邀请人address",
"code": "自己的邀请码"
}
```
### 11.\* boost
#### Request
- URL`/api/user/state/boost`
- 方法:`GET`
- 头部:
- Authorization: Bearer JWT_token
#### Response
```json
{
"boost": 1, // 正常值为1
"boostExpire": 0, // 计算得分时, 如果boost过期, 即使boost大于1, 也不计算boost
}
```

View File

@ -8,7 +8,7 @@ import { LoginRecordQueue } from 'queue/loginrecord.queue'
import { RedisClient } from 'redis/RedisClient'
import { rankKey } from 'services/rank.svr'
import {SiweMessage} from 'siwe'
import { yesterday } from 'utils/date.util'
import { nextday, yesterday } from 'utils/date.util'
import { checkParamsNeeded } from 'utils/net.util'
import { aesDecrypt, base58ToHex } from 'utils/security.util'
@ -23,7 +23,7 @@ class SignController extends BaseController {
await record.save()
return { nonce: record.id, tips: LOGIN_TIP }
}
//TODO:: 增加okx的奖励
@role(ROLE_ANON)
@router('post /api/wallet/login')
async walletVerify(req, res) {
@ -109,6 +109,18 @@ class SignController extends BaseController {
}
return result;
}
@router('get /api/user/state/boost')
async boost(req){
const user = req.user;
if (user.boost > 1 && user.boostExpire && user.boostExpire > Date.now()) {
throw new ZError(11, 'already boosted')
}
user.boost = 2;
user.boostExpire = nextday();
await user.save();
return { boost: user.boost, boostExpire: user.boostExpire };
}
/**
* regist user by token from wallet-svr
* TODO::