get user and employee
This commit is contained in:
parent
6996352029
commit
18ff74b17f
|
@ -1,3 +1,6 @@
|
|||
let loopBackContext = require('loopback-context');
|
||||
let app = require('../../server/server');
|
||||
|
||||
module.exports = function(self) {
|
||||
|
||||
self.setup = function() {
|
||||
|
@ -28,14 +31,12 @@ module.exports = function(self) {
|
|||
};
|
||||
|
||||
self.getUser = function() {
|
||||
let loopBackContext = require('loopback-context');
|
||||
let currentUser = loopBackContext.getCurrentContext();
|
||||
let userId = currentUser.get('currentUser');
|
||||
return userId;
|
||||
};
|
||||
|
||||
self.getEmployee = function() {
|
||||
let app = require('../../server/server');
|
||||
let userId = self.getUser();
|
||||
let employee = app.models.Employee;
|
||||
return employee.findOne({where: {userFk: userId}});
|
||||
|
|
|
@ -28,12 +28,11 @@ module.exports = function(TicketState) {
|
|||
});
|
||||
|
||||
TicketState.changeState = function(tickets, state, cb) {
|
||||
TicketState.getEmployee().then(function(emp){
|
||||
changeState(emp, tickets, state, cb);
|
||||
icketState.getEmployee().then(function(emp){
|
||||
changeState(emp, tickets, state, cb);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var changeState = function(emp, tickets, state, cb){
|
||||
var inserts = [];
|
||||
|
||||
|
@ -47,4 +46,5 @@ module.exports = function(TicketState) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
let loopBackContext = require('loopback-context');
|
||||
let app = require('../../server/server');
|
||||
|
||||
module.exports = function(self) {
|
||||
|
||||
self.setup = function() {
|
||||
|
@ -28,14 +31,12 @@ module.exports = function(self) {
|
|||
};
|
||||
|
||||
self.getUser = function() {
|
||||
let loopBackContext = require('loopback-context');
|
||||
let currentUser = loopBackContext.getCurrentContext();
|
||||
let userId = currentUser.get('currentUser');
|
||||
return userId;
|
||||
};
|
||||
|
||||
self.getEmployee = function() {
|
||||
let app = require('../../server/server');
|
||||
let userId = self.getUser();
|
||||
let employee = app.models.Employee;
|
||||
return employee.findOne({where: {userFk: userId}});
|
||||
|
|
Loading…
Reference in New Issue