助力记录增加按code查询

This commit is contained in:
CounterFire2023 2024-04-16 21:45:59 +08:00
parent fbb9aba160
commit dce75b563b

View File

@ -66,12 +66,23 @@ class BoxController extends BaseController {
@role(ROLE_ANON)
@router('post /api/chest/enhance/list')
async enhanceList(req) {
let { chestId, chestid } = req.params
let { chestId, chestid, code } = req.params
chestid = chestId || chestid
if (!isObjectIdString(chestid)) {
throw new ZError(11, 'must provide valid chestid')
if (code && !isValidShareCode(code)) {
throw new ZError(11, 'invalid share code')
}
if (chestid && !isObjectIdString(chestid)) {
throw new ZError(11, 'invalid chest id')
}
if (!code && !chestId) {
throw new ZError(11, 'must provide share code or chest id')
}
let chest: any
if (chestId) {
chest = await ActivityChest.findById(chestId)
} else {
chest = await ActivityChest.findOne({ shareCode: code })
}
const chest = await ActivityChest.findById(chestid)
if (!chest) {
throw new ZError(12, 'chest not found')
}