Commit c4a567d009fbbfd669d02bfd5c614df842d3bae9
1 parent
27aed231
Exists in
master
and in
1 other branch
merge
Showing
8 changed files
with
472 additions
and
246 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | +{ | |
| 2 | + "development": { | |
| 3 | + "app_name": "CMF", | |
| 4 | + "app_host": "0.0.0.0", | |
| 5 | + "app_port": "3000", | |
| 6 | + "app_https": false, | |
| 7 | + "KEY": "key1.pem", | |
| 8 | + "CERT": "cert1.pem", | |
| 9 | + "service": { | |
| 10 | + "PANDORA": { | |
| 11 | + "URI": "http://25.27.7.151:34680", | |
| 12 | + "URI_EQX": "http://25.27.7.151:15300", | |
| 13 | + "KEY": "./PANDORA_CERT/server.key", | |
| 14 | + "CERT": "./PANDORA_CERT/server.pem", | |
| 15 | + "PREFIX": "/phxPartner/v1/partner" | |
| 16 | + }, | |
| 17 | + "SACF": { | |
| 18 | + "Name": "SACF", | |
| 19 | + "POST_SearchCustomer_URL": "http://10.1.3.74:8080", | |
| 20 | + "POST_SearchCustomer_Timeout": 10 | |
| 21 | + }, | |
| 22 | + "D01": { | |
| 23 | + "Name": "D01", | |
| 24 | + "GET_Customer_URL": "http://localhost:8080", | |
| 25 | + "GET_Customer_Timeout": 10, | |
| 26 | + "POST_Customer_URL": "http://localhost:8080", | |
| 27 | + "POST_Customer_Timeout": 10, | |
| 28 | + "POST_Limit": 20, | |
| 29 | + "GET_Limit": 1000 | |
| 30 | + }, | |
| 31 | + "CMF": { | |
| 32 | + "Name": "CMF", | |
| 33 | + "GET_VIZCard_URL": [ | |
| 34 | + "/cmf/v1/vizcards/:vizCardId", | |
| 35 | + "/cmf/v1/vizcards" | |
| 36 | + ], | |
| 37 | + "GET_Customer_URL": [ | |
| 38 | + "/cmf/v1/customers/:customerId", | |
| 39 | + "/cmf/v1/customers/:userType/:userData", | |
| 40 | + "/cmf/v1/customers" | |
| 41 | + ], | |
| 42 | + "POST_Customer_URL": [ | |
| 43 | + "/cmf/v1/customers" | |
| 44 | + ], | |
| 45 | + "GET_CustomerMembership_URL": [ | |
| 46 | + "/cmf/v1/customers/:customerId/membercards", | |
| 47 | + "/cmf/v1/customers/:userType/:userData/membercards", | |
| 48 | + "/cmf/v1/customers/membercards" | |
| 49 | + ], | |
| 50 | + "POST_CustomerMembership_URL": [ | |
| 51 | + "/cmf/v1/customers/:customerId/membercards", | |
| 52 | + "/cmf/v1/customers/:userType/:userData/membercards" | |
| 53 | + ] | |
| 54 | + } | |
| 55 | + }, | |
| 56 | + "log": { | |
| 57 | + "logTime": 15, | |
| 58 | + "statTime": 2, | |
| 59 | + "detailTime": 15, | |
| 60 | + "summaryTime": 15, | |
| 61 | + "statInterval": 60, | |
| 62 | + "appLogPath": "./logTest/", | |
| 63 | + "summaryPath": "./logTest/", | |
| 64 | + "statPath": "./logTest/", | |
| 65 | + "detailPath": "./logTest/", | |
| 66 | + "level": "debug" | |
| 67 | + }, | |
| 68 | + "http_req_timeout": 120, | |
| 69 | + "session": 30, | |
| 70 | + "Default_Timeout": 10, | |
| 71 | + "Default_Retry": 5, | |
| 72 | + "Uri_length": 1000 | |
| 73 | + } | |
| 74 | +} | |
| 0 | 75 | \ No newline at end of file | ... | ... |
ais-structure/src/config/express.js
| ... | ... | @@ -160,6 +160,7 @@ module.exports = function () { |
| 160 | 160 | var headerLog = 'IP|'+remoteIp+'|USER|'+username+'|REQUESTID|'+req.id; |
| 161 | 161 | |
| 162 | 162 | logger.setHeader(headerLog); |
| 163 | + // console.log(headerLog); | |
| 163 | 164 | // console.log("req " +req.headers['x-token']); |
| 164 | 165 | // console.log("fullUrl " +req.originalUrl); |
| 165 | 166 | // console.log("method " +req.method); |
| ... | ... | @@ -209,10 +210,7 @@ module.exports = function () { |
| 209 | 210 | return res.resBody?res.resBody:'' ; |
| 210 | 211 | }) |
| 211 | 212 | |
| 212 | - app.use( function( req, res, next ) { | |
| 213 | - log.startEC(req); | |
| 214 | - next(); | |
| 215 | -} ); | |
| 213 | + | |
| 216 | 214 | |
| 217 | 215 | // app.use(morgan('IP|:remote-ip|USER|:user-id|REQUESTID|:id|METHOD|:method|URI|:uri|REQUESTBODY|:json|RESPSTATUS|:status|RESPBODY|:resp-body|RESPTIME|:response-time', { |
| 218 | 216 | // "stream": logger.stream |
| ... | ... | @@ -223,6 +221,13 @@ module.exports = function () { |
| 223 | 221 | // var ALL_ROUTES = require('../routes/index').GET_ALL_ROUTES(); |
| 224 | 222 | // app.use('/', ALL_ROUTES); |
| 225 | 223 | |
| 224 | + app.use( function( req, res, next ) { | |
| 225 | + // console.log(req.id); | |
| 226 | + log.startEC(req); | |
| 227 | + next(); | |
| 228 | + }); | |
| 229 | + | |
| 230 | + | |
| 226 | 231 | logger.info("load module"); |
| 227 | 232 | var load = require('express-load'); |
| 228 | 233 | // load('modules', { |
| ... | ... | @@ -274,19 +279,20 @@ module.exports = function () { |
| 274 | 279 | /* ------------- [END NOT MATCH ROUTE - 404 ] ------------ */ |
| 275 | 280 | |
| 276 | 281 | app.use( function( req, res, next ) { |
| 277 | - // console.log("end"); | |
| 278 | - // console.log(req.res.resBody); | |
| 279 | - if(req.res.resBody) | |
| 280 | - { | |
| 281 | - log.logSummary(JSON.parse(req.res.resBody)); | |
| 282 | - }else | |
| 283 | - { | |
| 284 | - res.status(200).json(responseMsg.unknow(req)); | |
| 285 | - } | |
| 286 | - | |
| 287 | - log.endEC(res); | |
| 288 | - next(); | |
| 289 | -} ); | |
| 282 | + // console.log("end"); | |
| 283 | + // console.log(req.res.resBody); | |
| 284 | + if(req.res.resBody) | |
| 285 | + { | |
| 286 | + log.logSummary(req,JSON.parse(req.res.resBody)); | |
| 287 | + }else | |
| 288 | + { | |
| 289 | + res.status(200).json(responseMsg.unknow(req)); | |
| 290 | + } | |
| 291 | + | |
| 292 | + log.endEC(req,res); | |
| 293 | + next(); | |
| 294 | + } ); | |
| 295 | + | |
| 290 | 296 | |
| 291 | 297 | return app; |
| 292 | 298 | }; | ... | ... |
ais-structure/src/modules/customer/customer.ctrl.js
| ... | ... | @@ -10,7 +10,6 @@ exports.customer = async function (req, res, next) { |
| 10 | 10 | var sendCmd = "Customer"; |
| 11 | 11 | var d01 = "D01" |
| 12 | 12 | var method = constant.METHOD.GET |
| 13 | - | |
| 14 | 13 | console.log(req.params); |
| 15 | 14 | |
| 16 | 15 | if(req.params.customerId){ |
| ... | ... | @@ -20,25 +19,26 @@ exports.customer = async function (req, res, next) { |
| 20 | 19 | } else if(req.query.clientName && req.query.commandId){ |
| 21 | 20 | var customerId = req.query.clientName+"@"+req.query.commandId; |
| 22 | 21 | } |
| 22 | +; | |
| 23 | 23 | |
| 24 | - log.startlog(method+"_"+getCmd,req.query.commandId,customerId); | |
| 25 | - log.logDetail.addInput(req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | |
| 24 | + log.startlog(req,method+"_"+getCmd,req.query.commandId,customerId); | |
| 25 | + log.logDetail.addInput(req,req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | |
| 26 | 26 | |
| 27 | 27 | var err = validator(req,getCmd); |
| 28 | 28 | |
| 29 | 29 | if(err.length > 0) |
| 30 | 30 | { |
| 31 | - log.addErrorSummary(req.query.clientName,method+"_"+getCmd,"null",constant.FAIL); | |
| 31 | + log.addErrorSummary(req,req.query.clientName,method+"_"+getCmd,"null",constant.FAIL); | |
| 32 | 32 | log.log(err,'error'); |
| 33 | 33 | var response = responseMsg.error(req,getCmd,40300); |
| 34 | 34 | // res.status(200).json(response); |
| 35 | 35 | }else |
| 36 | 36 | { |
| 37 | - log.addSuccessSummary(req.query.clientName,method+"_"+getCmd,"null",constant.SUCCESS); | |
| 37 | + log.addSuccessSummary(req,req.query.clientName,method+"_"+getCmd,"null",constant.SUCCESS); | |
| 38 | 38 | var objectData = Object.assign(req.query,req.params); |
| 39 | - const result = await connection.requestJsonToD01(objectData,sendCmd,method); | |
| 39 | + const result = await connection.requestJsonToD01(req,objectData,sendCmd,method); | |
| 40 | 40 | // console.log(Object.keys(result)) |
| 41 | - log.logDetail.addInput(d01,method+"_"+sendCmd,constant.RESPONSE,result,result.response); | |
| 41 | + log.logDetail.addInput(req,d01,method+"_"+sendCmd,constant.RESPONSE,result,result.response); | |
| 42 | 42 | if(typeof result.err === 'undefined'){ |
| 43 | 43 | // console.log(result.response); |
| 44 | 44 | var resultObj = result.response; |
| ... | ... | @@ -48,21 +48,21 @@ exports.customer = async function (req, res, next) { |
| 48 | 48 | { |
| 49 | 49 | stats.receiveRestResponse(d01,method,sendCmd,constant.SUCCESS); |
| 50 | 50 | var response = responseMsg.success(req,getCmd,resultObj); |
| 51 | - log.addSuccessSummary(d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
| 51 | + log.addSuccessSummary(req,d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
| 52 | 52 | }else |
| 53 | 53 | { |
| 54 | 54 | stats.receiveRestResponse(d01,method,sendCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); |
| 55 | 55 | var response = responseMsg.error(req,getCmd,40401); |
| 56 | - log.addErrorSummary(d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
| 56 | + log.addErrorSummary(req,d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
| 57 | 57 | } |
| 58 | 58 | } else if(resultObj.resultCode.startsWith("404")){ |
| 59 | 59 | stats.receiveRestResponse(d01,method,sendCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); |
| 60 | 60 | var response = responseMsg.direct(req,getCmd,resultObj); |
| 61 | - log.addErrorSummary(d01,method+"_"+sendCmd,resultObj.resultCode,resultObj.developerMessage); | |
| 61 | + log.addErrorSummary(req,d01,method+"_"+sendCmd,resultObj.resultCode,resultObj.developerMessage); | |
| 62 | 62 | } else if(resultObj.resultCode.startsWith("5")){ |
| 63 | 63 | stats.receiveRestResponse(d01,method,sendCmd,constant.ERROR); |
| 64 | 64 | var response = responseMsg.direct(req,getCmd,resultObj); |
| 65 | - log.addErrorSummary(d01,method+"_"+sendCmd,resultObj.resultCode,resultObj.developerMessage); | |
| 65 | + log.addErrorSummary(req,d01,method+"_"+sendCmd,resultObj.resultCode,resultObj.developerMessage); | |
| 66 | 66 | } else { |
| 67 | 67 | stats.receiveRestResponse(d01,method,sendCmd,constant.ERROR); |
| 68 | 68 | var response = responseMsg.error(req,getCmd,50000); |
| ... | ... | @@ -74,7 +74,7 @@ exports.customer = async function (req, res, next) { |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - log.logDetail.addOutput(req.query.clientName,method+"_"+getCmd,constant.RESPONSE,response,response); | |
| 77 | + log.logDetail.addOutput(req,req.query.clientName,method+"_"+getCmd,constant.RESPONSE,response,response); | |
| 78 | 78 | res.status(200).json(response); |
| 79 | 79 | next(); |
| 80 | 80 | }; | ... | ... |
ais-structure/src/modules/customer/customer.route.js
| ... | ... | @@ -5,19 +5,19 @@ module.exports = function (app) { |
| 5 | 5 | var customerCtrl = app.modules.customer.customerCtrl; |
| 6 | 6 | var postCustomerCtrl = app.modules.customer.postCustomerCtrl; |
| 7 | 7 | |
| 8 | - app.get(cfg.service.CMF.GET_Customer_URL[0], | |
| 9 | - customerCtrl.customer | |
| 10 | - ); | |
| 8 | + // app.get(cfg.service.CMF.GET_Customer_URL[0], | |
| 9 | + // customerCtrl.customer | |
| 10 | + // ); | |
| 11 | 11 | |
| 12 | - app.get(cfg.service.CMF.GET_Customer_URL[1], | |
| 13 | - customerCtrl.customer | |
| 14 | - ); | |
| 12 | + // app.get(cfg.service.CMF.GET_Customer_URL[1], | |
| 13 | + // customerCtrl.customer | |
| 14 | + // ); | |
| 15 | 15 | |
| 16 | - app.get(cfg.service.CMF.GET_Customer_URL[2], | |
| 17 | - customerCtrl.customer | |
| 18 | - ); | |
| 16 | + // app.get(cfg.service.CMF.GET_Customer_URL[2], | |
| 17 | + // customerCtrl.customer | |
| 18 | + // ); | |
| 19 | 19 | |
| 20 | - app.post(cfg.service.CMF.POST_Customer_URL[0], | |
| 21 | - postCustomerCtrl.postCustomer | |
| 22 | - ); | |
| 20 | + // app.post(cfg.service.CMF.POST_Customer_URL[0], | |
| 21 | + // postCustomerCtrl.postCustomer | |
| 22 | + // ); | |
| 23 | 23 | }; | ... | ... |
ais-structure/src/modules/helper/connection.js
| ... | ... | @@ -9,194 +9,206 @@ var constants = require('../helper/constants.js'); |
| 9 | 9 | var connection = []; |
| 10 | 10 | |
| 11 | 11 | |
| 12 | -connection.requestSoapToSACF = async function (soap,cmd,myMethod) { | |
| 12 | +connection.requestSoapToSACF = async function (req,soap,cmd,myMethod) { | |
| 13 | + try { | |
| 14 | + log.log("Connect to SACF") | |
| 15 | + | |
| 16 | + var service = cfg.service.SACF; | |
| 17 | + var retry = service[myMethod+"_"+cmd+"_Retry"]; | |
| 18 | + | |
| 19 | + var params = { | |
| 20 | + url : service[myMethod+"_"+cmd+"_URL"], | |
| 21 | + body : messageSOAP.objectToSOAP(soap,cmd), | |
| 22 | + method : myMethod, | |
| 23 | + timeout : cfg.service.SACF[myMethod+"_"+cmd+"_Timeout"]*1000 | |
| 24 | + } | |
| 13 | 25 | |
| 14 | - log.log("Connect to SACF") | |
| 26 | + log.log("requestData : "+JSON.stringify(params)) | |
| 15 | 27 | |
| 16 | - var service = cfg.service.SACF; | |
| 17 | - var retry = service[myMethod+"_"+cmd+"_Retry"]; | |
| 28 | + if(!retry) | |
| 29 | + retry = cfg.Default_Retry; | |
| 18 | 30 | |
| 19 | - var params = { | |
| 20 | - url : service[myMethod+"_"+cmd+"_URL"], | |
| 21 | - body : messageSOAP.objectToSOAP(soap,cmd), | |
| 22 | - method : myMethod, | |
| 23 | - timeout : cfg.service.SACF[myMethod+"_"+cmd+"_Timeout"]*1000 | |
| 24 | - } | |
| 31 | + var objectData = { | |
| 32 | + maxRetry : retry, | |
| 33 | + curRetry : 1 | |
| 34 | + } | |
| 35 | + | |
| 36 | + var funS = function(){ | |
| 37 | + stats.sendSACFRequest(service.Name,cmd); | |
| 38 | + log.logDetail.addOutput(req,service.Name,myMethod+"_"+cmd,constants.REQUEST,params,soap); | |
| 39 | + }; | |
| 40 | + | |
| 41 | + var funStats = { | |
| 42 | + start : funS, | |
| 43 | + error : function(response){log.addErrorSummary(req,service.Name,myMethod+"_"+cmd,response.resultCode,response.resultDescription);} | |
| 44 | + }; | |
| 25 | 45 | |
| 26 | - log.log(JSON.stringify(params)) | |
| 27 | 46 | |
| 28 | - if(!retry) | |
| 29 | - retry = cfg.Default_Retry; | |
| 47 | + var result = await asyncRequest(params,objectData,funStats); | |
| 30 | 48 | |
| 31 | - var objectData = { | |
| 32 | - maxRetry : retry, | |
| 33 | - curRetry : 1 | |
| 49 | + return checkResponse(result,funStats); | |
| 34 | 50 | } |
| 35 | - | |
| 36 | - var funS = function(){ | |
| 37 | - stats.sendSACFRequest(service.Name,cmd); | |
| 38 | - log.logDetail.addOutput(service.Name,myMethod+"_"+cmd,constants.REQUEST,params,soap); | |
| 39 | - }; | |
| 40 | - | |
| 41 | - var funStats = { | |
| 42 | - start : funS, | |
| 43 | - error : function(response){log.addErrorSummary(service.Name,myMethod+"_"+cmd,response.resultCode,response.resultDescription);} | |
| 44 | - }; | |
| 45 | - | |
| 51 | + catch(err) { | |
| 52 | + log.log(err); | |
| 46 | 53 | |
| 47 | - var result = await asyncRequest(params,objectData,funStats); | |
| 54 | + var result = { | |
| 55 | + response : constants.RESPONSECONN.MESSAGE.ERROR | |
| 56 | + }; | |
| 57 | + return result; | |
| 48 | 58 | |
| 49 | - return checkResponse(result,funStats); | |
| 59 | + } | |
| 50 | 60 | }; |
| 51 | 61 | |
| 52 | -connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | |
| 53 | - | |
| 54 | - log.log("Connect to D01") | |
| 55 | - | |
| 56 | - var service = cfg.service.D01; | |
| 57 | - var retry = service[myMethod+"_"+cmd+"_Retry"]; | |
| 58 | - if(!retry) | |
| 59 | - retry = cfg.Default_Retry; | |
| 62 | +connection.requestJsonToD01 = async function (req,obj,cmd,myMethod) { | |
| 63 | + try { | |
| 64 | + | |
| 65 | + log.log("Connect to D01") | |
| 60 | 66 | |
| 61 | - var objectData = { | |
| 62 | - maxRetry : retry, | |
| 63 | - curRetry : 1 | |
| 64 | - } | |
| 67 | + var service = cfg.service.D01; | |
| 68 | + var retry = service[myMethod+"_"+cmd+"_Retry"]; | |
| 69 | + if(!retry) | |
| 70 | + retry = cfg.Default_Retry; | |
| 65 | 71 | |
| 66 | - // JSON.stringify(json) | |
| 67 | - var params = { | |
| 68 | - url : service[myMethod+"_"+cmd+"_URL"], | |
| 69 | - body : obj, | |
| 70 | - method : myMethod, | |
| 71 | - timeout : service[myMethod+"_"+cmd+"_Timeout"]*1000 | |
| 72 | - } | |
| 72 | + var objectData = { | |
| 73 | + maxRetry : retry, | |
| 74 | + curRetry : 1 | |
| 75 | + } | |
| 73 | 76 | |
| 74 | - log.log(JSON.stringify(params)) | |
| 77 | + // JSON.stringify(json) | |
| 78 | + var params = { | |
| 79 | + url : service[myMethod+"_"+cmd+"_URL"], | |
| 80 | + body : obj, | |
| 81 | + method : myMethod, | |
| 82 | + timeout : service[myMethod+"_"+cmd+"_Timeout"]*1000 | |
| 83 | + } | |
| 75 | 84 | |
| 76 | - var funStats = function(){ | |
| 77 | - stats.sendRestRequest(service.Name,myMethod,cmd); | |
| 78 | - log.logDetail.addOutput(service.Name,myMethod+"_"+cmd,constants.Request,params,obj); | |
| 79 | - }; | |
| 80 | - | |
| 81 | - var funStats = { | |
| 82 | - start : funStats, | |
| 83 | - error : function(response){log.addErrorSummary(service.Name,myMethod+"_"+cmd,response.resultCode,response.resultDescription);} | |
| 84 | - }; | |
| 85 | + log.log("requestData : "+JSON.stringify(params)) | |
| 85 | 86 | |
| 86 | - | |
| 87 | + var funStats = function(){ | |
| 88 | + stats.sendRestRequest(service.Name,myMethod,cmd); | |
| 89 | + log.logDetail.addOutput(req,service.Name,myMethod+"_"+cmd,constants.Request,params,obj); | |
| 90 | + }; | |
| 91 | + | |
| 92 | + var funStats = { | |
| 93 | + start : funStats, | |
| 94 | + error : function(response){log.addErrorSummary(req,service.Name,myMethod+"_"+cmd,response.resultCode,response.resultDescription);} | |
| 95 | + }; | |
| 87 | 96 | |
| 88 | - var result = {}; | |
| 89 | - result.response = {}; | |
| 90 | - result.response.resultData = []; | |
| 97 | + | |
| 91 | 98 | |
| 92 | - | |
| 99 | + var result = {}; | |
| 100 | + result.response = {}; | |
| 101 | + result.response.resultData = []; | |
| 93 | 102 | |
| 94 | - if(params.method == constants.METHOD.GET) | |
| 95 | - { | |
| 96 | - var genUrl = getUrl(params,service["searchRecordLimit"]); | |
| 97 | - if(genUrl.length > 1) | |
| 98 | - { | |
| 99 | - console.log("multi Send"); | |
| 100 | - var multiSend = []; | |
| 101 | - for(var i=0;i<genUrl.length;i++) | |
| 102 | - multiSend.push({url:genUrl[i],method:params.method}); | |
| 103 | 103 | |
| 104 | - var parallelRes = await parallelRequest(multiSend,objectData,funStats); | |
| 105 | 104 | |
| 106 | - var dataRes = {}; | |
| 107 | - for(var i=0;i<multiSend.length;i++) | |
| 105 | + if(params.method == constants.METHOD.GET) | |
| 106 | + { | |
| 107 | + var genUrl = getUrl(params,service["searchRecordLimit"]); | |
| 108 | + if(genUrl.length > 1) | |
| 108 | 109 | { |
| 109 | - // console.log("start loop"); | |
| 110 | - var loopRes = parallelRes[i]; | |
| 111 | - | |
| 112 | - if(loopRes.response) | |
| 110 | + console.log("multi Send"); | |
| 111 | + var multiSend = []; | |
| 112 | + for(var i=0;i<genUrl.length;i++) | |
| 113 | + multiSend.push({url:genUrl[i],method:params.method}); | |
| 114 | + | |
| 115 | + var parallelRes = await parallelRequest(multiSend,objectData,funStats); | |
| 116 | + | |
| 117 | + var dataRes = {}; | |
| 118 | + for(var i=0;i<multiSend.length;i++) | |
| 113 | 119 | { |
| 114 | - var data = JSON.parse(loopRes.response.body); | |
| 115 | - dataRes[i] = {}; | |
| 120 | + // console.log("start loop"); | |
| 121 | + var loopRes = parallelRes[i]; | |
| 122 | + | |
| 123 | + if(loopRes.response) | |
| 124 | + { | |
| 125 | + var data = JSON.parse(loopRes.response.body); | |
| 126 | + dataRes[i] = {}; | |
| 116 | 127 | |
| 117 | - if(!data.resultCode) | |
| 118 | - dataRes[i].err = "Miss resultCode"; | |
| 128 | + if(!data.resultCode) | |
| 129 | + dataRes[i].err = "Miss resultCode"; | |
| 119 | 130 | |
| 120 | - if(!data.resultDescription) | |
| 121 | - dataRes[i].err = "Miss resultDescription" | |
| 131 | + if(!data.resultDescription) | |
| 132 | + dataRes[i].err = "Miss resultDescription" | |
| 122 | 133 | |
| 134 | + | |
| 135 | + dataRes[i].data = data.resultData; | |
| 123 | 136 | |
| 124 | - dataRes[i].data = data.resultData; | |
| 125 | - | |
| 137 | + } | |
| 138 | + | |
| 126 | 139 | } |
| 127 | 140 | |
| 128 | - } | |
| 141 | + for (var i = 0; i < multiSend.length; i++) { | |
| 142 | + | |
| 143 | + result.response.resultData = result.response.resultData.concat(dataRes[i].data); | |
| 144 | + if(dataRes[i].err) | |
| 145 | + result.err = dataRes[i].err; | |
| 146 | + } | |
| 129 | 147 | |
| 130 | - for (var i = 0; i < multiSend.length; i++) { | |
| 131 | - | |
| 132 | - result.response.resultData = result.response.resultData.concat(dataRes[i].data); | |
| 133 | - if(dataRes[i].err) | |
| 134 | - result.err = dataRes[i].err; | |
| 135 | - } | |
| 148 | + if(!result.err) | |
| 149 | + { | |
| 150 | + result.response = constants.RESPONSECONN.MESSAGE.SUCCESS; | |
| 151 | + // result.response.resultCode = "20000"; | |
| 152 | + // result.response.developerMessage = "Success"; | |
| 153 | + } | |
| 136 | 154 | |
| 137 | - if(!result.err) | |
| 155 | + | |
| 156 | + }else | |
| 138 | 157 | { |
| 139 | - result.response = constants.RESPONSECONN.MESSAGE.SUCCESS; | |
| 140 | - // result.response.resultCode = "20000"; | |
| 141 | - // result.response.developerMessage = "Success"; | |
| 158 | + // console.log("single Send"); | |
| 159 | + params.url = genUrl[0]; | |
| 160 | + delete params.body; | |
| 161 | + | |
| 162 | + var resultRes = await asyncRequest(params,objectData,funStats); | |
| 163 | + | |
| 164 | + // console.log(resultRes); | |
| 165 | + if(resultRes.response) | |
| 166 | + { | |
| 167 | + var data = JSON.parse(resultRes.response.body); | |
| 168 | + result.response = data; | |
| 169 | + | |
| 170 | + } else { | |
| 171 | + result = resultRes; | |
| 172 | + } | |
| 142 | 173 | } |
| 143 | 174 | |
| 144 | 175 | |
| 145 | - }else | |
| 176 | + }else if(params.method == constants.METHOD.POST) | |
| 146 | 177 | { |
| 147 | - // console.log("single Send"); | |
| 148 | - params.url = genUrl[0]; | |
| 149 | - delete params.body; | |
| 178 | + params.body = JSON.stringify(params.body); | |
| 150 | 179 | |
| 151 | 180 | var resultRes = await asyncRequest(params,objectData,funStats); |
| 152 | 181 | |
| 153 | - // console.log(resultRes); | |
| 154 | - if(resultRes.response) | |
| 155 | - { | |
| 156 | - var data = JSON.parse(resultRes.response.body); | |
| 157 | - result.response = data; | |
| 158 | - | |
| 182 | + if(resultRes.response){ | |
| 183 | + result.response = JSON.parse(resultRes.body); | |
| 159 | 184 | } else { |
| 160 | 185 | result = resultRes; |
| 161 | 186 | } |
| 162 | 187 | } |
| 163 | 188 | |
| 189 | + // console.log(result); | |
| 164 | 190 | |
| 165 | - } else if(params.method == constants.METHOD.POST){ | |
| 166 | - params.body = JSON.stringify(params.body); | |
| 167 | - | |
| 168 | - var resultRes = await asyncRequest(params,objectData,funStats); | |
| 169 | - | |
| 170 | - if(resultRes.response){ | |
| 171 | - result.response = JSON.parse(resultRes.body); | |
| 172 | - } else { | |
| 173 | - result = resultRes; | |
| 191 | + if(result.response) | |
| 192 | + { | |
| 193 | + if(!result.response.resultCode){ | |
| 194 | + result.err = "Missing resultCode"; | |
| 195 | + } else if(!result.response.resultDescription){ | |
| 196 | + result.err = "Missing resultDescription"; | |
| 197 | + } | |
| 174 | 198 | } |
| 175 | - } else if(params.method == constants.METHOD.PUT){ | |
| 176 | - | |
| 177 | - params.body = JSON.stringify(params.body); | |
| 178 | 199 | |
| 179 | - var resultRes = await asyncRequest(params,objectData,funStats); | |
| 200 | + return checkResponse(result,funStats); | |
| 180 | 201 | |
| 181 | - if(resultRes.response){ | |
| 182 | - result.response = JSON.parse(resultRes.body); | |
| 183 | - } else { | |
| 184 | - result = resultRes; | |
| 185 | - } | |
| 186 | 202 | } |
| 203 | + catch(err) { | |
| 204 | + log.log(err); | |
| 187 | 205 | |
| 188 | - // console.log(result); | |
| 189 | - | |
| 190 | - if(result.response) | |
| 191 | - { | |
| 192 | - if(!result.response.resultCode){ | |
| 193 | - result.err = "Missing resultCode"; | |
| 194 | - } else if(!result.response.resultDescription){ | |
| 195 | - result.err = "Missing resultDescription"; | |
| 196 | - } | |
| 197 | - } | |
| 206 | + var result = { | |
| 207 | + response : constants.RESPONSECONN.MESSAGE.ERROR | |
| 208 | + }; | |
| 209 | + return result; | |
| 198 | 210 | |
| 199 | - return checkResponse(result,funStats); | |
| 211 | + } | |
| 200 | 212 | }; |
| 201 | 213 | |
| 202 | 214 | |
| ... | ... | @@ -241,21 +253,17 @@ function asyncRequest (params = {},objectData,funStat) { |
| 241 | 253 | }else |
| 242 | 254 | { |
| 243 | 255 | var errRes = {}; |
| 244 | - if(error.code == 'ETIMEDOUT'){ | |
| 245 | - // errRes.resultCode = "50003"; | |
| 246 | - // errRes.resultDescription = "Timeout"; | |
| 247 | - errRes.resultCode = "50000"; | |
| 248 | - errRes.resultDescription = "System error"; | |
| 249 | - } else if(error.code == 'ECONNREFUSED'){ | |
| 250 | - // errRes.resultCode = "50002"; | |
| 251 | - // errRes.resultDescription = "Reject"; | |
| 252 | - errRes.resultCode = "50000"; | |
| 253 | - errRes.resultDescription = "System error"; | |
| 256 | + log.log(error,'error'); | |
| 257 | + if(error.code == constants.RESPONSECONN.STATS.ETIMEDOUT){ | |
| 258 | + errRes.response = constants.RESPONSECONN.MESSAGE.ETIMEDOUT; | |
| 259 | + } else if(error.code == constants.RESPONSECONN.STATS.ECONNREFUSED){ | |
| 260 | + errRes.response = constants.RESPONSECONN.MESSAGE.ECONNREFUSED; | |
| 261 | + } else if(error.code == constants.RESPONSECONN.STATS.ESOCKETTIMEDOUT){ | |
| 262 | + errRes.response = constants.RESPONSECONN.MESSAGE.ESOCKETTIMEDOUT; | |
| 254 | 263 | } else { |
| 255 | - errRes.resultCode = "50000"; | |
| 256 | - errRes.resultDescription = "System error"; | |
| 264 | + errRes.response = constants.RESPONSECONN.MESSAGE.ERROR; | |
| 257 | 265 | } |
| 258 | - | |
| 266 | + | |
| 259 | 267 | // console.log("retry "+objectData.curRetry); |
| 260 | 268 | funStat.error(errRes); |
| 261 | 269 | objectData.curRetry++; |
| ... | ... | @@ -374,7 +382,8 @@ function getUrl(params,limit) |
| 374 | 382 | // console.log(filter); |
| 375 | 383 | // console.log(fields); |
| 376 | 384 | |
| 377 | - console.log(returnData); | |
| 385 | + for(var i=0;i<returnData.length;i++) | |
| 386 | + console.log("URL "+[i+1]+" : "+returnData[i]); | |
| 378 | 387 | |
| 379 | 388 | return returnData; |
| 380 | 389 | } |
| ... | ... | @@ -483,9 +492,8 @@ function checkResponse(result,funStats) |
| 483 | 492 | } |
| 484 | 493 | } |
| 485 | 494 | funStats.error(result.response) |
| 486 | - } | |
| 487 | - | |
| 488 | - log.log(JSON.stringify(result)); | |
| 495 | + }else | |
| 496 | + log.log(JSON.stringify(result)); | |
| 489 | 497 | |
| 490 | 498 | return result; |
| 491 | 499 | } | ... | ... |
ais-structure/src/modules/helper/log.js
| ... | ... | @@ -6,15 +6,30 @@ conf.log = cfg.log; |
| 6 | 6 | conf.log.projectName = cfg.app_name; |
| 7 | 7 | |
| 8 | 8 | var logg = require('commonlog-kb').init(conf); |
| 9 | +var logger = []; | |
| 10 | + | |
| 11 | + | |
| 12 | +// var summaryList = []; | |
| 13 | +// var start = {}; | |
| 14 | +// var detail = {}; | |
| 15 | +// var startTime; | |
| 16 | + | |
| 17 | +var mapLog = {}; | |
| 9 | 18 | |
| 10 | -// wait log stats | |
| 11 | -// logg.stat('stat_name'); | |
| 12 | 19 | |
| 13 | -var logger = []; | |
| 14 | -var summaryList = []; | |
| 15 | -var start = {}; | |
| 16 | -var detail = {}; | |
| 17 | -var startTime; | |
| 20 | + | |
| 21 | +logger.startlog = function (req,cmdData,session,identity) | |
| 22 | +{ | |
| 23 | + | |
| 24 | + | |
| 25 | + var start = { | |
| 26 | + session : session, | |
| 27 | + cmd : cmdData, | |
| 28 | + identity : identity | |
| 29 | + }; | |
| 30 | + | |
| 31 | + mapLog[req.id].start = start; | |
| 32 | +} | |
| 18 | 33 | |
| 19 | 34 | logger.stat = function (msg){ |
| 20 | 35 | logg.stat(msg); |
| ... | ... | @@ -48,16 +63,8 @@ logger.log = function (msg,type) |
| 48 | 63 | console.log(msg); |
| 49 | 64 | } |
| 50 | 65 | |
| 51 | -logger.startlog = function (cmdData,session,identity) | |
| 52 | -{ | |
| 53 | - start = { | |
| 54 | - session : session, | |
| 55 | - cmd : cmdData, | |
| 56 | - identity : identity | |
| 57 | - }; | |
| 58 | -} | |
| 59 | 66 | |
| 60 | -logger.addSuccessSummary = function (nodeData,cmdData,resultCode,developerMessage) | |
| 67 | +logger.addSuccessSummary = function (req,nodeData,cmdData,resultCode,developerMessage) | |
| 61 | 68 | { |
| 62 | 69 | summary = { |
| 63 | 70 | node : undefinedToNull(nodeData), |
| ... | ... | @@ -66,11 +73,12 @@ logger.addSuccessSummary = function (nodeData,cmdData,resultCode,developerMessag |
| 66 | 73 | resultDesc : developerMessage, |
| 67 | 74 | type : "success" |
| 68 | 75 | }; |
| 69 | - summaryList.push(summary); | |
| 76 | + mapLog[req.id].summaryList.push(summary); | |
| 77 | + // summaryList.push(summary); | |
| 70 | 78 | // console.log(summary); |
| 71 | 79 | } |
| 72 | 80 | |
| 73 | -logger.addErrorSummary = function (nodeData,cmdData,resultCode,developerMessage) | |
| 81 | +logger.addErrorSummary = function (req,nodeData,cmdData,resultCode,developerMessage) | |
| 74 | 82 | { |
| 75 | 83 | summary = { |
| 76 | 84 | node : undefinedToNull(nodeData), |
| ... | ... | @@ -79,12 +87,18 @@ logger.addErrorSummary = function (nodeData,cmdData,resultCode,developerMessage) |
| 79 | 87 | resultDesc : developerMessage, |
| 80 | 88 | type : "error" |
| 81 | 89 | }; |
| 82 | - summaryList.push(summary); | |
| 90 | + // console.log(mapLog); | |
| 91 | + mapLog[req.id].summaryList.push(summary); | |
| 92 | + // summaryList.push(summary); | |
| 83 | 93 | // console.log(summary); |
| 84 | 94 | } |
| 85 | 95 | |
| 86 | -logger.logSummary = function (response) | |
| 96 | +logger.logSummary = function (req,response) | |
| 87 | 97 | { |
| 98 | + | |
| 99 | + var start = mapLog[req.id].start; | |
| 100 | + var summaryList = mapLog[req.id].summaryList; | |
| 101 | + | |
| 88 | 102 | var log = logg.summary(start.session,start.cmd,start.identity); |
| 89 | 103 | var row; |
| 90 | 104 | for (let index = 0; index < summaryList.length; index++) { |
| ... | ... | @@ -103,7 +117,7 @@ logger.logSummary = function (response) |
| 103 | 117 | } |
| 104 | 118 | } |
| 105 | 119 | |
| 106 | -var addlogDetailData = function(inputType,node,cmd,type,rawData,data){ | |
| 120 | +var addlogDetailData = function(req,inputType,node,cmd,type,rawData,data){ | |
| 107 | 121 | if(inputType == 'input') |
| 108 | 122 | { |
| 109 | 123 | if(rawData) |
| ... | ... | @@ -119,7 +133,7 @@ var addlogDetailData = function(inputType,node,cmd,type,rawData,data){ |
| 119 | 133 | }; |
| 120 | 134 | } |
| 121 | 135 | |
| 122 | - detail.input = { | |
| 136 | + mapLog[req.id].detail.input = { | |
| 123 | 137 | node : undefinedToNull(node), |
| 124 | 138 | cmd : cmd, |
| 125 | 139 | type : type, |
| ... | ... | @@ -127,11 +141,13 @@ var addlogDetailData = function(inputType,node,cmd,type,rawData,data){ |
| 127 | 141 | data : data |
| 128 | 142 | }; |
| 129 | 143 | |
| 144 | + | |
| 130 | 145 | // console.log(detail.input); |
| 131 | 146 | } |
| 132 | 147 | else if(inputType == 'output') |
| 133 | 148 | { |
| 134 | - detail.output = { | |
| 149 | + | |
| 150 | + mapLog[req.id].detail.output = { | |
| 135 | 151 | node : undefinedToNull(node), |
| 136 | 152 | cmd : cmd, |
| 137 | 153 | type : type, |
| ... | ... | @@ -139,6 +155,8 @@ var addlogDetailData = function(inputType,node,cmd,type,rawData,data){ |
| 139 | 155 | data : data |
| 140 | 156 | }; |
| 141 | 157 | |
| 158 | + var start = mapLog[req.id].start; | |
| 159 | + var detail = mapLog[req.id].detail; | |
| 142 | 160 | var log = logg.detail(start.session, start.cmd, start.identity); |
| 143 | 161 | log.addInput( detail.input.node, detail.input.cmd, detail.input.type, detail.input.rawData, detail.input.data ); |
| 144 | 162 | log.addOutput( detail.output.node, detail.output.cmd, detail.output.type, detail.output.rawData, detail.output.data ); |
| ... | ... | @@ -148,15 +166,9 @@ var addlogDetailData = function(inputType,node,cmd,type,rawData,data){ |
| 148 | 166 | } |
| 149 | 167 | |
| 150 | 168 | var logDetailData = { |
| 151 | - addInput : function(node,cmd,type,rawData,data){addlogDetailData('input',node,cmd,type,rawData,data)}, | |
| 152 | - addOutput : function(node,cmd,type,rawData,data){addlogDetailData('output',node,cmd,type,rawData,data)} | |
| 153 | - // write : function () | |
| 154 | - // { | |
| 155 | - // var log = logg.detail(start.session, start.cmd, start.identity); | |
| 156 | - // log.addInput( detail.input.node, detail.input.cmd, detail.input.type, detail.input.rawData, detail.input.data ); | |
| 157 | - // log.addOutput( detail.output.node, detail.output.cmd, detail.output.type, detail.output.rawData, detail.output.data ); | |
| 158 | - // log.end(); | |
| 159 | - // } | |
| 169 | + addInput : function(req,node,cmd,type,rawData,data){addlogDetailData(req,'input',node,cmd,type,rawData,data)}, | |
| 170 | + addOutput : function(req,node,cmd,type,rawData,data){addlogDetailData(req,'output',node,cmd,type,rawData,data)} | |
| 171 | + | |
| 160 | 172 | }; |
| 161 | 173 | |
| 162 | 174 | logger.logDetail = logDetailData; |
| ... | ... | @@ -171,18 +183,23 @@ var undefinedToNull = function(data){ |
| 171 | 183 | return data; |
| 172 | 184 | } |
| 173 | 185 | |
| 186 | + | |
| 187 | + | |
| 174 | 188 | logger.startEC = function(req) |
| 175 | 189 | { |
| 176 | - var newLine = "\r\n"; | |
| 177 | - var messageRes = ''; | |
| 178 | - startTime = new Date(); | |
| 190 | + var objectLog = { | |
| 191 | + summaryList : [], | |
| 192 | + start : {}, | |
| 193 | + detail : {}, | |
| 194 | + startTime : "" | |
| 195 | + } | |
| 179 | 196 | |
| 180 | - // if(!mapTime[req.headers.host]) | |
| 181 | - // { | |
| 182 | - // mapTime[req.headers.host] | |
| 183 | - // } | |
| 184 | 197 | |
| 198 | + mapLog[req.id] = objectLog; | |
| 185 | 199 | |
| 200 | + var newLine = "\r\n"; | |
| 201 | + var messageRes = ''; | |
| 202 | + startTime = new Date(); | |
| 186 | 203 | |
| 187 | 204 | // console.log(Object.keys(req)); |
| 188 | 205 | // console.log(req.headers); |
| ... | ... | @@ -206,21 +223,26 @@ logger.startEC = function(req) |
| 206 | 223 | } |
| 207 | 224 | |
| 208 | 225 | messageRes += newLine+newLine+"#====> Incoming Message <====# "; |
| 226 | + messageRes += newLine+"Session : "+req.id; | |
| 209 | 227 | messageRes += newLine+"Header : "+header; |
| 210 | 228 | messageRes += newLine+"Body : "+body; |
| 211 | 229 | messageRes += newLine+"Time in : "+startTime.toISOString(); |
| 212 | 230 | messageRes += newLine |
| 213 | 231 | |
| 214 | - logger.log(messageRes); | |
| 232 | + logg.debug(messageRes); | |
| 233 | + // logger.log(messageRes); | |
| 215 | 234 | }; |
| 216 | 235 | |
| 217 | -logger.endEC = function(res) | |
| 236 | +logger.endEC = function(req,res) | |
| 218 | 237 | { |
| 219 | 238 | |
| 220 | 239 | var newLine = "\r\n"; |
| 221 | 240 | var messageRes = ''; |
| 241 | + var startTime = mapLog[req.id].startTime; | |
| 222 | 242 | var endTime = new Date(); |
| 243 | + | |
| 223 | 244 | |
| 245 | + // console.log(mapLog); | |
| 224 | 246 | |
| 225 | 247 | var body = ""; |
| 226 | 248 | if(res.resBody) |
| ... | ... | @@ -241,6 +263,7 @@ logger.endEC = function(res) |
| 241 | 263 | } |
| 242 | 264 | |
| 243 | 265 | messageRes += newLine+newLine+"#====> Outgoing Message <====# "; |
| 266 | + messageRes += newLine+"Session : "+req.id; | |
| 244 | 267 | messageRes += newLine+"Header : "+header; |
| 245 | 268 | messageRes += newLine+"Body : "+body; |
| 246 | 269 | messageRes += newLine+"Time out : "+endTime.toISOString(); |
| ... | ... | @@ -285,7 +308,8 @@ logger.endEC = function(res) |
| 285 | 308 | // ________________________________________________________________________________________________________________________ |
| 286 | 309 | // `; |
| 287 | 310 | |
| 288 | - logger.log(messageRes); | |
| 311 | + logg.debug(messageRes); | |
| 312 | + // logger.log(messageRes); | |
| 289 | 313 | messageRes += newLine |
| 290 | 314 | }; |
| 291 | 315 | ... | ... |
| ... | ... | @@ -0,0 +1,114 @@ |
| 1 | +var env = process.env.NODE_ENV || 'development'; | |
| 2 | +var responseMsg = require('../modules/helper/responseMsg.js'); | |
| 3 | +var log = require('../modules/helper/log.js'); | |
| 4 | +var constants = require('../modules/helper/constants.js'); | |
| 5 | + | |
| 6 | +var cfg = require('../config/config.js').get(env); | |
| 7 | +var load = require('express-load'); | |
| 8 | + | |
| 9 | + | |
| 10 | +module.exports = function (app) { | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + app.all('/*', function (req, res,next) { | |
| 15 | + | |
| 16 | + | |
| 17 | + // console.log(req.params) | |
| 18 | + // console.log(req.query) | |
| 19 | + // console.log(req.url) | |
| 20 | + var splitPath = req._parsedUrl.pathname.split("/"); | |
| 21 | + //0 = ip host | |
| 22 | + //1 = 'cmf' | |
| 23 | + //2 = 'v1' | |
| 24 | + | |
| 25 | + var objectData = { | |
| 26 | + method:req.method, | |
| 27 | + req:req, | |
| 28 | + res:res, | |
| 29 | + next:next, | |
| 30 | + splitPath:splitPath, | |
| 31 | + pathname:req._parsedUrl.pathname | |
| 32 | + }; | |
| 33 | + | |
| 34 | + switch (splitPath[3]) { | |
| 35 | + case "customers": | |
| 36 | + if(splitPath[splitPath.length-1] == "membercards") | |
| 37 | + { | |
| 38 | + doMembercards(objectData); | |
| 39 | + } | |
| 40 | + else | |
| 41 | + { | |
| 42 | + objectData.modules = app.modules.customer; | |
| 43 | + doCustomers(objectData); | |
| 44 | + } | |
| 45 | + break; | |
| 46 | + case "vizcards": | |
| 47 | + doVizcard(objectData); | |
| 48 | + break; | |
| 49 | + default: next(); | |
| 50 | + break; | |
| 51 | + } | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + }); | |
| 57 | + | |
| 58 | + function doVizcard(objectData) | |
| 59 | + { | |
| 60 | + console.log("Route : "+objectData.pathname+" => doVizcard"); | |
| 61 | + objectData.next(); | |
| 62 | + } | |
| 63 | + | |
| 64 | + function doMembercards(objectData) | |
| 65 | + { | |
| 66 | + console.log("Route : "+objectData.pathname+" => doMembercards"); | |
| 67 | + objectData.next(); | |
| 68 | + | |
| 69 | + } | |
| 70 | + | |
| 71 | + function doCustomers(objectData) | |
| 72 | + { | |
| 73 | + console.log("Route : "+objectData.pathname+" => doCustomers"); | |
| 74 | + | |
| 75 | + // "/cmf/v1/customers/:customerId", | |
| 76 | + // "/cmf/v1/customers/:userType/:userData", | |
| 77 | + // "/cmf/v1/customers" | |
| 78 | + | |
| 79 | + var doAction = function(){ | |
| 80 | + | |
| 81 | + if(objectData.method == constants.METHOD.GET) | |
| 82 | + objectData.modules.customerCtrl.customer(objectData.req,objectData.res,objectData.next); | |
| 83 | + else | |
| 84 | + objectData.modules.postCustomerCtrl.customer(objectData.req,objectData.res,objectData.next); | |
| 85 | + }; | |
| 86 | + | |
| 87 | + switch (objectData.splitPath.length) { | |
| 88 | + case 4: | |
| 89 | + | |
| 90 | + doAction(); | |
| 91 | + break; | |
| 92 | + case 5: | |
| 93 | + objectData.req.params = { | |
| 94 | + customerId:objectData.splitPath[4] | |
| 95 | + }; | |
| 96 | + doAction(); | |
| 97 | + break; | |
| 98 | + case 6: | |
| 99 | + objectData.req.params = { | |
| 100 | + userType:objectData.splitPath[4], | |
| 101 | + userData:objectData.splitPath[5], | |
| 102 | + }; | |
| 103 | + doAction(); | |
| 104 | + break; | |
| 105 | + | |
| 106 | + default: | |
| 107 | + objectData.next(); | |
| 108 | + break; | |
| 109 | + } | |
| 110 | + } | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | +}; | ... | ... |
ais-structure/src/modules/vizcard/vizCard.ctrl.js
| ... | ... | @@ -17,20 +17,20 @@ exports.vizcard = async function (req, res, next) { |
| 17 | 17 | if(req.query.clientName && req.query.commandId){ |
| 18 | 18 | var customerId = req.query.clientName+"@"+req.query.commandId; |
| 19 | 19 | } |
| 20 | - log.startlog(method+"_"+getCmd,req.query.commandId,customerId); | |
| 21 | - log.logDetail.addInput(req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | |
| 20 | + log.startlog(req,method+"_"+getCmd,req.query.commandId,customerId); | |
| 21 | + log.logDetail.addInput(req,req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | |
| 22 | 22 | |
| 23 | 23 | var err = validator(req,getCmd); |
| 24 | 24 | |
| 25 | 25 | if(err.length > 0) |
| 26 | 26 | { |
| 27 | - log.addErrorSummary(req.query.clientName,method+"_"+getCmd,"null","Fail"); | |
| 28 | - log.log(err,'error'); | |
| 27 | + log.addErrorSummary(req,req.query.clientName,method+"_"+getCmd,"null","Fail"); | |
| 28 | + // log.log(err,'error'); | |
| 29 | 29 | var response = responseMsg.error(req,getCmd,40300); |
| 30 | 30 | // res.status(200).json(response); |
| 31 | 31 | }else |
| 32 | 32 | { |
| 33 | - log.addSuccessSummary(req.query.clientName,method+"_"+getCmd,"null","Success"); | |
| 33 | + log.addSuccessSummary(req,req.query.clientName,method+"_"+getCmd,"null","Success"); | |
| 34 | 34 | var objectData = { |
| 35 | 35 | Username : "axviz", |
| 36 | 36 | Password : "1234", |
| ... | ... | @@ -57,13 +57,13 @@ exports.vizcard = async function (req, res, next) { |
| 57 | 57 | stats.receiveSACFResponse(sacf,sendCmd,"Success"); |
| 58 | 58 | var response = responseMsg.success(req,getCmd,{resultData:resultSet.returnData,rowCount:resultSet.returnData.length}); |
| 59 | 59 | |
| 60 | - log.addSuccessSummary(sacf,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
| 60 | + log.addSuccessSummary(req,sacf,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
| 61 | 61 | } |
| 62 | 62 | catch(error) { |
| 63 | 63 | log.log(error,'error') |
| 64 | 64 | stats.receiveSACFBadResponse(sacf,sendCmd); |
| 65 | 65 | response = responseMsg.error(req,getCmd,50000); |
| 66 | - log.addErrorSummary(sacf,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
| 66 | + log.addErrorSummary(req,sacf,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
| 67 | 67 | var resultSet = {rawDataJson : ""} |
| 68 | 68 | } |
| 69 | 69 | |
| ... | ... | @@ -74,11 +74,11 @@ exports.vizcard = async function (req, res, next) { |
| 74 | 74 | var resultSet = {rawDataJson : ""} |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - log.logDetail.addInput(sacf,method+"_"+sendCmd,constant.RESPONSE,result,resultSet.rawDataJson); | |
| 77 | + log.logDetail.addInput(req,sacf,method+"_"+sendCmd,constant.RESPONSE,result,resultSet.rawDataJson); | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // console.log(response); |
| 81 | - log.logDetail.addOutput(sacf,method+"_"+getCmd,constant.RESPONSE,response,response); | |
| 81 | + log.logDetail.addOutput(req,sacf,method+"_"+getCmd,constant.RESPONSE,response,response); | |
| 82 | 82 | res.status(200).json(response); |
| 83 | 83 | next(); |
| 84 | 84 | }; | ... | ... |