From b77690fa1eb4866acae99effb3a4a62d840d0604 Mon Sep 17 00:00:00 2001 From: Nattapon Wongpaet Date: Thu, 30 Aug 2018 11:49:18 +0700 Subject: [PATCH] update post customermembership --- ais-structure/src/modules/customer/customer.ctrl.js | 2 +- ais-structure/src/modules/customer/postCustomer.ctrl.js | 2 +- ais-structure/src/modules/helper/connection.js | 28 ++++++++++++++++++++++++---- ais-structure/src/modules/membercard/getMembership.ctrl.js | 10 +++++----- ais-structure/src/modules/membercard/postMembership.ctrl.js | 7 +++---- ais-structure/src/modules/vizcard/vizCard.ctrl.js | 2 +- 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/ais-structure/src/modules/customer/customer.ctrl.js b/ais-structure/src/modules/customer/customer.ctrl.js index 632eea1..d4980d8 100644 --- a/ais-structure/src/modules/customer/customer.ctrl.js +++ b/ais-structure/src/modules/customer/customer.ctrl.js @@ -24,7 +24,7 @@ exports.customer = async function (req, res, next) { log.startlog(req,method+"_"+getCmd,req.query.commandId,customerId); log.logDetail.addInput(req,req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); - var err = validator(req,getCmd); + var err = await validator(req,getCmd); if(err.length > 0) { diff --git a/ais-structure/src/modules/customer/postCustomer.ctrl.js b/ais-structure/src/modules/customer/postCustomer.ctrl.js index 5040113..423e8ec 100644 --- a/ais-structure/src/modules/customer/postCustomer.ctrl.js +++ b/ais-structure/src/modules/customer/postCustomer.ctrl.js @@ -18,7 +18,7 @@ exports.postCustomer = async function (req, res, next){ log.startlog(req,method+"_"+getCmd,req.body.commandId,customerId); log.logDetail.addInput(req,req.body.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); - var err = validator(req,getCmd); + var err = await validator(req,getCmd); if(err.length > 0) { diff --git a/ais-structure/src/modules/helper/connection.js b/ais-structure/src/modules/helper/connection.js index a527d9e..b5f9b65 100644 --- a/ais-structure/src/modules/helper/connection.js +++ b/ais-structure/src/modules/helper/connection.js @@ -106,7 +106,13 @@ connection.requestJsonToD01 = async function (req,obj,cmd,myMethod,filter) { if(params.method == constants.METHOD.GET) { - var genUrl = getUrl(params,service["searchRecordLimit"]); + if(filter && filter == "or"){ + var genUrl = getOrUrl(params); + } + else{ + var genUrl = getUrl(params,service["searchRecordLimit"]); + } + if(genUrl.length > 1) { console.log("multi Send"); @@ -137,7 +143,7 @@ connection.requestJsonToD01 = async function (req,obj,cmd,myMethod,filter) { dataRes[i].data = data.resultData; // console.log(dataRes[i].data); - + } } @@ -325,8 +331,6 @@ function getUrlFilter(url,filter){ // var myUrl = url+"?filter=("+filter.base+")"; returnData.push(myUrl); - for(var i=0;i 0) { @@ -59,11 +59,11 @@ exports.getMembership = async function (req, res, next) { //Get MemberCard handler if(typeof resultMemberCard.err === 'undefined'){ - if(resultObj.resultCode.startsWith("2")){ - if(resultObj.resultData && resultObj.resultData.length>0){ + var resultMemberCardObj = resultMemberCard.response; + if(resultMemberCardObj.resultCode.startsWith("2")){ + if(resultMemberCardObj.resultData && resultMemberCardObj.resultData.length>0){ stats.receiveRestResponse(d01,method,sendMemCmd,constant.SUCCESS); - log.logDetail.addInput(req,d01,method+"_"+sendCusCmd,constant.RESPONSE,resultMemberCard,resultMemberCard.response); - var resultMemberCardObj = resultMemberCard.response; + log.logDetail.addInput(req,d01,method+"_"+sendMemCmd,constant.RESPONSE,resultMemberCard,resultMemberCard.response); log.addSuccessSummary(req,d01,method+"_"+sendMemCmd,resultMemberCardObj.resultCode,resultMemberCardObj.resultDescription); for(var i = 0; i < resultObj.resultData.length; i++){ diff --git a/ais-structure/src/modules/membercard/postMembership.ctrl.js b/ais-structure/src/modules/membercard/postMembership.ctrl.js index 8017060..70395a3 100644 --- a/ais-structure/src/modules/membercard/postMembership.ctrl.js +++ b/ais-structure/src/modules/membercard/postMembership.ctrl.js @@ -29,7 +29,7 @@ exports.postMembership = async function (req, res, next){ log.startlog(req,postMethod+"_"+getCmd, req.body.commandId, customerId); log.logDetail.addInput(req,req.body.clientName, postMethod+"_"+getCmd, constant.REQUEST, req, req.body); - var err = validator(req, getCmd); + var err = await validator(req, getCmd); if(err.length > 0) { @@ -41,12 +41,11 @@ exports.postMembership = async function (req, res, next){ var objectData = { cardId : req.body.cardId, - cardOwnerIdList : customerId - // _flag : "or" + cardOwnerIdList : customerId, } //GET Customer with cardId and cardOwnerIdList - const result = await connection.requestJsonToD01(req,objectData, sendMemberCardCmd, getMethod); + const result = await connection.requestJsonToD01(req,objectData, sendMemberCardCmd, getMethod, "or"); log.logDetail.addInput(req,d01, getMethod+"_"+sendMemberCardCmd, constant.RESPONSE, result, result.response); var objDataGetCustomer = { diff --git a/ais-structure/src/modules/vizcard/vizCard.ctrl.js b/ais-structure/src/modules/vizcard/vizCard.ctrl.js index 92d74ce..0b4b91d 100644 --- a/ais-structure/src/modules/vizcard/vizCard.ctrl.js +++ b/ais-structure/src/modules/vizcard/vizCard.ctrl.js @@ -20,7 +20,7 @@ exports.vizcard = async function (req, res, next) { log.startlog(req,method+"_"+getCmd,req.query.commandId,customerId); log.logDetail.addInput(req,req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); - var err = validator(req,getCmd); + var err = await validator(req,getCmd); if(err.length > 0) { -- libgit2 0.21.2