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,7 +2,7 @@ module.exports = function (app) { | ||
2 | var customerCtrl = app.modules.customer.customerCtrl; | 2 | var customerCtrl = app.modules.customer.customerCtrl; |
3 | var postCustomerCtrl = app.modules.customer.postCustomerCtrl; | 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 | customerCtrl.customer | 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,8 +32,7 @@ exports.postCustomer = async function (req, res, next){ | ||
32 | 32 | ||
33 | if(typeof result.err === 'undefined'){ | 33 | if(typeof result.err === 'undefined'){ |
34 | // console.log(result.response.body); | 34 | // console.log(result.response.body); |
35 | - var resultObj = JSON.parse(result.response.body); | ||
36 | - | 35 | + var resultObj = result.response; |
37 | if(resultObj.resultCode.startsWith("40")) | 36 | if(resultObj.resultCode.startsWith("40")) |
38 | { | 37 | { |
39 | if(resultObj.resultCode != "40401") | 38 | if(resultObj.resultCode != "40401") |
ais-structure/src/modules/helper/connection.js
@@ -26,6 +26,10 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | @@ -26,6 +26,10 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | ||
26 | method : myMethod | 26 | method : myMethod |
27 | } | 27 | } |
28 | 28 | ||
29 | + var result = {}; | ||
30 | + result.response = {}; | ||
31 | + result.response.resultData = []; | ||
32 | + | ||
29 | if(params.method == "GET") | 33 | if(params.method == "GET") |
30 | { | 34 | { |
31 | var genUrl = getUrl(params); | 35 | var genUrl = getUrl(params); |
@@ -63,10 +67,6 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | @@ -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 | for (var i = 0; i < multiSend.length; i++) { | 70 | for (var i = 0; i < multiSend.length; i++) { |
71 | 71 | ||
72 | result.response.resultData = result.response.resultData.concat(dataRes[i].data); | 72 | result.response.resultData = result.response.resultData.concat(dataRes[i].data); |
@@ -107,11 +107,22 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | @@ -107,11 +107,22 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | ||
107 | }else if(params.method == "POST") | 107 | }else if(params.method == "POST") |
108 | { | 108 | { |
109 | params.body = JSON.stringify(params.body); | 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 | return result; | 126 | return result; |
116 | 127 | ||
117 | 128 | ||
@@ -140,7 +151,6 @@ async function parallelRequest(multiParams,cmd,node) | @@ -140,7 +151,6 @@ async function parallelRequest(multiParams,cmd,node) | ||
140 | 151 | ||
141 | function asyncRequest (params = {},cmd,node) { | 152 | function asyncRequest (params = {},cmd,node) { |
142 | 153 | ||
143 | - | ||
144 | // console.log("Start : "+new Date().toISOString()); | 154 | // console.log("Start : "+new Date().toISOString()); |
145 | return new Promise((resolve, reject) => { | 155 | return new Promise((resolve, reject) => { |
146 | request(params, function (error, response, body) { | 156 | request(params, function (error, response, body) { |
ais-structure/src/modules/helper/responseMsg.js
@@ -43,7 +43,7 @@ responseMsg.direct = function (req,cmd,result,data) | @@ -43,7 +43,7 @@ responseMsg.direct = function (req,cmd,result,data) | ||
43 | { | 43 | { |
44 | var response = { | 44 | var response = { |
45 | resultCode : result.resultCode, | 45 | resultCode : result.resultCode, |
46 | - developerMessage : result.resultDescription | 46 | + developerMessage : result.developerMessage |
47 | }; | 47 | }; |
48 | 48 | ||
49 | 49 |