|
@@ -38,32 +38,31 @@ class BeginFaceReco extends API {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async onRequest(req, res) {
|
|
async onRequest(req, res) {
|
|
|
- let { student_num, name, captcha, id } = req.body
|
|
|
|
|
|
|
+ let { face_code } = req.body
|
|
|
|
|
|
|
|
- if ([student_num, name, captcha, id].some(value => value === '' || value === null || value === undefined))
|
|
|
|
|
|
|
+ if ([face_code].some(value => value === '' || value === null || value === undefined))
|
|
|
return res.json({
|
|
return res.json({
|
|
|
...BaseStdResponse.MISSING_PARAMETER
|
|
...BaseStdResponse.MISSING_PARAMETER
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- const code = await Redis.get(`captcha:${id}`)
|
|
|
|
|
- if (!code || code != captcha.toLowerCase())
|
|
|
|
|
- return res.json({
|
|
|
|
|
- ...BaseStdResponse.ERR,
|
|
|
|
|
- msg: '验证码错误或已过期!'
|
|
|
|
|
- })
|
|
|
|
|
- Redis.del(`captcha:${id}`);
|
|
|
|
|
- } catch (err) {
|
|
|
|
|
- this.logger.error(`验证图片验证码失败!${err.stack}`)
|
|
|
|
|
- return res.json({
|
|
|
|
|
- ...BaseStdResponse.DATABASE_ERR,
|
|
|
|
|
- msg: '验证失败!'
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- let sql = 'SELECT student_num, name, user_avatar, academy_name FROM lepao_account WHERE student_num = ? AND name = ?'
|
|
|
|
|
- let rows = await db.query(sql, [student_num, name])
|
|
|
|
|
|
|
+ let sql = `
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ f.student_num,
|
|
|
|
|
+ l.name,
|
|
|
|
|
+ l.user_avatar,
|
|
|
|
|
+ l.academy_name,
|
|
|
|
|
+ l.state
|
|
|
|
|
+ FROM
|
|
|
|
|
+ lepao_face f
|
|
|
|
|
+ JOIN
|
|
|
|
|
+ lepao_account l
|
|
|
|
|
+ ON
|
|
|
|
|
+ f.student_num = l.student_num
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ f.face_code = ?
|
|
|
|
|
+ `
|
|
|
|
|
+ let rows = await db.query(sql, [face_code])
|
|
|
if (!rows)
|
|
if (!rows)
|
|
|
return res.json({
|
|
return res.json({
|
|
|
...BaseStdResponse.DATABASE_ERR,
|
|
...BaseStdResponse.DATABASE_ERR,
|
|
@@ -72,13 +71,18 @@ class BeginFaceReco extends API {
|
|
|
if (rows.length !== 1)
|
|
if (rows.length !== 1)
|
|
|
return res.json({
|
|
return res.json({
|
|
|
...BaseStdResponse.ERR,
|
|
...BaseStdResponse.ERR,
|
|
|
- msg: '该用户尚未在RunForge系统中添加,请先添加账号'
|
|
|
|
|
|
|
+ msg: '采集码输入错误'
|
|
|
|
|
+ })
|
|
|
|
|
+ if(rows[0].state !== 1)
|
|
|
|
|
+ return res.json({
|
|
|
|
|
+ ...BaseStdResponse.ERR,
|
|
|
|
|
+ msg: '账号状态为未登录,请用登录器更新账号状态后再进行人脸识别'
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const face_img = await this.getImageBase64('https://lepao-cloud.xxoo365.top/view.php/d0b85269c3683ed48da1fc5e468108c7.jpg')
|
|
const face_img = await this.getImageBase64('https://lepao-cloud.xxoo365.top/view.php/d0b85269c3683ed48da1fc5e468108c7.jpg')
|
|
|
// 此时应该从乐跑获取人脸照片
|
|
// 此时应该从乐跑获取人脸照片
|
|
|
-
|
|
|
|
|
- const key = uuidv4()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const key = uuidv4()
|
|
|
|
|
|
|
|
await Redis.set(`faceReco:${rows[0].student_num}`, key, {
|
|
await Redis.set(`faceReco:${rows[0].student_num}`, key, {
|
|
|
EX: 1800
|
|
EX: 1800
|