diff --git a/v1/src/apps/public/public-load-attachments/routes.js b/v1/src/apps/public/public-load-attachments/routes.js index b9589e6..eba68b6 100644 --- a/v1/src/apps/public/public-load-attachments/routes.js +++ b/v1/src/apps/public/public-load-attachments/routes.js @@ -2,6 +2,7 @@ const router = require('express').Router(); const services= require('./services.js'); +router.get('/load/:id', services.getLoadAttachmentList ); router.get('/download/:id', services.getAttachmentFile ); module.exports = router; diff --git a/v1/src/apps/public/public-load-attachments/services.js b/v1/src/apps/public/public-load-attachments/services.js index 0a8e2fc..8a04677 100644 --- a/v1/src/apps/public/public-load-attachments/services.js +++ b/v1/src/apps/public/public-load-attachments/services.js @@ -5,6 +5,30 @@ const apiConfig = require('../../../config/apiConfig.json'); const s3Bucket = apiConfig.S3.bucket; 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) => { try{ const attachmentId = req.params.id; @@ -18,4 +42,4 @@ const getAttachmentFile = async(req, res) => { } } -module.exports = { getAttachmentFile }; +module.exports = { getAttachmentFile, getLoadAttachmentList };