app.post('/excel/students/add', (req, res) => { const { data, templateId, username } = req.body const templateIsExist = db.get('students.'+ templateId).value() if (!templateIsExist) { db.set('students.'+ templateId, []).write() } const studentsDB = db.get('students.'+ templateId) const flag = data.every(v=>{ const isDul = studentsDB.find({'身份证号': v.身份证号}).value() if (isDul) { v.error = true } return !isDul; }) if (flag) { data.map(v=>{ studentsDB.insert({...initObj(v),username: username}).write() }) const peopleCount = studentsDB.size() db.get('template').find({id: templateId}).assign({peopleCount: peopleCount}).write() resultSend(res, true, '添加') } else { const repeatData = data.filter(v=>v.error = true) res.send(resultFail('添加失败,存在重复的身份证号', repeatData)) } })