28 lines
645 B
JavaScript
28 lines
645 B
JavaScript
let path = require('path');
|
|
let rootPath = process.cwd();
|
|
let db = require(path.join(rootPath, '/database.js'));
|
|
|
|
module.exports = {
|
|
/**
|
|
* Init model
|
|
*/
|
|
init: function(args, cb) {
|
|
this.getName(args.id, cb);
|
|
},
|
|
|
|
/**
|
|
* Get user data
|
|
*/
|
|
getName: function(id, cb) {
|
|
let sql = `SELECT name, extension FROM
|
|
account.user u JOIN pbx.sip s ON s.user_id = u.id WHERE id = ?`;
|
|
|
|
db.pool.query(sql, [id], (error, result) => {
|
|
if (error)
|
|
console.log(error);
|
|
|
|
Object.assign(this, result[0]);
|
|
cb();
|
|
});
|
|
}
|
|
} |