#6274 workerTimeControl #1858

Merged
jorgep merged 31 commits from 6274-loginWorkerTimeControl into dev 2024-01-03 11:31:52 +00:00
4 changed files with 106 additions and 0 deletions
Showing only changes of commit e314a67fe7 - Show all commits

View File

@ -0,0 +1,34 @@
module.exports = Self => {
Self.remoteMethodCtx('clockIn', {
jorgep marked this conversation as resolved Outdated

veo que existe un archivo muy similar que llama al mismo procedimiento, lo has tenido en cuenta? conviene juntarlo en uno?
modules/worker/back/methods/worker-time-control/addTimeEntry.js

veo que existe un archivo muy similar que llama al mismo procedimiento, lo has tenido en cuenta? conviene juntarlo en uno? modules/worker/back/methods/worker-time-control/addTimeEntry.js

Ya se ha implementado, tenemos que mirarlo juntos conforme hemos hablado por rocket.

Ya se ha implementado, tenemos que mirarlo juntos conforme hemos hablado por rocket.

Refactor aplicado tras revisión en persona.

Refactor aplicado tras revisión en persona.
description: 'Check if the employee can clock in',
accessType: 'READ',
accepts: [
{
arg: 'workerFk',
type: 'integer',
required: true,
},
{
arg: 'direction',
type: 'integer'
},
{
arg: 'key',
type: 'string',
}
],
http: {
path: `/clockIn`,
verb: 'POST'
}
});
Self.clockIn = async(ctx, pin, direction, key, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const query = 'CALL vn.workerTimeControl_clockIn(?, NULL, ?)';
return await Self.rawSql(query, [workerFk, direction], options);
};
};

View File

@ -0,0 +1,30 @@
module.exports = Self => {
Self.remoteMethodCtx('getClockIn', {
description: 'Shows the clockings for each day, in columns per day',
accessType: 'READ',
accepts: [
{
arg: 'workerFk',
type: 'int',
required: true,
},
{
arg: 'key',
type: 'string',
}
],
http: {
path: `/getClockIn`,
verb: 'POST'
}
});
Self.getClockIn = async(ctx, workerFk, key, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const query = `CALL vn.workerTimeControl_getClockIn(?, CURDATE())`;
return await Self.rawSql(query, [workerFk], myOptions);
};
};

View File

@ -0,0 +1,39 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('login', {
description: 'Consult the user\'s information and the buttons that must be activated after logging in',
accessType: 'READ',
accepts: [
{
arg: 'pin',
type: 'string',
required: true,
},
{
arg: 'key',
type: 'string',
}
],
returns: {
type: 'Object',
root: true
},
http: {
path: `/login`,
verb: 'POST'
}
});
Self.login = async(ctx, pin, key, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
jorgep marked this conversation as resolved Outdated
Outdated
Review

Falta traduccion

Falta traduccion
const query = `CALL vn.workerTimeControl_login(?)`;
const user = await Self.rawSql(query, [pin], myOptions);
if (!user) throw new UserError('Indique el pin.');
return user;
};
};

View File

@ -10,6 +10,9 @@ module.exports = Self => {
require('../methods/worker-time-control/weeklyHourRecordEmail')(Self); require('../methods/worker-time-control/weeklyHourRecordEmail')(Self);
require('../methods/worker-time-control/getMailStates')(Self); require('../methods/worker-time-control/getMailStates')(Self);
require('../methods/worker-time-control/resendWeeklyHourEmail')(Self); require('../methods/worker-time-control/resendWeeklyHourEmail')(Self);
require('../methods/worker-time-control/login')(Self);
require('../methods/worker-time-control/getClockIn')(Self);
require('../methods/worker-time-control/clockIn')(Self);
Self.rewriteDbError(function(err) { Self.rewriteDbError(function(err) {
if (err.code === 'ER_DUP_ENTRY') if (err.code === 'ER_DUP_ENTRY')