258 lines
4.9 KiB
JavaScript
258 lines
4.9 KiB
JavaScript
module.exports = app => {
|
|
const request = require("request");
|
|
const cors=require('cors');
|
|
const Mycontroller = require("../controllers/test.controller.js");
|
|
const CreditPdController = require("../controllers/creditpd.controller.js");
|
|
const { logMsg } = require('../services/logger.js');
|
|
var router = require("express").Router();
|
|
|
|
|
|
|
|
/**
|
|
* @swagger
|
|
* /api/demo:
|
|
* get:
|
|
* summary: Demo Api
|
|
* description: Welcome Message
|
|
* responses:
|
|
* 200:
|
|
* description: success
|
|
*/
|
|
router.get("/demo", Mycontroller.Welcome);
|
|
|
|
router.get("/test", Mycontroller.test);
|
|
|
|
|
|
|
|
router.post("/ReInsertImageData", CreditPdController.ReInsertImageData);
|
|
|
|
|
|
|
|
|
|
// Pull CreditPd Data
|
|
/**
|
|
* @swagger
|
|
* definitions:
|
|
* PullCreditPdData:
|
|
* type: object
|
|
* properties:
|
|
* pdid:
|
|
* type: integer
|
|
* description: pdid
|
|
* example: 6646
|
|
* product:
|
|
* type: string
|
|
* description: product
|
|
* example: LFMP
|
|
* caseno:
|
|
* type: string
|
|
* description: case no
|
|
* example: MW30
|
|
* data:
|
|
* type: string
|
|
* description: json string
|
|
* example:
|
|
*/
|
|
/**
|
|
* @swagger
|
|
* /api/PullCreditPdData:
|
|
* post:
|
|
* summary: Pull CreditPd Data
|
|
* description: Pull CreditPd Data
|
|
* requestBody:
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/definitions/PullCreditPdData'
|
|
* responses:
|
|
* 200:
|
|
* description: success
|
|
* 500:
|
|
* description: failed
|
|
*/
|
|
router.post("/PullCreditPdData", CreditPdController.PullCreditPdData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// photograph upload
|
|
const multer = require('multer');
|
|
img_name = "";
|
|
const storage = multer.diskStorage({
|
|
destination: (req, file, cb) => {
|
|
cb(null, 'storage/uploads/');
|
|
},
|
|
filename: (req, file, cb) => {
|
|
img_name = "";
|
|
img_name += Date.now()+'-'+file.originalname;
|
|
cb(null, img_name);
|
|
}
|
|
});
|
|
const upload = multer({ storage });
|
|
/**
|
|
* @swagger
|
|
* definitions:
|
|
* PullCreditPdPhotographsData:
|
|
* type: object
|
|
* properties:
|
|
* pdid:
|
|
* type: integer
|
|
* description: pdid
|
|
* example: 6646
|
|
* product:
|
|
* type: string
|
|
* description: product
|
|
* example: LFMP
|
|
* caseno:
|
|
* type: string
|
|
* description:
|
|
* example: MW53315
|
|
* img:
|
|
* type: file
|
|
* description: image file
|
|
* example:
|
|
* img_name:
|
|
* type: string
|
|
* description: image file
|
|
* example: sample
|
|
*/
|
|
/**
|
|
* @swagger
|
|
* /api/PullCreditPdPhotographsData:
|
|
* post:
|
|
* summary: Pull CreditPd Photographs Data
|
|
* description: Pull CreditPd Photographs Data
|
|
* requestBody:
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/definitions/PullCreditPdPhotographsData'
|
|
* responses:
|
|
* 200:
|
|
* description: success
|
|
* 500:
|
|
* description: failed
|
|
*/
|
|
router.post('/PullCreditPdPhotographsData', upload.single('img'),function(req,res){ CreditPdController.PullCreditPdPhotographsData(req,res,img_name); } );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// view image
|
|
/**
|
|
* @swagger
|
|
* /api/imageView:
|
|
* get:
|
|
* summary: view image file api
|
|
* description:
|
|
* parameters:
|
|
* - in: query
|
|
* name: img_name
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* example: 1652702282873-tree-736885__480
|
|
* responses:
|
|
* 200:
|
|
* description: success
|
|
*/
|
|
router.get('/imageView',CreditPdController.imageView);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//get credit pd data List Api
|
|
/**
|
|
* @swagger
|
|
* /api/GetCreditPdData:
|
|
* get:
|
|
* summary: Get CreditPdData Data List
|
|
* description: Get CreditPdData Data List
|
|
* parameters:
|
|
* - in: query
|
|
* name: losid
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* example: MW112233
|
|
* responses:
|
|
* 200:
|
|
* description: success
|
|
*/
|
|
router.get('/GetCreditPdData',CreditPdController.GetCreditPdData)
|
|
|
|
|
|
// router.get('/GetCreditPdData__1',CreditPdController.GetCreditPdData__1)
|
|
|
|
|
|
|
|
// DownloadPdReport
|
|
/**
|
|
* @swagger
|
|
* /api/DownloadPdReport:
|
|
* get:
|
|
* summary: Download Pd Report as pdf file
|
|
* description: Download Pd Report as pdf file
|
|
* parameters:
|
|
* - in: query
|
|
* name: ref_no
|
|
* schema:
|
|
* type: integer
|
|
* required: true
|
|
* example: 614
|
|
* responses:
|
|
* 200:
|
|
* description: success
|
|
*/
|
|
router.get("/DownloadPdReport", CreditPdController.DownloadPdReport);
|
|
|
|
|
|
// // test
|
|
|
|
// //get credit pd data List Api
|
|
// /**
|
|
// * @swagger
|
|
// * /api/testGetCreditPdData:
|
|
// * get:
|
|
// * summary: Get testGetCreditPdData Data List
|
|
// * description: Get testGetCreditPdData Data List
|
|
// * parameters:
|
|
// * - in: query
|
|
// * name: pdid
|
|
// * schema:
|
|
// * type: integer
|
|
// * required: true
|
|
// * example: 206
|
|
// * responses:
|
|
// * 200:
|
|
// * description: success
|
|
// */
|
|
// router.get('/testGetCreditPdData',CreditPdController.testGetCreditPdData)
|
|
|
|
|
|
router.get("/getfilename", CreditPdController.readLogFileName);
|
|
|
|
router.post("/readlogs", CreditPdController.readLogFile);
|
|
|
|
router.get("/view", CreditPdController.viewLandingPage);
|
|
|
|
router.post("/deletelog", CreditPdController.deleteLogFile);
|
|
|
|
|
|
|
|
// routes started here
|
|
app.use('/api', router);
|
|
};
|
|
|
|
|