|
|
@@ -9,6 +9,9 @@ class AddAccount extends API {
|
|
|
|
|
|
this.setPath('/Lepao/Account')
|
|
|
this.setMethod('POST')
|
|
|
+
|
|
|
+ this.emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
|
|
|
+ this.banEmailList = ['icloud.com']
|
|
|
}
|
|
|
|
|
|
// 生成 6 位数字 + 字母混合码
|
|
|
@@ -40,12 +43,34 @@ class AddAccount extends API {
|
|
|
...BaseStdResponse.MISSING_PARAMETER
|
|
|
})
|
|
|
|
|
|
+ if (isNaN(target_count) || target_count < 0 || target_count > 99) {
|
|
|
+ return res.json({
|
|
|
+ ...BaseStdResponse.ERR,
|
|
|
+ msg: '乐跑目标次数不在合法范围内'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!this.emailRegex.test(email)) {
|
|
|
+ Message.error('请检查邮箱格式是否正确')
|
|
|
+ return res.json({
|
|
|
+ ...BaseStdResponse.ERR,
|
|
|
+ msg: '请检查邮箱格式是否正确'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const emailDomain = email.split('@')[1].toLowerCase()
|
|
|
+ if (this.banEmailList.includes(emailDomain))
|
|
|
+ return res.json({
|
|
|
+ ...BaseStdResponse.ERR,
|
|
|
+ msg: `暂不支持使用 ${emailDomain} 域名的邮箱,请更换其他邮箱后重试`
|
|
|
+ })
|
|
|
+
|
|
|
if (!await AccessControl.checkSession(uuid, session))
|
|
|
return res.status(401).json({
|
|
|
...BaseStdResponse.ACCESS_DENIED
|
|
|
})
|
|
|
|
|
|
- let countSql = 'SELECT id, create_user FROM lepao_account WHERE student_num = ?'
|
|
|
+ let countSql = 'SELECT id, create_user, total_num FROM lepao_account WHERE student_num = ?'
|
|
|
let countRows = await db.query(countSql, [student_num])
|
|
|
|
|
|
if (!countRows)
|
|
|
@@ -60,6 +85,11 @@ class AddAccount extends API {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (countRows.length !== 0) {
|
|
|
+ if (countRows[0].total_num >= target_count && target_count !== 0)
|
|
|
+ return res.json({ ...BaseStdResponse.ERR, msg: '该账号累计跑步次数已达到目标次数,请尝试修改目标次数' })
|
|
|
+ }
|
|
|
+
|
|
|
const time = new Date().getTime()
|
|
|
|
|
|
let sql, r
|