Commit 3cac963611f8269cb51506aa526e116e2780af82
1 parent
a1d815b9
Exists in
master
and in
1 other branch
update post customer
Showing
4 changed files
with
21 additions
and
12 deletions
Show diff stats
ais-structure/src/modules/customer/customer.route.js
... | ... | @@ -2,7 +2,7 @@ module.exports = function (app) { |
2 | 2 | var customerCtrl = app.modules.customer.customerCtrl; |
3 | 3 | var postCustomerCtrl = app.modules.customer.postCustomerCtrl; |
4 | 4 | |
5 | - app.get('/cmf/v2/customer/customerId.json', | |
5 | + app.get('/cmf/v2/customer.json', | |
6 | 6 | customerCtrl.customer |
7 | 7 | ); |
8 | 8 | ... | ... |
ais-structure/src/modules/customer/postCustomer.ctrl.js
... | ... | @@ -32,8 +32,7 @@ exports.postCustomer = async function (req, res, next){ |
32 | 32 | |
33 | 33 | if(typeof result.err === 'undefined'){ |
34 | 34 | // console.log(result.response.body); |
35 | - var resultObj = JSON.parse(result.response.body); | |
36 | - | |
35 | + var resultObj = result.response; | |
37 | 36 | if(resultObj.resultCode.startsWith("40")) |
38 | 37 | { |
39 | 38 | if(resultObj.resultCode != "40401") | ... | ... |
ais-structure/src/modules/helper/connection.js
... | ... | @@ -26,6 +26,10 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
26 | 26 | method : myMethod |
27 | 27 | } |
28 | 28 | |
29 | + var result = {}; | |
30 | + result.response = {}; | |
31 | + result.response.resultData = []; | |
32 | + | |
29 | 33 | if(params.method == "GET") |
30 | 34 | { |
31 | 35 | var genUrl = getUrl(params); |
... | ... | @@ -63,10 +67,6 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
63 | 67 | |
64 | 68 | } |
65 | 69 | |
66 | - var result = {}; | |
67 | - result.response = {}; | |
68 | - result.response.resultData = []; | |
69 | - | |
70 | 70 | for (var i = 0; i < multiSend.length; i++) { |
71 | 71 | |
72 | 72 | result.response.resultData = result.response.resultData.concat(dataRes[i].data); |
... | ... | @@ -107,11 +107,22 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
107 | 107 | }else if(params.method == "POST") |
108 | 108 | { |
109 | 109 | params.body = JSON.stringify(params.body); |
110 | + | |
111 | + var resultRes = await asyncRequest(params,cmd,cfg.service.D01.Name); | |
112 | + resultRes.body = JSON.parse(resultRes.body) | |
113 | + | |
114 | + if(resultRes.body.resultCode === "20000"){ | |
115 | + result.response.resultCode = resultRes.body.resultCode; | |
116 | + result.response.developerMessage = "Success"; | |
117 | + } else { | |
118 | + result.response.resultCode = "50000"; | |
119 | + result.response.developerMessage = "System error"; | |
120 | + } | |
110 | 121 | } |
111 | 122 | |
112 | - | |
113 | - delete result.body; | |
114 | - // console.log(result); | |
123 | + // console.log(result); | |
124 | + // delete result.body; | |
125 | + | |
115 | 126 | return result; |
116 | 127 | |
117 | 128 | |
... | ... | @@ -140,7 +151,6 @@ async function parallelRequest(multiParams,cmd,node) |
140 | 151 | |
141 | 152 | function asyncRequest (params = {},cmd,node) { |
142 | 153 | |
143 | - | |
144 | 154 | // console.log("Start : "+new Date().toISOString()); |
145 | 155 | return new Promise((resolve, reject) => { |
146 | 156 | request(params, function (error, response, body) { | ... | ... |
ais-structure/src/modules/helper/responseMsg.js