|
@@ -36,9 +36,9 @@ class AddAccount extends API {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async onRequest(req, res) {
|
|
async onRequest(req, res) {
|
|
|
- let { uuid, session, student_num, email, id, area, auto_time, auto_run, target_count, notes } = req.body
|
|
|
|
|
|
|
+ let { uuid, session, student_num, email, id, area, auto_time, auto_run, target_count, auto_day, notes } = req.body
|
|
|
|
|
|
|
|
- if ([uuid, session, student_num, email, auto_time, target_count].some(value => value === '' || value === null || value === undefined))
|
|
|
|
|
|
|
+ if ([uuid, session, student_num, email, auto_time, target_count, auto_day].some(value => value === '' || value === null || value === undefined))
|
|
|
return res.json({
|
|
return res.json({
|
|
|
...BaseStdResponse.MISSING_PARAMETER
|
|
...BaseStdResponse.MISSING_PARAMETER
|
|
|
})
|
|
})
|
|
@@ -64,6 +64,12 @@ class AddAccount extends API {
|
|
|
msg: `暂不支持使用 ${emailDomain} 域名的邮箱,请更换其他邮箱后重试`
|
|
msg: `暂不支持使用 ${emailDomain} 域名的邮箱,请更换其他邮箱后重试`
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ if (auto_run === 1 && (!Array.isArray(auto_day) || !auto_day.every(v => Number.isInteger(v) && v >= 0 && v <= 6)))
|
|
|
|
|
+ return res.json({
|
|
|
|
|
+ ...BaseStdResponse.ERR,
|
|
|
|
|
+ msg: '自动乐跑日期格式不合法'
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
if (!await AccessControl.checkSession(uuid, session))
|
|
if (!await AccessControl.checkSession(uuid, session))
|
|
|
return res.status(401).json({
|
|
return res.status(401).json({
|
|
|
...BaseStdResponse.ACCESS_DENIED
|
|
...BaseStdResponse.ACCESS_DENIED
|
|
@@ -95,14 +101,14 @@ class AddAccount extends API {
|
|
|
|
|
|
|
|
if (!id) {
|
|
if (!id) {
|
|
|
if (countRows.length !== 0) {
|
|
if (countRows.length !== 0) {
|
|
|
- sql = 'UPDATE lepao_account SET create_user = ?, email = ?, area = ?, auto_time = ?, auto_run = ?, target_count = ?, create_time = ?, notes = ? WHERE id = ?'
|
|
|
|
|
- r = await db.query(sql, [uuid, email, area, auto_time, auto_run, target_count, time, notes ?? '', countRows[0].id])
|
|
|
|
|
|
|
+ sql = 'UPDATE lepao_account SET create_user = ?, email = ?, area = ?, auto_time = ?, auto_run = ?, target_count = ?, create_time = ?, notes = ?, auto_day = ? WHERE id = ?'
|
|
|
|
|
+ r = await db.query(sql, [uuid, email, area, auto_time, auto_run, target_count, time, notes ?? '', JSON.stringify(auto_day), countRows[0].id])
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
const face_code = await this.generateCode()
|
|
const face_code = await this.generateCode()
|
|
|
|
|
|
|
|
- sql = 'INSERT INTO lepao_account (student_num, email, area, auto_time, auto_run, target_count, create_user, create_time, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
|
|
|
|
|
- r = await db.query(sql, [student_num, email, area, auto_time, auto_run, target_count, uuid, time, notes ?? ''])
|
|
|
|
|
|
|
+ sql = 'INSERT INTO lepao_account (student_num, email, area, auto_time, auto_run, target_count, create_user, create_time, notes, auto_day) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
|
|
|
|
+ r = await db.query(sql, [student_num, email, area, auto_time, auto_run, target_count, uuid, time, notes ?? '', JSON.stringify(auto_day)])
|
|
|
|
|
|
|
|
let faceSql = 'INSERT INTO lepao_face (student_num, face_code) VALUES (?, ?)'
|
|
let faceSql = 'INSERT INTO lepao_face (student_num, face_code) VALUES (?, ?)'
|
|
|
let faceRows = await db.query(faceSql, [student_num, face_code])
|
|
let faceRows = await db.query(faceSql, [student_num, face_code])
|
|
@@ -110,8 +116,8 @@ class AddAccount extends API {
|
|
|
return res.json({ ...BaseStdResponse.ERR, msg: '添加乐跑账号失败!数据库错误' })
|
|
return res.json({ ...BaseStdResponse.ERR, msg: '添加乐跑账号失败!数据库错误' })
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- sql = 'UPDATE lepao_account SET student_num = ?, email = ?, area = ?, auto_time = ?, target_count = ?, auto_run = ?, notes = ? WHERE id = ?'
|
|
|
|
|
- r = await db.query(sql, [student_num, email, area, auto_time, target_count, auto_run, notes ?? '', id])
|
|
|
|
|
|
|
+ sql = 'UPDATE lepao_account SET student_num = ?, email = ?, area = ?, auto_time = ?, target_count = ?, auto_run = ?, notes = ?, auto_day = ? WHERE id = ?'
|
|
|
|
|
+ r = await db.query(sql, [student_num, email, area, auto_time, target_count, auto_run, notes ?? '', JSON.stringify(auto_day), id])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|