feat: Add public-load-attachments list of load evidences
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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 };
|
||||||
|
|||||||
Reference in New Issue
Block a user