feat: Add public-load-attachments list of load evidences

This commit is contained in:
Josepablo C
2024-10-03 20:07:25 -06:00
parent 3180e0bad1
commit ddca2f24b5
2 changed files with 26 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
const router = require('express').Router(); const router = require('express').Router();
const services= require('./services.js'); const services= require('./services.js');
router.get('/load/:id', services.getLoadAttachmentList );
router.get('/download/:id', services.getAttachmentFile ); router.get('/download/:id', services.getAttachmentFile );
module.exports = router; module.exports = router;

View File

@@ -5,6 +5,30 @@ const apiConfig = require('../../../config/apiConfig.json');
const s3Bucket = apiConfig.S3.bucket; const s3Bucket = apiConfig.S3.bucket;
const s3BucketKey = apiConfig.S3.load_attachments_key; const s3BucketKey = apiConfig.S3.load_attachments_key;
const { getPage } = require( '../../../lib/Misc' )
const Model = require('../../../lib/Models/load-attachments.model')
const getLoadAttachmentList = async(req, res) => {
const loadId = req.params.id;
try{
const filter = {
$and : [
{ load : loadId }
]
};
const retVal = await getPage( 0, 2, Model, filter );
return res.send( retVal );
}catch( error ){
console.log( error );
return res.send({
total: 0,
limit: 2,
skip: 0,
data : []
});
}
};
const getAttachmentFile = async(req, res) => { const getAttachmentFile = async(req, res) => {
try{ try{
const attachmentId = req.params.id; const attachmentId = req.params.id;
@@ -18,4 +42,4 @@ const getAttachmentFile = async(req, res) => {
} }
} }
module.exports = { getAttachmentFile }; module.exports = { getAttachmentFile, getLoadAttachmentList };