Skip to content

Commit

Permalink
added api and endpoint for logout
Browse files Browse the repository at this point in the history
  • Loading branch information
Abzmoni committed Sep 1, 2022
1 parent 4331993 commit 26f40a1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
14 changes: 14 additions & 0 deletions api/users/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const {
getAllVisitors,
getVisitorByFullname,
updateVisitorClockout,
getVisitorsSignOutNumber,
getVisitorsNumber


} = require('./user.service'); //we called the service

Expand Down Expand Up @@ -191,6 +193,18 @@ getVisitorsNumber: (req, res) => {
data: results
});
});
},
getVisitorsSignOutNumber: (req, res) => {
getVisitorsSignOutNumber((err, results) => {
if (err) {
console.log(err);
return;
}
return res.json({
success: 1,
data: results
});
});
},
getVisitorPurpose: (req, res) => {
getVisitorPurpose((err, results) => {
Expand Down
2 changes: 2 additions & 0 deletions api/users/user.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { //We have to import all the controllers in the router
getAllVisitors,
getVisitorByFullname,
getVisitorsNumber,
getVisitorsSignOutNumber,
updateVisitorClockout
} = require('./user.controller');

Expand All @@ -38,6 +39,7 @@ router.post('/user/createUsers', checkToken, createUsers);
router.get('/visitor/getVisitorPurpose', getVisitorPurpose);
router.get('/visitor/getVisitorByFullname', getVisitorByFullname);
router.get('/visitor/getVisitorsNumber', checkToken, getVisitorsNumber);
router.get('/visitor/getVisitorsSignOutNumber', checkToken, getVisitorsSignOutNumber);
router.patch('/visitor/updateVisitorClockout', updateVisitorClockout);


Expand Down
21 changes: 21 additions & 0 deletions api/users/user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,27 @@ module.exports = {
}
);
},
getVisitorsSignOutNumber: callBack => {
const number = '2000-08-02 00:00:00';
pool.query(
`
select v.id as id, v.fullname as fullname, v.purpose_id as purpose, v.date_added as date_added, v.address as address,
c.time_in as time_in, c.time_out as time_out,u.first_name as first_name, u.last_name as last_name
from clock_in c
join visitors v on v.id = c.visitor_id
join users u on u.id = v.user_id
where date(c.time_out) = current_date
`,
[],
(error, results, fields) => {
if (error) {
return callBack(error);
}
return callBack(null, results);
}
);
},
getAllVisitors: callBack => {
pool.query(
`
Expand Down

0 comments on commit 26f40a1

Please sign in to comment.