Commit 1f123eb14d93c1fda5dc73f24342fc78ba531f8a
1 parent
c4a567d0
Exists in
master
and in
1 other branch
update post membership
Showing
6 changed files
with
116 additions
and
72 deletions
Show diff stats
ais-structure/src/modules/customer/postCustomer.ctrl.js
| @@ -15,19 +15,19 @@ exports.postCustomer = async function (req, res, next){ | @@ -15,19 +15,19 @@ exports.postCustomer = async function (req, res, next){ | ||
| 15 | var customerId = req.body.user.userData+"@"+req.body.user.userType; | 15 | var customerId = req.body.user.userData+"@"+req.body.user.userType; |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | - log.startlog(method+"_"+getCmd,req.body.commandId,customerId); | ||
| 19 | - log.logDetail.addInput(req.body.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | 18 | + log.startlog(req,method+"_"+getCmd,req.body.commandId,customerId); |
| 19 | + log.logDetail.addInput(req,req.body.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | ||
| 20 | 20 | ||
| 21 | var err = validator(req,getCmd); | 21 | var err = validator(req,getCmd); |
| 22 | 22 | ||
| 23 | if(err.length > 0) | 23 | if(err.length > 0) |
| 24 | { | 24 | { |
| 25 | - log.addErrorSummary(req.body.clientName,method+"_"+getCmd,"null",constant.FAIL); | 25 | + log.addErrorSummary(req,req.body.clientName,method+"_"+getCmd,"null",constant.FAIL); |
| 26 | console.log(err); | 26 | console.log(err); |
| 27 | var response = responseMsg.error(req,getCmd,40300); | 27 | var response = responseMsg.error(req,getCmd,40300); |
| 28 | }else | 28 | }else |
| 29 | { | 29 | { |
| 30 | - log.addSuccessSummary(req.body.clientName,method+"_"+getCmd,"null",constant.SUCCESS); | 30 | + log.addSuccessSummary(req,req.body.clientName,method+"_"+getCmd,"null",constant.SUCCESS); |
| 31 | var objectData = { | 31 | var objectData = { |
| 32 | customerId : customerId, | 32 | customerId : customerId, |
| 33 | userIdData : req.body.user.userData, | 33 | userIdData : req.body.user.userData, |
| @@ -39,23 +39,23 @@ exports.postCustomer = async function (req, res, next){ | @@ -39,23 +39,23 @@ exports.postCustomer = async function (req, res, next){ | ||
| 39 | dateCreated : req.body.dateCreated | 39 | dateCreated : req.body.dateCreated |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | - const result = await connection.requestJsonToD01(objectData,sendCmd,method); | ||
| 43 | - log.logDetail.addInput(d01,method+"_"+sendCmd,constant.RESPONSE,result,result.response); | 42 | + const result = await connection.requestJsonToD01(req,objectData,sendCmd,method); |
| 43 | + log.logDetail.addInput(req,d01,method+"_"+sendCmd,constant.RESPONSE,result,result.response); | ||
| 44 | if(typeof result.err === 'undefined'){ | 44 | if(typeof result.err === 'undefined'){ |
| 45 | // console.log(result.response.body); | 45 | // console.log(result.response.body); |
| 46 | var resultObj = result.response; | 46 | var resultObj = result.response; |
| 47 | if(resultObj.resultCode.startsWith("2")){ | 47 | if(resultObj.resultCode.startsWith("2")){ |
| 48 | stats.receiveRestResponse(d01,method,sendCmd,constant.SUCCESS); | 48 | stats.receiveRestResponse(d01,method,sendCmd,constant.SUCCESS); |
| 49 | var response = responseMsg.direct(req,getCmd,resultObj,{customerId:objectData.customerId}); | 49 | var response = responseMsg.direct(req,getCmd,resultObj,{customerId:objectData.customerId}); |
| 50 | - log.addSuccessSummary(d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); | 50 | + log.addSuccessSummary(req,d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); |
| 51 | } else if(resultObj.resultCode.startsWith("404")){ | 51 | } else if(resultObj.resultCode.startsWith("404")){ |
| 52 | stats.receiveRestResponse(d01,method,sendCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); | 52 | stats.receiveRestResponse(d01,method,sendCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); |
| 53 | var response = responseMsg.direct(req,getCmd,resultObj); | 53 | var response = responseMsg.direct(req,getCmd,resultObj); |
| 54 | - log.addErrorSummary(d01,method+"_"+sendCmd,resultObj.resultCode,resultObj.developerMessage); | 54 | + log.addErrorSummary(req,d01,method+"_"+sendCmd,resultObj.resultCode,resultObj.developerMessage); |
| 55 | } else if(resultObj.resultCode.startsWith("5")){ | 55 | } else if(resultObj.resultCode.startsWith("5")){ |
| 56 | stats.receiveRestResponse(d01,method,sendCmd,constant.ERROR); | 56 | stats.receiveRestResponse(d01,method,sendCmd,constant.ERROR); |
| 57 | var response = responseMsg.direct(req,getCmd,resultObj); | 57 | var response = responseMsg.direct(req,getCmd,resultObj); |
| 58 | - log.addErrorSummary(d01,method+"_"+sendCmd,resultObj.resultCode,resultObj.developerMessage); | 58 | + log.addErrorSummary(req,d01,method+"_"+sendCmd,resultObj.resultCode,resultObj.developerMessage); |
| 59 | } else { | 59 | } else { |
| 60 | stats.receiveRestResponse(d01,method,sendCmd,constant.ERROR); | 60 | stats.receiveRestResponse(d01,method,sendCmd,constant.ERROR); |
| 61 | var response = responseMsg.error(req,getCmd,50000); | 61 | var response = responseMsg.error(req,getCmd,50000); |
| @@ -66,7 +66,7 @@ exports.postCustomer = async function (req, res, next){ | @@ -66,7 +66,7 @@ exports.postCustomer = async function (req, res, next){ | ||
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | - log.logDetail.addOutput(req.body.clientName,method+"_"+getCmd,constant.RESPONSE,response,response); | 69 | + log.logDetail.addOutput(req,req.body.clientName,method+"_"+getCmd,constant.RESPONSE,response,response); |
| 70 | res.status(200).json(response); | 70 | res.status(200).json(response); |
| 71 | next(); | 71 | next(); |
| 72 | }; | 72 | }; |
ais-structure/src/modules/helper/connection.js
| @@ -173,8 +173,20 @@ connection.requestJsonToD01 = async function (req,obj,cmd,myMethod) { | @@ -173,8 +173,20 @@ connection.requestJsonToD01 = async function (req,obj,cmd,myMethod) { | ||
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | 175 | ||
| 176 | - }else if(params.method == constants.METHOD.POST) | ||
| 177 | - { | 176 | + } else if(params.method == constants.METHOD.POST) { |
| 177 | + params.body = JSON.stringify(params.body); | ||
| 178 | + | ||
| 179 | + var resultRes = await asyncRequest(params,objectData,funStats); | ||
| 180 | + | ||
| 181 | + if(resultRes.response){ | ||
| 182 | + result.response = JSON.parse(resultRes.body); | ||
| 183 | + } else { | ||
| 184 | + result = resultRes; | ||
| 185 | + } | ||
| 186 | + } else if(params.method == constants.METHOD.PUT) { | ||
| 187 | + | ||
| 188 | + | ||
| 189 | + | ||
| 178 | params.body = JSON.stringify(params.body); | 190 | params.body = JSON.stringify(params.body); |
| 179 | 191 | ||
| 180 | var resultRes = await asyncRequest(params,objectData,funStats); | 192 | var resultRes = await asyncRequest(params,objectData,funStats); |
| @@ -383,7 +395,7 @@ function getUrl(params,limit) | @@ -383,7 +395,7 @@ function getUrl(params,limit) | ||
| 383 | // console.log(fields); | 395 | // console.log(fields); |
| 384 | 396 | ||
| 385 | for(var i=0;i<returnData.length;i++) | 397 | for(var i=0;i<returnData.length;i++) |
| 386 | - console.log("URL "+[i+1]+" : "+returnData[i]); | 398 | + log.log("URL "+[i+1]+" : "+returnData[i]); |
| 387 | 399 | ||
| 388 | return returnData; | 400 | return returnData; |
| 389 | } | 401 | } |
ais-structure/src/modules/main.route.js
| @@ -49,28 +49,24 @@ module.exports = function (app) { | @@ -49,28 +49,24 @@ module.exports = function (app) { | ||
| 49 | default: next(); | 49 | default: next(); |
| 50 | break; | 50 | break; |
| 51 | } | 51 | } |
| 52 | - | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 56 | }); | 52 | }); |
| 57 | 53 | ||
| 58 | function doVizcard(objectData) | 54 | function doVizcard(objectData) |
| 59 | { | 55 | { |
| 60 | - console.log("Route : "+objectData.pathname+" => doVizcard"); | 56 | + log.log("Route : "+objectData.pathname+" => doVizcard"); |
| 61 | objectData.next(); | 57 | objectData.next(); |
| 62 | } | 58 | } |
| 63 | 59 | ||
| 64 | function doMembercards(objectData) | 60 | function doMembercards(objectData) |
| 65 | { | 61 | { |
| 66 | - console.log("Route : "+objectData.pathname+" => doMembercards"); | 62 | + log.log("Route : "+objectData.pathname+" => doMembercards"); |
| 67 | objectData.next(); | 63 | objectData.next(); |
| 68 | 64 | ||
| 69 | } | 65 | } |
| 70 | 66 | ||
| 71 | function doCustomers(objectData) | 67 | function doCustomers(objectData) |
| 72 | { | 68 | { |
| 73 | - console.log("Route : "+objectData.pathname+" => doCustomers"); | 69 | + log.log("Route : "+objectData.pathname+" => doCustomers"); |
| 74 | 70 | ||
| 75 | // "/cmf/v1/customers/:customerId", | 71 | // "/cmf/v1/customers/:customerId", |
| 76 | // "/cmf/v1/customers/:userType/:userData", | 72 | // "/cmf/v1/customers/:userType/:userData", |
| @@ -81,7 +77,7 @@ module.exports = function (app) { | @@ -81,7 +77,7 @@ module.exports = function (app) { | ||
| 81 | if(objectData.method == constants.METHOD.GET) | 77 | if(objectData.method == constants.METHOD.GET) |
| 82 | objectData.modules.customerCtrl.customer(objectData.req,objectData.res,objectData.next); | 78 | objectData.modules.customerCtrl.customer(objectData.req,objectData.res,objectData.next); |
| 83 | else | 79 | else |
| 84 | - objectData.modules.postCustomerCtrl.customer(objectData.req,objectData.res,objectData.next); | 80 | + objectData.modules.postCustomerCtrl.postCustomer(objectData.req,objectData.res,objectData.next); |
| 85 | }; | 81 | }; |
| 86 | 82 | ||
| 87 | switch (objectData.splitPath.length) { | 83 | switch (objectData.splitPath.length) { |
ais-structure/src/modules/membercard/getMembership.ctrl.js
| @@ -23,22 +23,22 @@ exports.getMembership = async function (req, res, next) { | @@ -23,22 +23,22 @@ exports.getMembership = async function (req, res, next) { | ||
| 23 | var customerId = req.query.clientName+"@"+req.query.commandId; | 23 | var customerId = req.query.clientName+"@"+req.query.commandId; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | - log.startlog(method+"_"+getCmd,req.query.commandId,customerId); | ||
| 27 | - log.logDetail.addInput(req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | 26 | + log.startlog(req,method+"_"+getCmd,req.query.commandId,customerId); |
| 27 | + log.logDetail.addInput(req,req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | ||
| 28 | 28 | ||
| 29 | var err = validator(req,getCmd); | 29 | var err = validator(req,getCmd); |
| 30 | 30 | ||
| 31 | if(err.length > 0) | 31 | if(err.length > 0) |
| 32 | { | 32 | { |
| 33 | - log.addErrorSummary(req.query.clientName,method+"_"+getCmd,"null","Fail"); | 33 | + log.addErrorSummary(req,req.query.clientName,method+"_"+getCmd,"null","Fail"); |
| 34 | log.log(err,'error'); | 34 | log.log(err,'error'); |
| 35 | var response = responseMsg.error(req,getCmd,40300); | 35 | var response = responseMsg.error(req,getCmd,40300); |
| 36 | }else | 36 | }else |
| 37 | { | 37 | { |
| 38 | - log.addSuccessSummary(req.query.clientName,method+"_"+getCmd,"null","Success"); | 38 | + log.addSuccessSummary(req,req.query.clientName,method+"_"+getCmd,"null","Success"); |
| 39 | var objectData = Object.assign(req.query,req.params); | 39 | var objectData = Object.assign(req.query,req.params); |
| 40 | - const result = await connection.requestJsonToD01(objectData,sendCusCmd,method); | ||
| 41 | - log.logDetail.addInput(d01,method+"_"+sendCusCmd,constant.RESPONSE,result,result.response); | 40 | + const result = await connection.requestJsonToD01(req,objectData,sendCusCmd,method); |
| 41 | + log.logDetail.addInput(req,d01,method+"_"+sendCusCmd,constant.RESPONSE,result,result.response); | ||
| 42 | 42 | ||
| 43 | //Get Customer | 43 | //Get Customer |
| 44 | if(typeof result.err === 'undefined'){ | 44 | if(typeof result.err === 'undefined'){ |
| @@ -47,23 +47,23 @@ exports.getMembership = async function (req, res, next) { | @@ -47,23 +47,23 @@ exports.getMembership = async function (req, res, next) { | ||
| 47 | { | 47 | { |
| 48 | if(resultObj.resultData && resultObj.resultData.length>0) | 48 | if(resultObj.resultData && resultObj.resultData.length>0) |
| 49 | { | 49 | { |
| 50 | - log.addSuccessSummary(d01,method+"_"+sendCusCmd,resultObj.resultCode,resultObj.resultDescription); | 50 | + log.addSuccessSummary(req,d01,method+"_"+sendCusCmd,resultObj.resultCode,resultObj.resultDescription); |
| 51 | var cusIdArr = []; | 51 | var cusIdArr = []; |
| 52 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.SUCCESS); | 52 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.SUCCESS); |
| 53 | for(var i = 0; i < resultObj.resultData.length; i++){ | 53 | for(var i = 0; i < resultObj.resultData.length; i++){ |
| 54 | cusIdArr.push(resultObj.resultData[i].customerId) | 54 | cusIdArr.push(resultObj.resultData[i].customerId) |
| 55 | } | 55 | } |
| 56 | objectData = {customerId : cusIdArr} | 56 | objectData = {customerId : cusIdArr} |
| 57 | - const resultMemberCard = await connection.requestJsonToD01(objectData,sendMemCmd,method); | 57 | + const resultMemberCard = await connection.requestJsonToD01(req,objectData,sendMemCmd,method); |
| 58 | 58 | ||
| 59 | //Get MemberCard handler | 59 | //Get MemberCard handler |
| 60 | if(typeof resultMemberCard.err === 'undefined'){ | 60 | if(typeof resultMemberCard.err === 'undefined'){ |
| 61 | if(resultObj.resultCode.startsWith("2")){ | 61 | if(resultObj.resultCode.startsWith("2")){ |
| 62 | if(resultObj.resultData && resultObj.resultData.length>0){ | 62 | if(resultObj.resultData && resultObj.resultData.length>0){ |
| 63 | stats.receiveRestResponse(d01,method,sendMemCmd,constant.SUCCESS); | 63 | stats.receiveRestResponse(d01,method,sendMemCmd,constant.SUCCESS); |
| 64 | - log.logDetail.addInput(d01,method+"_"+sendCusCmd,constant.RESPONSE,resultMemberCard,resultMemberCard.response); | 64 | + log.logDetail.addInput(req,d01,method+"_"+sendCusCmd,constant.RESPONSE,resultMemberCard,resultMemberCard.response); |
| 65 | var resultMemberCardObj = resultMemberCard.response; | 65 | var resultMemberCardObj = resultMemberCard.response; |
| 66 | - log.addSuccessSummary(d01,method+"_"+sendMemCmd,resultMemberCardObj.resultCode,resultMemberCardObj.resultDescription); | 66 | + log.addSuccessSummary(req,d01,method+"_"+sendMemCmd,resultMemberCardObj.resultCode,resultMemberCardObj.resultDescription); |
| 67 | 67 | ||
| 68 | for(var i = 0; i < resultObj.resultData.length; i++){ | 68 | for(var i = 0; i < resultObj.resultData.length; i++){ |
| 69 | for(var j = 0; j < resultMemberCardObj.resultData.length; j++){ | 69 | for(var j = 0; j < resultMemberCardObj.resultData.length; j++){ |
| @@ -76,16 +76,16 @@ exports.getMembership = async function (req, res, next) { | @@ -76,16 +76,16 @@ exports.getMembership = async function (req, res, next) { | ||
| 76 | } else { | 76 | } else { |
| 77 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); | 77 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); |
| 78 | var response = responseMsg.error(req,getCmd,40401); | 78 | var response = responseMsg.error(req,getCmd,40401); |
| 79 | - log.addErrorSummary(d01,method+"_"+sendCusCmd,response.resultCode,response.developerMessage); | 79 | + log.addErrorSummary(req,d01,method+"_"+sendCusCmd,response.resultCode,response.developerMessage); |
| 80 | } | 80 | } |
| 81 | } else if(resultObj.resultCode.startsWith("404")){ | 81 | } else if(resultObj.resultCode.startsWith("404")){ |
| 82 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); | 82 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); |
| 83 | var response = responseMsg.direct(req,getCmd,resultObj); | 83 | var response = responseMsg.direct(req,getCmd,resultObj); |
| 84 | - log.addErrorSummary(d01,method+"_"+sendCusCmd,resultObj.resultCode,resultObj.developerMessage); | 84 | + log.addErrorSummary(req,d01,method+"_"+sendCusCmd,resultObj.resultCode,resultObj.developerMessage); |
| 85 | } else if(resultObj.resultCode.startsWith("5")){ | 85 | } else if(resultObj.resultCode.startsWith("5")){ |
| 86 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.ERROR); | 86 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.ERROR); |
| 87 | var response = responseMsg.direct(req,getCmd,resultObj); | 87 | var response = responseMsg.direct(req,getCmd,resultObj); |
| 88 | - log.addErrorSummary(d01,method+"_"+sendCusCmd,resultObj.resultCode,resultObj.developerMessage); | 88 | + log.addErrorSummary(req,d01,method+"_"+sendCusCmd,resultObj.resultCode,resultObj.developerMessage); |
| 89 | } else { | 89 | } else { |
| 90 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.ERROR); | 90 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.ERROR); |
| 91 | var response = responseMsg.error(req,getCmd,50000); | 91 | var response = responseMsg.error(req,getCmd,50000); |
| @@ -100,16 +100,16 @@ exports.getMembership = async function (req, res, next) { | @@ -100,16 +100,16 @@ exports.getMembership = async function (req, res, next) { | ||
| 100 | } else { | 100 | } else { |
| 101 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); | 101 | stats.receiveRestResponse(d01,method,sendCusCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); |
| 102 | var response = responseMsg.error(req,getCmd,40300); | 102 | var response = responseMsg.error(req,getCmd,40300); |
| 103 | - log.addErrorSummary(d01,method+"_"+sendCusCmd,response.resultCode,response.developerMessage); | 103 | + log.addErrorSummary(req,d01,method+"_"+sendCusCmd,response.resultCode,response.developerMessage); |
| 104 | } | 104 | } |
| 105 | } else if(resultObj.resultCode.startsWith("404")){ | 105 | } else if(resultObj.resultCode.startsWith("404")){ |
| 106 | stats.receiveRestResponse(d01,method,sendMemCmd,constant.ERROR); | 106 | stats.receiveRestResponse(d01,method,sendMemCmd,constant.ERROR); |
| 107 | var response = responseMsg.direct(req,getCmd,resultObj); | 107 | var response = responseMsg.direct(req,getCmd,resultObj); |
| 108 | - log.addErrorSummary(d01,method+"_"+sendMemCmd,resultObj.resultCode,resultObj.developerMessage); | 108 | + log.addErrorSummary(req,d01,method+"_"+sendMemCmd,resultObj.resultCode,resultObj.developerMessage); |
| 109 | } else if(resultObj.resultCode.startsWith("5")){ | 109 | } else if(resultObj.resultCode.startsWith("5")){ |
| 110 | stats.receiveRestResponse(d01,method,sendMemCmd,constant.ERROR); | 110 | stats.receiveRestResponse(d01,method,sendMemCmd,constant.ERROR); |
| 111 | var response = responseMsg.direct(req,getCmd,resultObj); | 111 | var response = responseMsg.direct(req,getCmd,resultObj); |
| 112 | - log.addErrorSummary(d01,method+"_"+sendMemCmd,resultObj.resultCode,resultObj.developerMessage); | 112 | + log.addErrorSummary(req,d01,method+"_"+sendMemCmd,resultObj.resultCode,resultObj.developerMessage); |
| 113 | } else { | 113 | } else { |
| 114 | stats.receiveRestResponse(d01,method,sendMemCmd,constant.ERROR); | 114 | stats.receiveRestResponse(d01,method,sendMemCmd,constant.ERROR); |
| 115 | var response = responseMsg.error(req,getCmd,50000); | 115 | var response = responseMsg.error(req,getCmd,50000); |
| @@ -122,7 +122,7 @@ exports.getMembership = async function (req, res, next) { | @@ -122,7 +122,7 @@ exports.getMembership = async function (req, res, next) { | ||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | // console.log(response); | 124 | // console.log(response); |
| 125 | - log.logDetail.addOutput(req.query.clientName,method+"_"+getCmd,constant.RESPONSE,response,response); | 125 | + log.logDetail.addOutput(req,req.query.clientName,method+"_"+getCmd,constant.RESPONSE,response,response); |
| 126 | res.status(200).json(response); | 126 | res.status(200).json(response); |
| 127 | next(); | 127 | next(); |
| 128 | }; | 128 | }; |
ais-structure/src/modules/membercard/postMembership.ctrl.js
| @@ -26,19 +26,19 @@ exports.postMembership = async function (req, res, next){ | @@ -26,19 +26,19 @@ exports.postMembership = async function (req, res, next){ | ||
| 26 | customerId = req.body.clientName+"@"+req.body.commandId; | 26 | customerId = req.body.clientName+"@"+req.body.commandId; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | - log.startlog(postMethod+"_"+getCmd, req.body.commandId, customerId); | ||
| 30 | - log.logDetail.addInput(req.body.clientName, postMethod+"_"+getCmd, constant.REQUEST, req, req.body); | 29 | + log.startlog(req,postMethod+"_"+getCmd, req.body.commandId, customerId); |
| 30 | + log.logDetail.addInput(req,req.body.clientName, postMethod+"_"+getCmd, constant.REQUEST, req, req.body); | ||
| 31 | 31 | ||
| 32 | var err = validator(req, getCmd); | 32 | var err = validator(req, getCmd); |
| 33 | 33 | ||
| 34 | if(err.length > 0) | 34 | if(err.length > 0) |
| 35 | { | 35 | { |
| 36 | - log.addErrorSummary(req.body.clientName, postMethod+"_"+getCmd, "null", "Fail"); | 36 | + log.addErrorSummary(req,req.body.clientName, postMethod+"_"+getCmd, "null", "Fail"); |
| 37 | // console.log(err); | 37 | // console.log(err); |
| 38 | var response = responseMsg.error(req, getCmd, 40300); | 38 | var response = responseMsg.error(req, getCmd, 40300); |
| 39 | }else | 39 | }else |
| 40 | { | 40 | { |
| 41 | - log.addSuccessSummary(req.body.clientName, postMethod+"_"+getCmd, "null", "Success"); | 41 | + log.addSuccessSummary(req,req.body.clientName, postMethod+"_"+getCmd, "null", "Success"); |
| 42 | 42 | ||
| 43 | var objectData = { | 43 | var objectData = { |
| 44 | cardId : req.body.cardId, | 44 | cardId : req.body.cardId, |
| @@ -47,8 +47,8 @@ exports.postMembership = async function (req, res, next){ | @@ -47,8 +47,8 @@ exports.postMembership = async function (req, res, next){ | ||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | //GET Customer with cardId and cardOwnerIdList | 49 | //GET Customer with cardId and cardOwnerIdList |
| 50 | - const result = await connection.requestJsonToD01(objectData, sendMemberCardCmd, getMethod); | ||
| 51 | - log.logDetail.addInput(d01, getMethod+"_"+sendMemberCardCmd, constant.RESPONSE, result, result.response); | 50 | + const result = await connection.requestJsonToD01(req,objectData, sendMemberCardCmd, getMethod); |
| 51 | + log.logDetail.addInput(req,d01, getMethod+"_"+sendMemberCardCmd, constant.RESPONSE, result, result.response); | ||
| 52 | 52 | ||
| 53 | var objDataGetCustomer = { | 53 | var objDataGetCustomer = { |
| 54 | req : req, | 54 | req : req, |
| @@ -61,13 +61,14 @@ exports.postMembership = async function (req, res, next){ | @@ -61,13 +61,14 @@ exports.postMembership = async function (req, res, next){ | ||
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | var objDataMembership = { | 63 | var objDataMembership = { |
| 64 | + customerId : customerId, | ||
| 64 | POST : { | 65 | POST : { |
| 65 | req : req, | 66 | req : req, |
| 66 | reqMembership : { | 67 | reqMembership : { |
| 67 | cardId : req.body.cardId, | 68 | cardId : req.body.cardId, |
| 68 | cardOwnerIdList : [customerId] | 69 | cardOwnerIdList : [customerId] |
| 69 | }, | 70 | }, |
| 70 | - cmd : sendCustomerCmd, | 71 | + cmd : sendMemberCardCmd, |
| 71 | method : postMethod, | 72 | method : postMethod, |
| 72 | resultData : result.response.resultData | 73 | resultData : result.response.resultData |
| 73 | }, | 74 | }, |
| @@ -79,7 +80,7 @@ exports.postMembership = async function (req, res, next){ | @@ -79,7 +80,7 @@ exports.postMembership = async function (req, res, next){ | ||
| 79 | cardOwnerIdList : customerId | 80 | cardOwnerIdList : customerId |
| 80 | } | 81 | } |
| 81 | }, | 82 | }, |
| 82 | - cmd : sendCustomerCmd, | 83 | + cmd : sendMemberCardCmd, |
| 83 | method : putMethod, | 84 | method : putMethod, |
| 84 | resultData : result.response.resultData | 85 | resultData : result.response.resultData |
| 85 | } | 86 | } |
| @@ -92,49 +93,49 @@ exports.postMembership = async function (req, res, next){ | @@ -92,49 +93,49 @@ exports.postMembership = async function (req, res, next){ | ||
| 92 | if(resultObj.resultData && resultObj.resultData.length>0){ | 93 | if(resultObj.resultData && resultObj.resultData.length>0){ |
| 93 | 94 | ||
| 94 | stats.receiveRestResponse(d01,getMethod,sendMemberCardCmd,constant.SUCCESS); | 95 | stats.receiveRestResponse(d01,getMethod,sendMemberCardCmd,constant.SUCCESS); |
| 95 | - log.addSuccessSummary(d01,getMethod+"_"+sendMemberCardCmd,resultObj.resultCode,resultObj.resultDescription); | 96 | + log.addSuccessSummary(req,d01,getMethod+"_"+sendMemberCardCmd,resultObj.resultCode,resultObj.resultDescription); |
| 96 | 97 | ||
| 97 | var todo = await checkOwnerCard(resultObj.resultData,objectData); | 98 | var todo = await checkOwnerCard(resultObj.resultData,objectData); |
| 98 | // console.log(todo); | 99 | // console.log(todo); |
| 99 | if(todo){ | 100 | if(todo){ |
| 100 | - var getCustomer = await getCustomerD01(objDataGetCustomer); | 101 | + var getCustomer = await getCustomerD01(req, objDataGetCustomer); |
| 101 | var response = await getCustomerHandler(req, getCustomer, resultObj, objDataMembership); | 102 | var response = await getCustomerHandler(req, getCustomer, resultObj, objDataMembership); |
| 102 | } else { | 103 | } else { |
| 103 | stats.receiveRestResponse(d01,getMethod,sendMemberCardCmd,constant.SUCCESS); | 104 | stats.receiveRestResponse(d01,getMethod,sendMemberCardCmd,constant.SUCCESS); |
| 104 | var response = responseMsg.direct(req,getCmd,constant.RESPONSECONN.MESSAGE.EXCEED); | 105 | var response = responseMsg.direct(req,getCmd,constant.RESPONSECONN.MESSAGE.EXCEED); |
| 105 | - log.addSuccessSummary(d01, getMethod+"_"+sendMemberCardCmd, response.resultCode, response.developerMessage); | 106 | + log.addSuccessSummary(req,d01, getMethod+"_"+sendMemberCardCmd, response.resultCode, response.developerMessage); |
| 106 | } | 107 | } |
| 107 | 108 | ||
| 108 | } else { //data not found | 109 | } else { //data not found |
| 109 | 110 | ||
| 110 | stats.receiveRestResponse(d01,getMethod,sendMemberCardCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); | 111 | stats.receiveRestResponse(d01,getMethod,sendMemberCardCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); |
| 111 | - log.addSuccessSummary(d01,getMethod+"_"+sendMemberCardCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.resultCode,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); | 112 | + log.addSuccessSummary(req,d01,getMethod+"_"+sendMemberCardCmd,constant.RESPONSERESULT.DATA_NOT_FOUND.resultCode,constant.RESPONSERESULT.DATA_NOT_FOUND.developerMessage); |
| 112 | 113 | ||
| 113 | //get customer | 114 | //get customer |
| 114 | 115 | ||
| 115 | - var getCustomer = await getCustomerD01(objDataGetCustomer); | 116 | + var getCustomer = await getCustomerD01(req, objDataGetCustomer); |
| 116 | var response = await getCustomerHandler(req, getCustomer, resultObj, objDataMembership); | 117 | var response = await getCustomerHandler(req, getCustomer, resultObj, objDataMembership); |
| 117 | } | 118 | } |
| 118 | } else if(resultObj.resultCode.startsWith("404")){ //data not found | 119 | } else if(resultObj.resultCode.startsWith("404")){ //data not found |
| 119 | //get customer | 120 | //get customer |
| 120 | - var getCustomer = await getCustomerD01(objDataGetCustomer); | 121 | + var getCustomer = await getCustomerD01(req, objDataGetCustomer); |
| 121 | var response = await getCustomerHandler(req, getCustomer, resultObj, objDataMembership); | 122 | var response = await getCustomerHandler(req, getCustomer, resultObj, objDataMembership); |
| 122 | 123 | ||
| 123 | } else if(resultObj.resultCode.startsWith("5")){ | 124 | } else if(resultObj.resultCode.startsWith("5")){ |
| 124 | stats.receiveRestResponse(d01, getMethod, sendMemberCardCmd, constant.ERROR); | 125 | stats.receiveRestResponse(d01, getMethod, sendMemberCardCmd, constant.ERROR); |
| 125 | var response = responseMsg.direct(req, getCmd, resultObj); | 126 | var response = responseMsg.direct(req, getCmd, resultObj); |
| 126 | - log.addErrorSummary(d01, getMethod+"_"+sendMemberCardCmd, resultObj.resultCode, resultObj.developerMessage); | 127 | + log.addErrorSummary(req,d01, getMethod+"_"+sendMemberCardCmd, resultObj.resultCode, resultObj.developerMessage); |
| 127 | } else { | 128 | } else { |
| 128 | stats.receiveRestResponse(d01, getMethod, sendMemberCardCmd, constant.ERROR); | 129 | stats.receiveRestResponse(d01, getMethod, sendMemberCardCmd, constant.ERROR); |
| 129 | var response = responseMsg.error(req, getCmd, 50000); | 130 | var response = responseMsg.error(req, getCmd, 50000); |
| 130 | } | 131 | } |
| 131 | } else { | 132 | } else { |
| 132 | - stats.receiveRestResponse(d01,method,sendCusCmd,constant.ERROR); | 133 | + stats.receiveRestResponse(d01,getMethod,sendCusCmd,constant.ERROR); |
| 133 | var response = responseMsg.error(req,getCmd,50000); | 134 | var response = responseMsg.error(req,getCmd,50000); |
| 134 | } | 135 | } |
| 135 | } | 136 | } |
| 136 | 137 | ||
| 137 | - log.logDetail.addOutput(req.body.clientName, postMethod+"_"+getCmd, constant.RESPONSE, response, response); | 138 | + log.logDetail.addOutput(req,req.body.clientName, postMethod+"_"+getCmd, constant.RESPONSE, response, response); |
| 138 | res.status(200).json(response); | 139 | res.status(200).json(response); |
| 139 | next(); | 140 | next(); |
| 140 | }; | 141 | }; |
| @@ -161,7 +162,7 @@ function validator(req, api) | @@ -161,7 +162,7 @@ function validator(req, api) | ||
| 161 | return err; | 162 | return err; |
| 162 | } | 163 | } |
| 163 | 164 | ||
| 164 | -async function getCustomerD01(data){ | 165 | +async function getCustomerD01(req, data){ |
| 165 | 166 | ||
| 166 | var responseData = { | 167 | var responseData = { |
| 167 | isErr : false, | 168 | isErr : false, |
| @@ -169,7 +170,7 @@ async function getCustomerD01(data){ | @@ -169,7 +170,7 @@ async function getCustomerD01(data){ | ||
| 169 | isDirect : false | 170 | isDirect : false |
| 170 | }; | 171 | }; |
| 171 | 172 | ||
| 172 | - const resultCustomer = await connection.requestJsonToD01(data.reqCustomer, data.cmd, data.method); | 173 | + const resultCustomer = await connection.requestJsonToD01(req, data.reqCustomer, data.cmd, data.method); |
| 173 | var resultObj = resultCustomer.response | 174 | var resultObj = resultCustomer.response |
| 174 | 175 | ||
| 175 | if(typeof resultCustomer.err === 'undefined'){ | 176 | if(typeof resultCustomer.err === 'undefined'){ |
| @@ -195,7 +196,7 @@ async function getCustomerD01(data){ | @@ -195,7 +196,7 @@ async function getCustomerD01(data){ | ||
| 195 | return responseData; | 196 | return responseData; |
| 196 | } | 197 | } |
| 197 | 198 | ||
| 198 | -async function postMemberCardD01(data){ | 199 | +async function postMemberCardD01(req, data){ |
| 199 | 200 | ||
| 200 | var responseData = { | 201 | var responseData = { |
| 201 | isErr : false, | 202 | isErr : false, |
| @@ -203,7 +204,9 @@ async function postMemberCardD01(data){ | @@ -203,7 +204,9 @@ async function postMemberCardD01(data){ | ||
| 203 | isDirect : false | 204 | isDirect : false |
| 204 | }; | 205 | }; |
| 205 | 206 | ||
| 206 | - const resultCustomer = await connection.requestJsonToD01(data.reqMembership, data.cmd, data.method); | 207 | + // console.log(data) |
| 208 | + | ||
| 209 | + const resultCustomer = await connection.requestJsonToD01(req,data.reqMembership, data.cmd, data.method); | ||
| 207 | var resultObj = resultCustomer.response | 210 | var resultObj = resultCustomer.response |
| 208 | 211 | ||
| 209 | if(typeof resultCustomer.err === 'undefined'){ | 212 | if(typeof resultCustomer.err === 'undefined'){ |
| @@ -232,23 +235,58 @@ async function getCustomerHandler(req, getCustomer, getMemberCard, objDataMember | @@ -232,23 +235,58 @@ async function getCustomerHandler(req, getCustomer, getMemberCard, objDataMember | ||
| 232 | if(!getCustomer.isDataNotFound){ | 235 | if(!getCustomer.isDataNotFound){ |
| 233 | //post membercard | 236 | //post membercard |
| 234 | stats.receiveRestResponse(d01, getMethod, sendCustomerCmd, constant.SUCCESS); | 237 | stats.receiveRestResponse(d01, getMethod, sendCustomerCmd, constant.SUCCESS); |
| 235 | - log.addSuccessSummary(d01, getMethod+"_"+sendCustomerCmd, getCustomer.response.resultCode, getCustomer.response.resultDescription); | ||
| 236 | - | 238 | + log.addSuccessSummary(req,d01, getMethod+"_"+sendCustomerCmd, getCustomer.response.resultCode, getCustomer.response.resultDescription); |
| 237 | 239 | ||
| 238 | //check post or put | 240 | //check post or put |
| 239 | - | ||
| 240 | - var postMemberCard = await postMemberCardD01(objDataMembership.POST); | ||
| 241 | - var response = await postMemberCardHandler(req, postMemberCard) | ||
| 242 | 241 | ||
| 242 | + function getResultTodo(req, getMemberCard, objDataMembership){ | ||
| 243 | + | ||
| 244 | + var result = { | ||
| 245 | + doPost : true, | ||
| 246 | + doNothing : false | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + for(var i = 0 ; i < getMemberCard.resultData.length ; i++){ | ||
| 250 | + if(req.body.cardId === getMemberCard.resultData[i].cardId){ | ||
| 251 | + if(getMemberCard.resultData[i].cardOwnerIdList.includes(objDataMembership.customerId)){ | ||
| 252 | + result.doNothing = true; | ||
| 253 | + break; | ||
| 254 | + } else { | ||
| 255 | + result.doPost = false; | ||
| 256 | + break; | ||
| 257 | + } | ||
| 258 | + } else if(i == getMemberCard.resultData.length-1){ | ||
| 259 | + result.doPost = true; | ||
| 260 | + break; | ||
| 261 | + } | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + return result; | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + var getResult = await getResultTodo(req, getMemberCard, objDataMembership); | ||
| 268 | + | ||
| 269 | + if(getResult.doNothing){ | ||
| 270 | + var response = responseMsg.success(req,getCmd) | ||
| 271 | + } else { | ||
| 272 | + if(getResult.doPost){ | ||
| 273 | + var postMemberCard = await postMemberCardD01(req, objDataMembership.POST); | ||
| 274 | + var response = await postMemberCardHandler(req, postMemberCard) | ||
| 275 | + } else { | ||
| 276 | + var putMemberCard = await postMemberCardD01(req, objDataMembership.PUT); | ||
| 277 | + var response = await postMemberCardHandler(req, putMemberCard) | ||
| 278 | + } | ||
| 279 | + } | ||
| 280 | + | ||
| 243 | } else { | 281 | } else { |
| 244 | stats.receiveRestResponse(d01, getMethod, sendCustomerCmd, constant.RESPONSERESULT.DATA_NOT_FOUND.resultDescription); | 282 | stats.receiveRestResponse(d01, getMethod, sendCustomerCmd, constant.RESPONSERESULT.DATA_NOT_FOUND.resultDescription); |
| 245 | var response = responseMsg.error(req, getCmd, 40401); | 283 | var response = responseMsg.error(req, getCmd, 40401); |
| 246 | - log.addErrorSummary(d01, getMethod+"_"+sendCustomerCmd, response.resultCode, response.resultDescription); | 284 | + log.addErrorSummary(req,d01, getMethod+"_"+sendCustomerCmd, response.resultCode, response.resultDescription); |
| 247 | } | 285 | } |
| 248 | } else if(getCustomer.isDirect){ | 286 | } else if(getCustomer.isDirect){ |
| 249 | stats.receiveRestResponse(d01, getMethod, sendCustomerCmd, constant.ERROR); | 287 | stats.receiveRestResponse(d01, getMethod, sendCustomerCmd, constant.ERROR); |
| 250 | var response = responseMsg.direct(req, getCmd, getCustomer.response); | 288 | var response = responseMsg.direct(req, getCmd, getCustomer.response); |
| 251 | - log.addErrorSummary(d01, getMethod+"_"+sendCustomerCmd, getCustomer.response.resultCode, getCustomer.response.resultDescription); | 289 | + log.addErrorSummary(req,d01, getMethod+"_"+sendCustomerCmd, getCustomer.response.resultCode, getCustomer.response.resultDescription); |
| 252 | } else { | 290 | } else { |
| 253 | stats.receiveRestResponse(d01, getMethod, sendCustomerCmd, constant.ERROR); | 291 | stats.receiveRestResponse(d01, getMethod, sendCustomerCmd, constant.ERROR); |
| 254 | var response = responseMsg.error(req, getCmd, 50000); | 292 | var response = responseMsg.error(req, getCmd, 50000); |
| @@ -263,11 +301,11 @@ async function postMemberCardHandler(req, memberCard){ | @@ -263,11 +301,11 @@ async function postMemberCardHandler(req, memberCard){ | ||
| 263 | if(!memberCard.isErr){ | 301 | if(!memberCard.isErr){ |
| 264 | stats.receiveRestResponse(d01, postMethod, sendMemberCardCmd, constant.SUCCESS); | 302 | stats.receiveRestResponse(d01, postMethod, sendMemberCardCmd, constant.SUCCESS); |
| 265 | var response = responseMsg.direct(req, getCmd, memberCard.response); | 303 | var response = responseMsg.direct(req, getCmd, memberCard.response); |
| 266 | - log.addSuccessSummary(d01, postMethod+"_"+sendMemberCardCmd, response.resultCode, response.developerMessage); | ||
| 267 | - } else if(getCustomer.isDirect){ | 304 | + log.addSuccessSummary(req,d01, postMethod+"_"+sendMemberCardCmd, response.resultCode, response.developerMessage); |
| 305 | + } else if(memberCard.isDirect){ | ||
| 268 | stats.receiveRestResponse(d01, postMethod, sendMemberCardCmd, constant.ERROR); | 306 | stats.receiveRestResponse(d01, postMethod, sendMemberCardCmd, constant.ERROR); |
| 269 | var response = responseMsg.direct(req, getCmd, memberCard.response); | 307 | var response = responseMsg.direct(req, getCmd, memberCard.response); |
| 270 | - log.addErrorSummary(d01, postMethod+"_"+sendMemberCardCmd, memberCard.response.resultCode, memberCard.response.developerMessage); | 308 | + log.addErrorSummary(req,d01, postMethod+"_"+sendMemberCardCmd, memberCard.response.resultCode, memberCard.response.developerMessage); |
| 271 | } else { | 309 | } else { |
| 272 | stats.receiveRestResponse(d01, postMethod, sendMemberCardCmd, constant.ERROR); | 310 | stats.receiveRestResponse(d01, postMethod, sendMemberCardCmd, constant.ERROR); |
| 273 | var response = responseMsg.error(req, getCmd, 50000); | 311 | var response = responseMsg.error(req, getCmd, 50000); |
ais-structure/src/modules/vizcard/vizCard.ctrl.js
| @@ -43,7 +43,7 @@ exports.vizcard = async function (req, res, next) { | @@ -43,7 +43,7 @@ exports.vizcard = async function (req, res, next) { | ||
| 43 | moblieNo : req.query.moblieNo | 43 | moblieNo : req.query.moblieNo |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | - const result = await connection.requestSoapToSACF(objectData,sendCmd,constant.METHOD.POST); | 46 | + const result = await connection.requestSoapToSACF(req,objectData,sendCmd,constant.METHOD.POST); |
| 47 | // console.log(result.err) | 47 | // console.log(result.err) |
| 48 | 48 | ||
| 49 | if(typeof result.err === 'undefined'){ | 49 | if(typeof result.err === 'undefined'){ |
| @@ -70,14 +70,12 @@ exports.vizcard = async function (req, res, next) { | @@ -70,14 +70,12 @@ exports.vizcard = async function (req, res, next) { | ||
| 70 | } else { | 70 | } else { |
| 71 | stats.receiveSACFResponse(sacf,sendCmd,"Error"); | 71 | stats.receiveSACFResponse(sacf,sendCmd,"Error"); |
| 72 | response = responseMsg.error(req,getCmd,50000); | 72 | response = responseMsg.error(req,getCmd,50000); |
| 73 | - // log.addErrorSummary(sacf,method+"_"+sendCmd,response.resultCode,response.developerMessage); | ||
| 74 | var resultSet = {rawDataJson : ""} | 73 | var resultSet = {rawDataJson : ""} |
| 75 | } | 74 | } |
| 76 | 75 | ||
| 77 | log.logDetail.addInput(req,sacf,method+"_"+sendCmd,constant.RESPONSE,result,resultSet.rawDataJson); | 76 | log.logDetail.addInput(req,sacf,method+"_"+sendCmd,constant.RESPONSE,result,resultSet.rawDataJson); |
| 78 | } | 77 | } |
| 79 | 78 | ||
| 80 | - // console.log(response); | ||
| 81 | log.logDetail.addOutput(req,sacf,method+"_"+getCmd,constant.RESPONSE,response,response); | 79 | log.logDetail.addOutput(req,sacf,method+"_"+getCmd,constant.RESPONSE,response,response); |
| 82 | res.status(200).json(response); | 80 | res.status(200).json(response); |
| 83 | next(); | 81 | next(); |