From 26f40a101b5047fb5b97186354a1955ffbb94a01 Mon Sep 17 00:00:00 2001 From: Abzmoni <107305262+Abzmoni@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:08:42 +0100 Subject: [PATCH] added api and endpoint for logout --- api/users/user.controller.js | 14 ++++++++++++++ api/users/user.router.js | 2 ++ api/users/user.service.js | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/api/users/user.controller.js b/api/users/user.controller.js index 0dd8f5a..37e033a 100644 --- a/api/users/user.controller.js +++ b/api/users/user.controller.js @@ -16,7 +16,9 @@ const { getAllVisitors, getVisitorByFullname, updateVisitorClockout, + getVisitorsSignOutNumber, getVisitorsNumber + } = require('./user.service'); //we called the service @@ -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) => { diff --git a/api/users/user.router.js b/api/users/user.router.js index 94284b4..07c515c 100644 --- a/api/users/user.router.js +++ b/api/users/user.router.js @@ -14,6 +14,7 @@ const { //We have to import all the controllers in the router getAllVisitors, getVisitorByFullname, getVisitorsNumber, + getVisitorsSignOutNumber, updateVisitorClockout } = require('./user.controller'); @@ -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); diff --git a/api/users/user.service.js b/api/users/user.service.js index debca22..b235826 100644 --- a/api/users/user.service.js +++ b/api/users/user.service.js @@ -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( `