6956-2410_devTest #2112

Merged
alexm merged 150 commits from 6956-2410_devTest into test 2024-02-29 09:17:58 +00:00
8 changed files with 117 additions and 2 deletions
Showing only changes of commit f4dc596e97 - Show all commits

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryDms_afterDelete`
AFTER DELETE ON `entryDms`
FOR EACH ROW
BEGIN
INSERT INTO entryLog
SET `action` = 'delete',
`changedModel` = 'EntryDms',
`changedModelId` = OLD.entryFk,
`userFk` = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryDms_beforeInsert`
BEFORE INSERT ON `entryDms`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryDms_beforeUpdate`
BEFORE UPDATE ON `entryDms`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -336,5 +336,6 @@
"Incorrect pin": "Pin incorrecto.", "Incorrect pin": "Pin incorrecto.",
"You already have the mailAlias": "Ya tienes este alias de correo", "You already have the mailAlias": "Ya tienes este alias de correo",
"The alias cant be modified": "Este alias de correo no puede ser modificado", "The alias cant be modified": "Este alias de correo no puede ser modificado",
"No tickets to invoice": "No hay tickets para facturar" "No tickets to invoice": "No hay tickets para facturar",
"this warehouse has not dms": "El Almacén no acepta documentos"
} }

View File

@ -103,6 +103,20 @@
"video/mp4" "video/mp4"
] ]
}, },
"entryStorage": {
"name": "entryStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/dms",
"maxFileSize": "31457280",
"allowedContentTypes": [
"image/png",
"image/jpeg",
"image/jpg",
"image/webp",
"video/mp4"
]
},
"accessStorage": { "accessStorage": {
"name": "accessStorage", "name": "accessStorage",
"connector": "loopback-component-storage", "connector": "loopback-component-storage",

View File

@ -0,0 +1,59 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('downloadFile', {
description: 'Get the entry file',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'Number',
description: 'The document id',
http: {source: 'path'}
}
],
returns: [
{
arg: 'body',
type: 'file',
root: true
},
{
arg: 'Content-Type',
type: 'String',
http: {target: 'header'}
},
{
arg: 'Content-Disposition',
type: 'String',
http: {target: 'header'}
}
],
http: {
path: `/:id/downloadFile`,
verb: 'GET'
}
});
Self.downloadFile = async function(ctx, id) {
const models = Self.app.models;
const EntryContainer = models.EntryContainer;
const dms = await models.Dms.findById(id);
const pathHash = EntryContainer.getHash(dms.id);
try {
await EntryContainer.getFile(pathHash, dms.file);
} catch (e) {
if (e.code != 'ENOENT')
throw e;
const error = new UserError(`File doesn't exists`);
error.statusCode = 404;
throw error;
}
const stream = EntryContainer.downloadStream(pathHash, dms.file);
return [stream, dms.contentType, `filename="${dms.file}"`];
};
};

View File

@ -2,6 +2,9 @@
"Entry": { "Entry": {
"dataSource": "vn" "dataSource": "vn"
}, },
"EntryContainer": {
"dataSource": "entryStorage"
},
"Buy": { "Buy": {
"dataSource": "vn" "dataSource": "vn"
}, },

View File

@ -0,0 +1,10 @@
{
"name": "EntryContainer",
"base": "Container",
"acls": [{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}]
}