feat: error handlers
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
ffa0ff650e
commit
7fc18c89df
|
@ -237,7 +237,9 @@
|
|||
"Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador",
|
||||
"Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador",
|
||||
"Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente",
|
||||
"Claim pickup order sent": "Reclamación Orden de recogida enviada [({{claimId}})]({{{claimUrl}}}) al cliente *{{clientName}}*",
|
||||
"You don't have grant privilege": "No tienes privilegios para dar privilegios",
|
||||
"You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario"
|
||||
}
|
||||
"Claim pickup order sent": "Reclamación Orden de recogida enviada [({{claimId}})]({{{claimUrl}}}) al cliente *{{clientName}}*",
|
||||
"You don't have grant privilege": "No tienes privilegios para dar privilegios",
|
||||
"You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario",
|
||||
"Already has this status": "Ya tiene este estado",
|
||||
"There aren't records for this week": "No existen registros para esta semana"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
fdescribe('workerTimeControl sendMail()', () => {
|
||||
describe('workerTimeControl sendMail()', () => {
|
||||
const workerId = 18;
|
||||
const ctx = {
|
||||
req: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('updateWorkerTimeControlMail', {
|
||||
description: 'Updates the state of WorkerTimeControlMail',
|
||||
|
@ -39,6 +40,7 @@ module.exports = Self => {
|
|||
Self.updateWorkerTimeControlMail = async(ctx, options) => {
|
||||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const myOptions = {};
|
||||
|
||||
|
@ -53,9 +55,33 @@ module.exports = Self => {
|
|||
}
|
||||
}, myOptions);
|
||||
|
||||
return workerTimeControlMail.updateAttributes({
|
||||
if (!workerTimeControlMail) throw new UserError(`There aren't records for this week`);
|
||||
|
||||
const oldState = workerTimeControlMail.state;
|
||||
const oldEmailResponse = workerTimeControlMail.emailResponse;
|
||||
|
||||
if (oldState == args.state) throw new UserError('Already has this status');
|
||||
|
||||
await workerTimeControlMail.updateAttributes({
|
||||
state: args.state,
|
||||
emailResponse: args.emailResponse || null
|
||||
}, myOptions);
|
||||
|
||||
const logRecord = {
|
||||
originFk: args.workerId,
|
||||
userFk: userId,
|
||||
action: 'update',
|
||||
changedModel: 'WorkerTimeControlMail',
|
||||
oldInstance: {
|
||||
state: oldState,
|
||||
emailResponse: oldEmailResponse
|
||||
},
|
||||
newInstance: {
|
||||
state: args.state,
|
||||
emailResponse: args.emailResponse
|
||||
}
|
||||
};
|
||||
|
||||
return models.WorkerLog.create(logRecord, myOptions);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue