This commit is contained in:
2024-08-10 20:35:02 +08:00
parent 88233c58e3
commit 90f6ed0bc3
50 changed files with 5333 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
const express = require('express');
const router = express.Router();
const { Logger } = require('@plugs/Logger');
const { STANDARDRESPONSE } = require('@root/STANDARDRESPONSE')
const { RotationVerificationService } = require('@plugs/Service/RotationVerificationService');
Logger.info(`[API][/hmv/checkRotationVerification] 加载成功`);
// 验证旋转验证传入RVSession和用户旋转角度返回验证结果
router.post('/checkRotationVerification', async (req, res) => {
let { session, angle } = req.body;
// session为RVSession(32位UUID)angle为用户旋转角度
if(!session || !angle || session.length != 32){
Logger.warn(`[API][/hmv/checkRotationVerification]参数缺失或错误(session=${session}, angle=${angle})`);
res.json({...STANDARDRESPONSE.PARAMETER_MISSING});
return;
}
let result = await RotationVerificationService.check(session,angle);
switch(result){
case 0:
Logger.info(`[API][/hmv/checkRotationVerification] session[${session}]已过期,验证未通过`);
res.json({...STANDARDRESPONSE.ROTATION_VERIFICATION_EXPIRED, endpoint: result});
return;
case -1:
Logger.info(`[API][/hmv/checkRotationVerification] session[${session}]验证次数已达上限,验证未通过`);
res.json({...STANDARDRESPONSE.ROTATION_VERIFICATION_MAX_ATTEMPTS, endpoint: result});
return;
case -2:
Logger.info(`[API][/hmv/checkRotationVerification] session[${session}]验证角度差异过大,验证未通过`);
res.json({...STANDARDRESPONSE.ROTATION_VERIFICATION_ANGLE_DIFFERENCE, endpoint: result});
return;
}
Logger.info(`[API][/hmv/checkRotationVerification] session[${session}]验证通过`);
res.json({...STANDARDRESPONSE.OK});
})
module.exports = router;