This commit is contained in:
parent
a237375db6
commit
56201f4c1a
|
@ -0,0 +1,75 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('saveSign', {
|
||||
description: 'Save sign',
|
||||
accessType: 'WRITE',
|
||||
accepts:
|
||||
[
|
||||
{
|
||||
arg: 'singContent',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The sign content'
|
||||
}, {
|
||||
arg: 'tickets',
|
||||
type: ['number'],
|
||||
required: true,
|
||||
description: 'The tickets'
|
||||
}, {
|
||||
arg: 'signedTime',
|
||||
type: 'date',
|
||||
description: 'The signed time'
|
||||
}, {
|
||||
arg: 'addressFk',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The address fk'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/saveSign`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.saveSign = async(ctx, signContent, tickets, signedTime, addressFk) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
let dmsDir = await Self.rawSql(`SELECT dmsDir FROM hedera.config`);
|
||||
|
||||
let image;
|
||||
|
||||
let alertLevels = [];
|
||||
|
||||
for (let i = 0; i < tickets.length; i++) {
|
||||
let call = `SELECT alertLevel FROM vn.ticketState WHERE ticketFk = ${tickets[i]}`;
|
||||
let result = await Self.rawSql(call);
|
||||
|
||||
alertLevels.push(result[0].alertLevel);
|
||||
}
|
||||
|
||||
signedTime ? signedTime != undefined : signedTime = new Date();
|
||||
|
||||
let tx = await Self.beginTransaction({});
|
||||
|
||||
try {
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return {
|
||||
success: true,
|
||||
signContent: signContent,
|
||||
tickets: tickets,
|
||||
signedTime: signedTime,
|
||||
addressFk: addressFk,
|
||||
dmsDir: dmsDir,
|
||||
alertLevels: alertLevels
|
||||
};
|
||||
} catch (err) {
|
||||
await tx.rollback();
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -6,6 +6,7 @@ module.exports = Self => {
|
|||
require('../methods/dms/removeFile')(Self);
|
||||
require('../methods/dms/updateFile')(Self);
|
||||
require('../methods/dms/deleteTrashFiles')(Self);
|
||||
require('../methods/dms/saveSign')(Self);
|
||||
|
||||
Self.checkRole = async function(ctx, id) {
|
||||
const models = Self.app.models;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
INSERT INTO salix.ACL (model,property,accessType,permission,principalId) VALUES ('Dms','saveSign','*','ALLOW','employee');
|
|
@ -0,0 +1,30 @@
|
|||
INSERT INTO
|
||||
`hedera`.`config` (
|
||||
defaultLang,
|
||||
https,
|
||||
cookieLife,
|
||||
jwtKey,
|
||||
defaultForm,
|
||||
restUri,
|
||||
testRestUri,
|
||||
guestUser,
|
||||
testDomain,
|
||||
productionDomain,
|
||||
pdfsDir,
|
||||
dmsDir
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'es',
|
||||
0,
|
||||
15,
|
||||
'dfAr&s4t78h9F.Arw1C?dpR',
|
||||
'cms/home',
|
||||
'https://verdnatura.es/',
|
||||
'https://test.verdnatura.es/',
|
||||
'visitor',
|
||||
NULL,
|
||||
'verdnatura.es',
|
||||
'/mnt/storage/pdfs',
|
||||
'/mnt/storage/dms'
|
||||
);
|
Loading…
Reference in New Issue