From 72b6dab15077e8e4a12a0b20eb80a4386e1f617a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 1 Dec 2025 18:03:59 +0530 Subject: [PATCH] Download unit master sample file API --- app/controllers/unitMasterController.js | 9 +++++++++ app/routes/routes.js | 25 ++++++++++++++++++++++++- app/uploads/unit-master-sample.csv | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 app/uploads/unit-master-sample.csv diff --git a/app/controllers/unitMasterController.js b/app/controllers/unitMasterController.js index a94cfe6..9e923fb 100644 --- a/app/controllers/unitMasterController.js +++ b/app/controllers/unitMasterController.js @@ -438,3 +438,12 @@ exports.uploadUnitMasterFromCSV = async (req, res) => { }); } }; + +exports.downloadUnitMasterSample = async (req, res) => { + try { + const filePath = path.join(__dirname, "../uploads/unit_master_sample.csv"); + return res.download(filePath, "unit_master_sample.csv"); + } catch (error) { + return res.status(500).send({ status: "failed", message: error.message }); + } +}; \ No newline at end of file diff --git a/app/routes/routes.js b/app/routes/routes.js index 00091cb..07c569b 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -2798,7 +2798,7 @@ router.get("/city-towns", [verifySignature, verifyToken], establishmentControlle * @swagger * /api/establishment/download-sample-file: * get: - * summary: Download sample CSV template for bulk product upload + * summary: Download sample CSV template for bulk company profile upload * tags: [Products] * security: * - appSignature: [] @@ -2818,6 +2818,29 @@ router.get("/city-towns", [verifySignature, verifyToken], establishmentControlle */ router.get("/establishment/download-sample-file",[verifySignature, verifyToken], establishmentController.downloadCompanyProfileSample); +/** + * @swagger + * /api/establishment/download-sample-file: + * get: + * summary: Download sample CSV template for bulk Unit Master upload + * tags: [Products] + * security: + * - appSignature: [] + * - bearerAuth: [] + * responses: + * 200: + * description: Sample CSV file downloaded successfully + * content: + * text/csv: + * schema: + * type: string + * format: binary + * 404: + * description: File not found + * 500: + * description: Server error + */ +router.get("/unit_master/download-sample-file",[verifySignature, verifyToken], establishmentController.downloadUnitMasterSample); diff --git a/app/uploads/unit-master-sample.csv b/app/uploads/unit-master-sample.csv new file mode 100644 index 0000000..b2dd7cd --- /dev/null +++ b/app/uploads/unit-master-sample.csv @@ -0,0 +1 @@ +Unit Name,Description