add file name

master
shoaibalmasi 4 years ago
parent c6b0168757
commit 6992ab47b4
  1. 15
      migrations/20210315204118-change-codeMelli-type.js
  2. 18
      migrations/20210315204918-add-filename-column.js
  3. 10
      models/user.js
  4. 4
      services/user.js

@ -0,0 +1,15 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.changeColumn('Users', 'codeMelli', {
type: Sequelize.BIGINT ,
}),
]);
},
down: (queryInterface) => {
return Promise.all([queryInterface.changeColumn('Users', 'codeMelli')]);
},
};

@ -0,0 +1,18 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.addColumn('Users', 'fileName', {
type: Sequelize.STRING,
allowNull: false,
defaultValue: 'Hform4.docx'
}),
]);
},
down: (queryInterface) => {
return Promise.all([queryInterface.removeColumn('Users', 'fileName')]);
},
};

@ -17,7 +17,7 @@ module.exports = (sequelize, DataTypes) => {
firstName: DataTypes.STRING,
lastName: DataTypes.STRING,
fatherName: DataTypes.STRING,
codeMelli: DataTypes.INTEGER,
codeMelli: DataTypes.BIGINT,
workUnit: DataTypes.STRING,
workUnitCode: DataTypes.INTEGER,
address: DataTypes.TEXT,
@ -27,7 +27,13 @@ module.exports = (sequelize, DataTypes) => {
requestDate: DataTypes.DATE,
writtenOrderNumber: DataTypes.INTEGER,
writtenOrderDate: DataTypes.DATE,
deadline: DataTypes.INTEGER
deadline: DataTypes.INTEGER,
fileName:{
type: DataTypes.STRING,
allowNull: false,
defaultValue: 'Hform4.docx'
}
}, {
sequelize,
modelName: 'User',

@ -61,11 +61,11 @@ methods.completeForm =(userId)=>{
userInfo.requestDate = jalali( user.requestDate, '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, userInfo.fileName)
}).then(link=>{
resolve(link)
}).catch(err => {
if (err.eText) {
if (typeof (err.eText) !== 'string') {

Loading…
Cancel
Save