|
|
|
@ -5,79 +5,77 @@ const fs = require('fs') |
|
|
|
|
var path = require('path'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.post('/add', function(req, res) { |
|
|
|
|
const userInfo ={ |
|
|
|
|
firstName : req.body.firstName, |
|
|
|
|
lastName : req.body.lastName, |
|
|
|
|
fatherName : req.body.fatherName, |
|
|
|
|
codeMelli : req.body.codeMelli, |
|
|
|
|
workUnit : req.body.workUnit, |
|
|
|
|
workUnitCode : req.body.workUnitCode, |
|
|
|
|
address : req.body.address, |
|
|
|
|
obligationNumber : req.body.obligationNumber, |
|
|
|
|
obligationDate : req.body.obligationDate, |
|
|
|
|
requestNumber : req.body.requestNumber, |
|
|
|
|
requestDate : req.body.requestDate, |
|
|
|
|
writtenOrderNumber : req.body.writtenOrderNumber, |
|
|
|
|
writtenOrderDate : req.body.writtenOrderDate, |
|
|
|
|
deadline : req.body.deadline |
|
|
|
|
router.post('/add', function (req, res) { |
|
|
|
|
const userInfo = { |
|
|
|
|
firstName: req.body.firstName, |
|
|
|
|
lastName: req.body.lastName, |
|
|
|
|
fatherName: req.body.fatherName, |
|
|
|
|
codeMelli: req.body.codeMelli, |
|
|
|
|
workUnit: req.body.workUnit, |
|
|
|
|
workUnitCode: req.body.workUnitCode, |
|
|
|
|
address: req.body.address, |
|
|
|
|
obligationNumber: req.body.obligationNumber, |
|
|
|
|
obligationDate: req.body.obligationDate, |
|
|
|
|
requestNumber: req.body.requestNumber, |
|
|
|
|
requestDate: req.body.requestDate, |
|
|
|
|
writtenOrderNumber: req.body.writtenOrderNumber, |
|
|
|
|
writtenOrderDate: req.body.writtenOrderDate, |
|
|
|
|
deadline: req.body.deadline |
|
|
|
|
} |
|
|
|
|
userServeice.addUser(userInfo) |
|
|
|
|
.then((result) => { |
|
|
|
|
res.status(200).send({ |
|
|
|
|
success: true, |
|
|
|
|
user: result |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
.catch(err => { |
|
|
|
|
if (err.eText) { |
|
|
|
|
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() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
res.status(200).send({ |
|
|
|
|
success: true, |
|
|
|
|
user: result |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
.catch(err => { |
|
|
|
|
if (err.eText) { |
|
|
|
|
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) { |
|
|
|
|
userServeice.completeForm(req.body.userId) |
|
|
|
|
.then((result) => { |
|
|
|
|
console.log('sssssssssssssssssssss'); |
|
|
|
|
console.log(result); |
|
|
|
|
res.status(200).send({ |
|
|
|
|
success: true, |
|
|
|
|
user: result |
|
|
|
|
.then((result) => { |
|
|
|
|
res.status(200).send({ |
|
|
|
|
success: true, |
|
|
|
|
link: result |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
.catch(err => { |
|
|
|
|
if (err.eText) { |
|
|
|
|
if (typeof err.eText !== 'string') { |
|
|
|
|
err.eText = err.eText.toString() |
|
|
|
|
.catch(err => { |
|
|
|
|
if (err.eText) { |
|
|
|
|
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() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
res.status(err.eCode).send({ |
|
|
|
|
success: false, |
|
|
|
|
error: err.eText |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
res.status(500).send({ |
|
|
|
|
success: false, |
|
|
|
|
error: err.toString() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
router.get('/download/:fileName', function(req, res){ |
|
|
|
|
router.get('/download/:fileName', function (req, res) { |
|
|
|
|
var file = fs.readFileSync(path.join(__dirname + `/../public/files/${req.params.fileName}`), 'binary'); |
|
|
|
|
|
|
|
|
|
res.setHeader('Content-Length', file.length); |
|
|
|
|