Commit 79d9e5349df175020a5378852774135e85d29d9a
1 parent
2b14eb08
Exists in
master
and in
1 other branch
update post customer
Showing
5 changed files
with
37 additions
and
47 deletions
Show diff stats
ais-structure/src/modules/customer/customer.ctrl.js
| ... | ... | @@ -12,8 +12,6 @@ exports.customer = async function (req, res, next) { |
| 12 | 12 | var d01 = "D01" |
| 13 | 13 | var method = constant.METHOD.GET |
| 14 | 14 | |
| 15 | - var err = validator(req,getCmd); | |
| 16 | - | |
| 17 | 15 | if(req.params.customerId){ |
| 18 | 16 | var customerId = req.params.customerId |
| 19 | 17 | } else if(req.params.userData && req.params.userType){ |
| ... | ... | @@ -23,7 +21,9 @@ exports.customer = async function (req, res, next) { |
| 23 | 21 | } |
| 24 | 22 | |
| 25 | 23 | log.startlog(method+"_"+getCmd,req.query.commandId,customerId); |
| 26 | - log.logDetail.addInput(req.query.clientName,getCmd,constant.REQUEST,req,req.body); | |
| 24 | + log.logDetail.addInput(req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | |
| 25 | + | |
| 26 | + var err = validator(req,getCmd); | |
| 27 | 27 | |
| 28 | 28 | if(err.length > 0) |
| 29 | 29 | { |
| ... | ... | @@ -37,7 +37,7 @@ exports.customer = async function (req, res, next) { |
| 37 | 37 | var objectData = req.query; |
| 38 | 38 | const result = await connection.requestJsonToD01(objectData,sendCmd,method); |
| 39 | 39 | // console.log(Object.keys(result)) |
| 40 | - log.logDetail.addInput(d01,sendCmd,constant.RESPONSE,result,result.response); | |
| 40 | + log.logDetail.addInput(d01,method+"_"+sendCmd,constant.RESPONSE,result,result.response); | |
| 41 | 41 | if(typeof result.err === 'undefined'){ |
| 42 | 42 | // console.log(result.response); |
| 43 | 43 | var resultObj = result.response; |
| ... | ... | @@ -56,18 +56,12 @@ exports.customer = async function (req, res, next) { |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } else { |
| 59 | - stats.receiveRestResponse(d01,method,sendCmd,"Error"); | |
| 60 | - response = responseMsg.direct(req,getCmd,result.response); | |
| 59 | + var response = responseMsg.direct(req,getCmd,result.response); | |
| 61 | 60 | log.addErrorSummary(d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); |
| 62 | 61 | } |
| 63 | 62 | } |
| 64 | 63 | |
| 65 | - if(!response){ | |
| 66 | - var response = responseMsg.error(req,getCmd,50000); | |
| 67 | - stats.receiveRestResponse(d01,method,sendCmd,"Error"); | |
| 68 | - } | |
| 69 | - | |
| 70 | - log.logDetail.addOutput(req.query.clientName,getCmd,constant.RESPONSE,response,response); | |
| 64 | + log.logDetail.addOutput(req.query.clientName,method+"_"+getCmd,constant.RESPONSE,response,response); | |
| 71 | 65 | res.status(200).json(response); |
| 72 | 66 | next(); |
| 73 | 67 | }; | ... | ... |
ais-structure/src/modules/customer/postCustomer.ctrl.js
| ... | ... | @@ -10,20 +10,27 @@ exports.postCustomer = async function (req, res, next){ |
| 10 | 10 | var sendCmd = "Customer"; |
| 11 | 11 | var sacf = "SACF"; |
| 12 | 12 | var d01 = "D01"; |
| 13 | + var method = constant.METHOD.POST; | |
| 13 | 14 | |
| 14 | - log.startlog(getCmd,req); | |
| 15 | - log.logDetail.addInput(sacf,getCmd,constant.REQUEST,req,req.body); | |
| 15 | + if(req.params.userData && req.params.userType){ | |
| 16 | + var customerId = req.body.user.userData+"@"+req.body.user.userType; | |
| 17 | + } | |
| 18 | + | |
| 19 | + log.startlog(method+"_"+getCmd,req.body.commandId,customerId); | |
| 20 | + log.logDetail.addInput(req.body.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | |
| 16 | 21 | |
| 17 | 22 | var err = validator(req,getCmd); |
| 18 | 23 | |
| 19 | 24 | if(err.length > 0) |
| 20 | 25 | { |
| 26 | + log.addErrorSummary(req.query.clientName,method+"_"+getCmd,"null","Fail"); | |
| 21 | 27 | console.log(err); |
| 22 | 28 | var response = responseMsg.error(req,getCmd,40300); |
| 23 | 29 | }else |
| 24 | 30 | { |
| 31 | + log.addSuccessSummary(req.query.clientName,method+"_"+getCmd,"null","Success"); | |
| 25 | 32 | var objectData = { |
| 26 | - customerId : req.body.user.userData+"@"+req.body.user.userType, | |
| 33 | + customerId : customerId, | |
| 27 | 34 | userIdData : req.body.user.userData, |
| 28 | 35 | userIdType : req.body.user.userType, |
| 29 | 36 | firstName : req.body.firstName, |
| ... | ... | @@ -34,7 +41,7 @@ exports.postCustomer = async function (req, res, next){ |
| 34 | 41 | }; |
| 35 | 42 | |
| 36 | 43 | const result = await connection.requestJsonToD01(objectData,sendCmd,"POST"); |
| 37 | - log.logDetail.addInput(d01,sendCmd,constant.RESPONSE,result,result.response); | |
| 44 | + log.logDetail.addInput(d01,method+"_"+sendCmd,constant.RESPONSE,result,result.response); | |
| 38 | 45 | if(typeof result.err === 'undefined'){ |
| 39 | 46 | // console.log(result.response.body); |
| 40 | 47 | var resultObj = result.response; |
| ... | ... | @@ -42,27 +49,23 @@ exports.postCustomer = async function (req, res, next){ |
| 42 | 49 | { |
| 43 | 50 | stats.receiveRestResponse(d01,constant.METHOD.POST,sendCmd,"Success"); |
| 44 | 51 | var response = responseMsg.direct(req,getCmd,resultObj,{customerId:objectData.customerId}); |
| 45 | - log.addSuccessSummary(d01,sendCmd,response); | |
| 52 | + log.addSuccessSummary(d01,method+"_"+sendCmd,response); | |
| 46 | 53 | } else { |
| 47 | 54 | if(resultObj.resultCode != "40401"){ |
| 48 | 55 | resultObj.resultCode = "50000"; |
| 49 | 56 | } |
| 50 | 57 | stats.receiveRestResponse(d01,constant.METHOD.POST,sendCmd,"Error"); |
| 51 | 58 | var response = responseMsg.direct(req,getCmd,resultObj); |
| 52 | - log.addErrorSummary(d01,sendCmd,response); | |
| 59 | + log.addErrorSummary(d01,method+"_"+sendCmd,response); | |
| 53 | 60 | } |
| 54 | 61 | } else { |
| 55 | - response = responseMsg.direct(req,getCmd,result.response); | |
| 56 | - log.addErrorSummary(d01,sendCmd,response); | |
| 62 | + stats.receiveRestResponse(d01,constant.METHOD.POST,sendCmd,"Error"); | |
| 63 | + var response = responseMsg.direct(req,getCmd,result.response); | |
| 64 | + log.addErrorSummary(d01,method+"_"+sendCmd,response); | |
| 57 | 65 | } |
| 58 | 66 | } |
| 59 | 67 | |
| 60 | - if(!response){ | |
| 61 | - var response = responseMsg.error(req,getCmd,50000); | |
| 62 | - stats.receiveResponse(sacf,sendCmd,"Error"); | |
| 63 | - } | |
| 64 | - | |
| 65 | - log.logDetail.addOutput(sacf,getCmd,constant.RESPONSE,response,response); | |
| 68 | + log.logDetail.addOutput(req.body.clientName,getCmd,constant.RESPONSE,response,response); | |
| 66 | 69 | res.status(200).json(response); |
| 67 | 70 | next(); |
| 68 | 71 | }; | ... | ... |
ais-structure/src/modules/helper/connection.js
| ... | ... | @@ -31,12 +31,12 @@ connection.requestSoapToSACF = async function (soap,cmd,myMethod) { |
| 31 | 31 | |
| 32 | 32 | var funS = function(){ |
| 33 | 33 | stats.sendSACFRequest(service.Name,cmd); |
| 34 | - log.logDetail.addOutput(service.Name,cmd,constants.REQUEST,params,soap); | |
| 34 | + log.logDetail.addOutput(service.Name,myMethod+"_"+cmd,constants.REQUEST,params,soap); | |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | var funStats = { |
| 38 | 38 | start : funS, |
| 39 | - error : function(response){log.addErrorSummary(service.Name,cmd,response);} | |
| 39 | + error : function(response){log.addErrorSummary(service.Name,myMethod+"_"+cmd,response);} | |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | 42 | |
| ... | ... | @@ -89,12 +89,12 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
| 89 | 89 | |
| 90 | 90 | var funStats = function(){ |
| 91 | 91 | stats.sendRestRequest(service.Name,myMethod,cmd); |
| 92 | - log.logDetail.addOutput(service.Name,cmd,constants.Request,params,obj); | |
| 92 | + log.logDetail.addOutput(service.Name,myMethod+"_"+cmd,constants.Request,params,obj); | |
| 93 | 93 | }; |
| 94 | 94 | |
| 95 | 95 | var funStats = { |
| 96 | 96 | start : funStats, |
| 97 | - error : function(response){log.addErrorSummary(service.Name,cmd,response);} | |
| 97 | + error : function(response){log.addErrorSummary(service.Name,myMethod+"_"+cmd,response);} | |
| 98 | 98 | }; |
| 99 | 99 | |
| 100 | 100 | |
| ... | ... | @@ -165,7 +165,7 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
| 165 | 165 | |
| 166 | 166 | var resultRes = await asyncRequest(params,objectData,funStats); |
| 167 | 167 | |
| 168 | - console.log(resultRes); | |
| 168 | + // console.log(resultRes); | |
| 169 | 169 | if(resultRes.response) |
| 170 | 170 | { |
| 171 | 171 | var data = JSON.parse(resultRes.response.body); |
| ... | ... | @@ -188,7 +188,7 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
| 188 | 188 | |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - console.log(result); | |
| 191 | + // console.log(result); | |
| 192 | 192 | |
| 193 | 193 | if(result.response) |
| 194 | 194 | { |
| ... | ... | @@ -312,15 +312,15 @@ function getUrl(params,limit) |
| 312 | 312 | if(key == "fields") |
| 313 | 313 | fields = getFields(params.body.fields,first); |
| 314 | 314 | else |
| 315 | - filter = getfilter(filter,key,params.body[key]); | |
| 315 | + filter = getFilter(filter,key,params.body[key]); | |
| 316 | 316 | |
| 317 | 317 | first = false; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | if(first) |
| 321 | - fields = "?limit="+limit; | |
| 321 | + fields += "?limit="+limit; | |
| 322 | 322 | else |
| 323 | - fields = "&limit="+limit; | |
| 323 | + fields += "&limit="+limit; | |
| 324 | 324 | |
| 325 | 325 | } |
| 326 | 326 | |
| ... | ... | @@ -375,7 +375,7 @@ function getUrl(params,limit) |
| 375 | 375 | // console.log(filter); |
| 376 | 376 | // console.log(fields); |
| 377 | 377 | |
| 378 | - // console.log(returnData); | |
| 378 | + console.log(returnData); | |
| 379 | 379 | |
| 380 | 380 | return returnData; |
| 381 | 381 | } |
| ... | ... | @@ -394,7 +394,7 @@ function getFields(fields,first) |
| 394 | 394 | return returnData; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | -function getfilter(filter,key,data) | |
| 397 | +function getFilter(filter,key,data) | |
| 398 | 398 | { |
| 399 | 399 | |
| 400 | 400 | // console.log(key); | ... | ... |
ais-structure/src/modules/helper/responseMsg.js
| ... | ... | @@ -33,7 +33,7 @@ responseMsg.success = function (req,cmd,data){ |
| 33 | 33 | |
| 34 | 34 | var response = { |
| 35 | 35 | resultCode : constants.RESPONSERESULT.SUCCESS.resultCode, |
| 36 | - developerMessage : constants.RESPONSERESULT.SUCCESS.resultDescription, | |
| 36 | + developerMessage : constants.RESPONSERESULT.SUCCESS.developerMessage, | |
| 37 | 37 | resultData : data.resultData, |
| 38 | 38 | rowCount : data.resultData.length |
| 39 | 39 | }; | ... | ... |
ais-structure/src/modules/vizcard/vizCard.ctrl.js
| ... | ... | @@ -75,18 +75,11 @@ exports.vizcard = async function (req, res, next) { |
| 75 | 75 | var resultSet = {rawDataJson : ""} |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - log.logDetail.addInput(sacf,sendCmd,constant.RESPONSE,result,resultSet.rawDataJson); | |
| 79 | - | |
| 80 | - if(!response){ | |
| 81 | - var response = responseMsg.error(req,getCmd,50000); | |
| 82 | - stats.receiveSACFResponse(sacf,sendCmd,"Error"); | |
| 83 | - } | |
| 84 | - | |
| 85 | - | |
| 78 | + log.logDetail.addInput(sacf,method+"_"+sendCmd,constant.RESPONSE,result,resultSet.rawDataJson); | |
| 86 | 79 | } |
| 87 | 80 | |
| 88 | 81 | // console.log(response); |
| 89 | - log.logDetail.addOutput(sacf,getCmd,constant.RESPONSE,response,response); | |
| 82 | + log.logDetail.addOutput(sacf,method+"_"+getCmd,constant.RESPONSE,response,response); | |
| 90 | 83 | res.status(200).json(response); |
| 91 | 84 | next(); |
| 92 | 85 | }; | ... | ... |