|
|
@ -7,10 +7,14 @@ let methods = {} |
|
|
|
let privates = { |
|
|
|
let privates = { |
|
|
|
findUser : (userId)=>{ |
|
|
|
findUser : (userId)=>{ |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
|
|
|
|
models.User.findByPk(userId) |
|
|
|
models.User.findByPk(userId) |
|
|
|
|
|
|
|
|
|
|
|
.then((user) => { |
|
|
|
.then((user) => { |
|
|
|
if(user){ |
|
|
|
if(user){ |
|
|
|
|
|
|
|
|
|
|
|
resolve(user.dataValues) |
|
|
|
resolve(user.dataValues) |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
reject({ |
|
|
|
reject({ |
|
|
|
eCode: 404, |
|
|
|
eCode: 404, |
|
|
@ -33,7 +37,7 @@ let privates = { |
|
|
|
methods.addUser = (userInfo) => { |
|
|
|
methods.addUser = (userInfo) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
models.User.create(userInfo).then((user) => { |
|
|
|
models.User.create(userInfo).then((user) => { |
|
|
|
console.log(user); |
|
|
|
|
|
|
|
resolve(user) |
|
|
|
resolve(user) |
|
|
|
|
|
|
|
|
|
|
|
}).catch(err => { |
|
|
|
}).catch(err => { |
|
|
@ -50,6 +54,7 @@ methods.completeForm =(userId)=>{ |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
privates.findUser(userId) |
|
|
|
privates.findUser(userId) |
|
|
|
.then(user=>{ |
|
|
|
.then(user=>{ |
|
|
|
|
|
|
|
|
|
|
|
let userInfo = user |
|
|
|
let userInfo = user |
|
|
|
userInfo.fullName = user.firstName + ' ' + user.lastName |
|
|
|
userInfo.fullName = user.firstName + ' ' + user.lastName |
|
|
|
userInfo.obligationDate = jalali( user.obligationDate, 'YYYY/MM/DD').locale('fa').format('YYYY/MM/DD') |
|
|
|
userInfo.obligationDate = jalali( user.obligationDate, 'YYYY/MM/DD').locale('fa').format('YYYY/MM/DD') |
|
|
@ -57,8 +62,10 @@ methods.completeForm =(userId)=>{ |
|
|
|
userInfo.writtenOrderDate = jalali( user.writtenOrderDate, 'YYYY/MM/DD').locale('fa').format('YYYY/MM/DD') |
|
|
|
userInfo.writtenOrderDate = jalali( user.writtenOrderDate, 'YYYY/MM/DD').locale('fa').format('YYYY/MM/DD') |
|
|
|
|
|
|
|
|
|
|
|
return docxTemp(userInfo, 'Hform4.docx') |
|
|
|
return docxTemp(userInfo, 'Hform4.docx') |
|
|
|
}).then(text=>{ |
|
|
|
}).then(link=>{ |
|
|
|
resolve(text) |
|
|
|
|
|
|
|
|
|
|
|
resolve(link) |
|
|
|
|
|
|
|
|
|
|
|
}).catch(err => { |
|
|
|
}).catch(err => { |
|
|
|
if (err.eText) { |
|
|
|
if (err.eText) { |
|
|
|
if (typeof (err.eText) !== 'string') { |
|
|
|
if (typeof (err.eText) !== 'string') { |
|
|
|