#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 37 additions and 25 deletions
Showing only changes of commit 29fb36010c - Show all commits

View File

@ -0,0 +1,13 @@
INSERT INTO `account`.`role` (name, description)
jorgep marked this conversation as resolved Outdated
Outdated
Review

Cambiar version a la ultima

Cambiar version a la ultima
VALUES ('timeControl','Tablet para fichar');
INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
VALUES (127, 11);
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
VALUES
('workerTimeControl', 'login', 'READ', 'ALLOW', 'ROLE', '*'),
('workerTimeControl', 'getClockIn', 'READ', 'ALLOW', 'ROLE', '*'),
('workerTimeControl', 'clockIn', 'WRITE', 'ALLOW', 'ROLE', '*');
CALL `account`.`role_sync`();

View File

@ -1,7 +1,7 @@
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('clockIn', { Self.remoteMethod('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', description: 'Check if the employee can clock in',
accessType: 'READ', accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'workerFk', arg: 'workerFk',
@ -10,25 +10,26 @@ module.exports = Self => {
}, },
{ {
arg: 'direction', arg: 'direction',
type: 'integer' type: 'string'
}, },
{
arg: 'key',
type: 'string',
}
], ],
http: { http: {
path: `/clockIn`, path: `/clockIn`,
verb: 'POST' verb: 'POST'
},
returns: {
type: 'Object',
root: true
} }
}); });
Self.clockIn = async(ctx, pin, direction, key, options) => { Self.clockIn = async(workerFk, direction, options) => {
const myOptions = {}; const myOptions = {};
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
const query = 'CALL vn.workerTimeControl_clockIn(?, NULL, ?)'; const query = 'CALL vn.workerTimeControl_clockIn(?, NULL, ?)';
return await Self.rawSql(query, [workerFk, direction], options); return await Self.rawSql(query, [workerFk, direction], myOptions);
}; };
}; };

View File

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

View File

@ -1,7 +1,7 @@
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('login', { Self.remoteMethod('login', {
description: 'Consult the user\'s information and the buttons that must be activated after logging in', description: 'Consult the user\'s information and the buttons that must be activated after logging in',
accessType: 'READ', accessType: 'READ',
accepts: [ accepts: [
@ -10,10 +10,6 @@ module.exports = Self => {
type: 'string', type: 'string',
required: true, required: true,
}, },
{
arg: 'key',
type: 'string',
}
], ],
returns: { returns: {
type: 'Object', type: 'Object',
@ -25,7 +21,7 @@ module.exports = Self => {
} }
}); });
Self.login = async(ctx, pin, key, options) => { Self.login = async(pin, options) => {
const myOptions = {}; const myOptions = {};
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
@ -34,6 +30,6 @@ module.exports = Self => {
const user = await Self.rawSql(query, [pin], myOptions); const user = await Self.rawSql(query, [pin], myOptions);
if (!user) throw new UserError('Indique el pin.'); if (!user) throw new UserError('Indique el pin.');
jorgep marked this conversation as resolved Outdated
Outdated
Review

Falta traduccion

Falta traduccion
return user; return user[0][0];
}; };
}; };