|
|
@ -6,46 +6,68 @@ var path = require('path'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.post('/add', function (req, res) { |
|
|
|
router.post('/add', function (req, res) { |
|
|
|
|
|
|
|
let flag = false; |
|
|
|
|
|
|
|
let emptyFieldsArray =[] |
|
|
|
const userInfo = { |
|
|
|
const userInfo = { |
|
|
|
firstName: req.body.firstName, |
|
|
|
firstName: req.body.firstName.trim(), |
|
|
|
lastName: req.body.lastName, |
|
|
|
lastName: req.body.lastName.trim(), |
|
|
|
fatherName: req.body.fatherName, |
|
|
|
fatherName: req.body.fatherName.trim(), |
|
|
|
codeMelli: req.body.codeMelli, |
|
|
|
codeMelli: req.body.codeMelli.trim(), |
|
|
|
workUnit: req.body.workUnit, |
|
|
|
workUnit: req.body.workUnit.trim(), |
|
|
|
workUnitCode: req.body.workUnitCode, |
|
|
|
workUnitCode: req.body.workUnitCode.trim(), |
|
|
|
address: req.body.address, |
|
|
|
address: req.body.address.trim(), |
|
|
|
obligationNumber: req.body.obligationNumber, |
|
|
|
obligationNumber: req.body.obligationNumber.trim(), |
|
|
|
obligationDate: req.body.obligationDate, |
|
|
|
obligationDate: req.body.obligationDate.trim(), |
|
|
|
requestNumber: req.body.requestNumber, |
|
|
|
requestNumber: req.body.requestNumber.trim(), |
|
|
|
requestDate: req.body.requestDate, |
|
|
|
requestDate: req.body.requestDate.trim(), |
|
|
|
writtenOrderNumber: req.body.writtenOrderNumber, |
|
|
|
writtenOrderNumber: req.body.writtenOrderNumber.trim(), |
|
|
|
writtenOrderDate: req.body.writtenOrderDate, |
|
|
|
writtenOrderDate: req.body.writtenOrderDate.trim(), |
|
|
|
deadline: req.body.deadline |
|
|
|
deadline: req.body.deadline.trim(), |
|
|
|
|
|
|
|
deadlineUnit: req.body.deadlineUnit.trim(), |
|
|
|
|
|
|
|
healthCenter: req.body.healthCenter.trim(), |
|
|
|
|
|
|
|
healthCenterCity: req.body.healthCenterCity.trim() |
|
|
|
} |
|
|
|
} |
|
|
|
userServeice.addUser(userInfo) |
|
|
|
for (const key in userInfo) { |
|
|
|
.then((result) => { |
|
|
|
if (!userInfo[key] || !userInfo[key].trim()) { |
|
|
|
res.status(200).send({ |
|
|
|
emptyFieldsArray.push(key) |
|
|
|
success: true, |
|
|
|
flag = true |
|
|
|
user: result |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(flag){ |
|
|
|
|
|
|
|
res.status(406).send({ |
|
|
|
|
|
|
|
success: false, |
|
|
|
|
|
|
|
emptyFields : emptyFieldsArray, |
|
|
|
|
|
|
|
error: `پر کردن همه فیلدها الزامی است` |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
}else { |
|
|
|
if (err.eText) { |
|
|
|
userServeice.addUser(userInfo) |
|
|
|
if (typeof err.eText !== 'string') { |
|
|
|
.then((result) => { |
|
|
|
err.eText = err.eText.toString() |
|
|
|
res.status(200).send({ |
|
|
|
} |
|
|
|
success: true, |
|
|
|
res.status(err.eCode).send({ |
|
|
|
user: result |
|
|
|
success: false, |
|
|
|
|
|
|
|
error: err.eText |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
}) |
|
|
|
res.status(500).send({ |
|
|
|
.catch(err => { |
|
|
|
success: false, |
|
|
|
if (err.eText) { |
|
|
|
error: err.toString() |
|
|
|
if (typeof err.eText !== 'string') { |
|
|
|
}) |
|
|
|
err.eText = err.eText.toString() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
res.status(err.eCode).send({ |
|
|
|
|
|
|
|
success: false, |
|
|
|
|
|
|
|
error: err.eText |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
res.status(500).send({ |
|
|
|
|
|
|
|
success: false, |
|
|
|
|
|
|
|
error: err.toString() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
router.post('/complete/form', function (req, res) { |
|
|
|
router.post('/complete/form', function (req, res) { |
|
|
@ -57,6 +79,7 @@ router.post('/complete/form', function (req, res) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
.catch(err => { |
|
|
|
|
|
|
|
console.log(err); |
|
|
|
if (err.eText) { |
|
|
|
if (err.eText) { |
|
|
|
if (typeof err.eText !== 'string') { |
|
|
|
if (typeof err.eText !== 'string') { |
|
|
|
err.eText = err.eText.toString() |
|
|
|
err.eText = err.eText.toString() |
|
|
|