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