2017-06-12 11:41:02 +00:00
|
|
|
var path = require('path');
|
|
|
|
var database = require(path.join(__dirname, '../../database.js'));
|
|
|
|
|
2017-09-27 15:44:51 +00:00
|
|
|
module.exports = class NotificationNotice {
|
2017-06-12 11:41:02 +00:00
|
|
|
getData(params, cb) {
|
2017-08-31 14:11:37 +00:00
|
|
|
let query = `SELECT
|
|
|
|
LOWER(ct.code) countryCode,
|
|
|
|
c.email recipient,
|
|
|
|
nc.name categoryName,
|
|
|
|
recipient.name recipientName,
|
|
|
|
sender.name senderName
|
|
|
|
FROM client c
|
|
|
|
JOIN account.user recipient ON recipient.id = c.id
|
|
|
|
JOIN country ct ON ct.id = c.countryFk
|
|
|
|
JOIN noticeCategory nc ON nc.keyName = ?
|
|
|
|
JOIN account.user sender ON sender.id = ?
|
|
|
|
WHERE c.id = ?`;
|
|
|
|
database.pool.query(query, [params.category, params.sender, params.recipient], (error, result) => {
|
|
|
|
if (error || result.length == 0)
|
|
|
|
return cb({status: 'REJECT', data: {message: 'No data found', error: error}});
|
|
|
|
|
2017-06-12 11:41:02 +00:00
|
|
|
Object.assign(this, result[0]);
|
2017-08-31 14:11:37 +00:00
|
|
|
this.message = params.message;
|
|
|
|
|
|
|
|
cb({status: 'ACCEPT', data: {}});
|
2017-06-12 11:41:02 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|