Commit 9d8ce483edb6e90f2dad326f4feadea1470510cc
1 parent
1f123eb1
Exists in
master
and in
1 other branch
update url put
Showing
3 changed files
with
32 additions
and
9 deletions
Show diff stats
ais-structure/src/modules/customer/customer.ctrl.js
@@ -13,13 +13,13 @@ exports.customer = async function (req, res, next) { | @@ -13,13 +13,13 @@ exports.customer = async function (req, res, next) { | ||
13 | console.log(req.params); | 13 | console.log(req.params); |
14 | 14 | ||
15 | if(req.params.customerId){ | 15 | if(req.params.customerId){ |
16 | - var customerId = req.params.customerId | 16 | + var customerId = req.params.customerId; |
17 | } else if(req.params.userData && req.params.userType){ | 17 | } else if(req.params.userData && req.params.userType){ |
18 | - var customerId = req.params.userData+"@"+req.params.userType | 18 | + var customerId = req.params.userData+"@"+req.params.userType; |
19 | } else if(req.query.clientName && req.query.commandId){ | 19 | } else if(req.query.clientName && req.query.commandId){ |
20 | var customerId = req.query.clientName+"@"+req.query.commandId; | 20 | var customerId = req.query.clientName+"@"+req.query.commandId; |
21 | } | 21 | } |
22 | -; | 22 | + |
23 | 23 | ||
24 | log.startlog(req,method+"_"+getCmd,req.query.commandId,customerId); | 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); | 25 | log.logDetail.addInput(req,req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); |
ais-structure/src/modules/helper/connection.js
@@ -59,7 +59,7 @@ connection.requestSoapToSACF = async function (req,soap,cmd,myMethod) { | @@ -59,7 +59,7 @@ connection.requestSoapToSACF = async function (req,soap,cmd,myMethod) { | ||
59 | } | 59 | } |
60 | }; | 60 | }; |
61 | 61 | ||
62 | -connection.requestJsonToD01 = async function (req,obj,cmd,myMethod) { | 62 | +connection.requestJsonToD01 = async function (req,obj,cmd,myMethod,filter) { |
63 | try { | 63 | try { |
64 | 64 | ||
65 | log.log("Connect to D01") | 65 | log.log("Connect to D01") |
@@ -185,12 +185,12 @@ connection.requestJsonToD01 = async function (req,obj,cmd,myMethod) { | @@ -185,12 +185,12 @@ connection.requestJsonToD01 = async function (req,obj,cmd,myMethod) { | ||
185 | } | 185 | } |
186 | } else if(params.method == constants.METHOD.PUT) { | 186 | } else if(params.method == constants.METHOD.PUT) { |
187 | 187 | ||
188 | - | 188 | + params.url = getUrlFilter(params.url,filter); |
189 | 189 | ||
190 | params.body = JSON.stringify(params.body); | 190 | params.body = JSON.stringify(params.body); |
191 | 191 | ||
192 | var resultRes = await asyncRequest(params,objectData,funStats); | 192 | var resultRes = await asyncRequest(params,objectData,funStats); |
193 | - | 193 | + |
194 | if(resultRes.response){ | 194 | if(resultRes.response){ |
195 | result.response = JSON.parse(resultRes.body); | 195 | result.response = JSON.parse(resultRes.body); |
196 | } else { | 196 | } else { |
@@ -214,6 +214,7 @@ connection.requestJsonToD01 = async function (req,obj,cmd,myMethod) { | @@ -214,6 +214,7 @@ connection.requestJsonToD01 = async function (req,obj,cmd,myMethod) { | ||
214 | } | 214 | } |
215 | catch(err) { | 215 | catch(err) { |
216 | log.log(err); | 216 | log.log(err); |
217 | + console.log(err); | ||
217 | 218 | ||
218 | var result = { | 219 | var result = { |
219 | response : constants.RESPONSECONN.MESSAGE.ERROR | 220 | response : constants.RESPONSECONN.MESSAGE.ERROR |
@@ -296,6 +297,25 @@ function asyncRequest (params = {},objectData,funStat) { | @@ -296,6 +297,25 @@ function asyncRequest (params = {},objectData,funStat) { | ||
296 | }); | 297 | }); |
297 | }; | 298 | }; |
298 | 299 | ||
300 | +function getUrlFilter(url,filter){ | ||
301 | + var returnData = []; | ||
302 | + var myfilter = "" | ||
303 | + | ||
304 | + for(var i in filter){ | ||
305 | + myfilter += myfilter+"("+i+"="+filter[i]+")" | ||
306 | + } | ||
307 | + | ||
308 | + var myUrl = url+"?filter="+myfilter | ||
309 | + | ||
310 | + // var myUrl = url+"?filter=("+filter.base+")"; | ||
311 | + | ||
312 | + returnData.push(myUrl); | ||
313 | + for(var i=0;i<returnData.length;i++) | ||
314 | + log.log("URL "+[i+1]+" : "+returnData[i]); | ||
315 | + | ||
316 | + return myUrl; | ||
317 | +} | ||
318 | + | ||
299 | function getUrl(params,limit) | 319 | function getUrl(params,limit) |
300 | { | 320 | { |
301 | var returnData = []; | 321 | var returnData = []; |
ais-structure/src/modules/membercard/postMembership.ctrl.js
@@ -82,7 +82,10 @@ exports.postMembership = async function (req, res, next){ | @@ -82,7 +82,10 @@ exports.postMembership = async function (req, res, next){ | ||
82 | }, | 82 | }, |
83 | cmd : sendMemberCardCmd, | 83 | cmd : sendMemberCardCmd, |
84 | method : putMethod, | 84 | method : putMethod, |
85 | - resultData : result.response.resultData | 85 | + resultData : result.response.resultData, |
86 | + filter : { | ||
87 | + cardId : req.body.cardId | ||
88 | + } | ||
86 | } | 89 | } |
87 | 90 | ||
88 | } | 91 | } |
@@ -130,7 +133,7 @@ exports.postMembership = async function (req, res, next){ | @@ -130,7 +133,7 @@ exports.postMembership = async function (req, res, next){ | ||
130 | var response = responseMsg.error(req, getCmd, 50000); | 133 | var response = responseMsg.error(req, getCmd, 50000); |
131 | } | 134 | } |
132 | } else { | 135 | } else { |
133 | - stats.receiveRestResponse(d01,getMethod,sendCusCmd,constant.ERROR); | 136 | + stats.receiveRestResponse(d01,getMethod,sendMemberCardCmd,constant.ERROR); |
134 | var response = responseMsg.error(req,getCmd,50000); | 137 | var response = responseMsg.error(req,getCmd,50000); |
135 | } | 138 | } |
136 | } | 139 | } |
@@ -206,7 +209,7 @@ async function postMemberCardD01(req, data){ | @@ -206,7 +209,7 @@ async function postMemberCardD01(req, data){ | ||
206 | 209 | ||
207 | // console.log(data) | 210 | // console.log(data) |
208 | 211 | ||
209 | - const resultCustomer = await connection.requestJsonToD01(req,data.reqMembership, data.cmd, data.method); | 212 | + const resultCustomer = await connection.requestJsonToD01(req,data.reqMembership, data.cmd, data.method, data.filter); |
210 | var resultObj = resultCustomer.response | 213 | var resultObj = resultCustomer.response |
211 | 214 | ||
212 | if(typeof resultCustomer.err === 'undefined'){ | 215 | if(typeof resultCustomer.err === 'undefined'){ |