#6274 workerTimeControl #1858
|
@ -0,0 +1,34 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('clockIn', {
|
||||
jorgep marked this conversation as resolved
Outdated
|
||||
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);
|
||||
};
|
||||
};
|
|
@ -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);
|
||||
};
|
||||
};
|
|
@ -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
alexm
commented
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;
|
||||
};
|
||||
};
|
|
@ -10,6 +10,9 @@ module.exports = Self => {
|
|||
require('../methods/worker-time-control/weeklyHourRecordEmail')(Self);
|
||||
require('../methods/worker-time-control/getMailStates')(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) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
|
|
Loading…
Reference in New Issue
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.
Refactor aplicado tras revisión en persona.