Commit 84646faa12edcc293f47ffb3a0e2478f69aeab6b
1 parent
c39cf9da
Exists in
master
and in
1 other branch
update connection
Showing
2 changed files
with
38 additions
and
36 deletions
Show diff stats
ais-structure/src/modules/customer/customer.ctrl.js
... | ... | @@ -2,11 +2,15 @@ var stats = require('../helper/stats.js'); |
2 | 2 | var validatorHelper = require('../helper/validator.js'); |
3 | 3 | var connection = require('../helper/connection.js'); |
4 | 4 | var responseMsg = require('../helper/responseMsg.js'); |
5 | +var log = require('../helper/log.js'); | |
5 | 6 | |
6 | 7 | exports.customer = async function (req, res, next) { |
7 | 8 | var getCmd = "Customer"; |
8 | 9 | var sendCmd = "Customer"; |
9 | 10 | |
11 | + log.startlog(getCmd,req); | |
12 | + log.logDetail.addInput("Client",getCmd,"Request",req); | |
13 | + | |
10 | 14 | var err = validator(req,getCmd); |
11 | 15 | |
12 | 16 | if(err.length > 0) |
... | ... | @@ -37,6 +41,9 @@ exports.customer = async function (req, res, next) { |
37 | 41 | if(!response) |
38 | 42 | var response = responseMsg.error(req,getCmd,50000); |
39 | 43 | |
44 | + log.logDetail.addOutput("Client",getCmd,"Response",response,response); | |
45 | + log.logDetail.write(); | |
46 | + // log.logSummary(); | |
40 | 47 | res.status(200).json(response); |
41 | 48 | }; |
42 | 49 | ... | ... |
ais-structure/src/modules/helper/connection.js
... | ... | @@ -88,19 +88,14 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
88 | 88 | params.url = genUrl[0]; |
89 | 89 | delete params.body; |
90 | 90 | |
91 | - var result = await asyncRequest(params,cmd,cfg.service.D01.Name); | |
91 | + var result = await asyncRequest(params,cmd,service.Name); | |
92 | 92 | |
93 | 93 | // console.log(result); |
94 | 94 | if(result.response) |
95 | 95 | { |
96 | 96 | var data = JSON.parse(result.response.body); |
97 | 97 | result.response = data; |
98 | - | |
99 | - if(!data.resultCode) | |
100 | - result.err = "Miss resultCode"; | |
101 | - | |
102 | - if(!data.resultDescription) | |
103 | - result.err = "Miss resultDescription"; | |
98 | + | |
104 | 99 | } |
105 | 100 | } |
106 | 101 | |
... | ... | @@ -109,23 +104,24 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
109 | 104 | { |
110 | 105 | params.body = JSON.stringify(params.body); |
111 | 106 | |
112 | - var resultRes = await asyncRequest(params,cmd,cfg.service.D01.Name); | |
107 | + var resultRes = await asyncRequest(params,cmd,service.Name); | |
113 | 108 | |
114 | 109 | result.response = JSON.parse(resultRes.body); |
115 | - // resultRes.body = JSON.parse(resultRes.body); | |
116 | - | |
117 | - // if(resultRes.body.resultCode === "20000"){ | |
118 | - // result.response.resultCode = resultRes.body.resultCode; | |
119 | - // result.response.developerMessage = "Success"; | |
120 | - // } else { | |
121 | - // result.response.resultCode = "50000"; | |
122 | - // result.response.developerMessage = "System error"; | |
123 | - // } | |
110 | + | |
124 | 111 | } |
125 | 112 | |
113 | + if(!result.response.resultCode) | |
114 | + result.err = "Miss resultCode"; | |
115 | + | |
116 | + if(!result.response.resultDescription) | |
117 | + result.err = "Miss resultDescription"; | |
118 | + | |
126 | 119 | // console.log(result); |
127 | 120 | // delete result.body; |
128 | 121 | |
122 | + if(result.err) | |
123 | + stats.reciveResponse(service.Name,cmd,"Error"); | |
124 | + | |
129 | 125 | return result; |
130 | 126 | |
131 | 127 | |
... | ... | @@ -190,24 +186,23 @@ function getUrl(params,limit) |
190 | 186 | }; |
191 | 187 | |
192 | 188 | |
193 | - params.body = {}; | |
194 | - params.body.a = "aaa"; | |
195 | - params.body.b = "bbb"; | |
196 | - params.body.papa = []; | |
197 | - params.body.papa.push("1"); | |
198 | - params.body.papa.push("2"); | |
199 | - params.body.commandId = []; | |
200 | - params.body.commandId.push("1"); | |
201 | - params.body.commandId.push("2"); | |
202 | - params.body.commandId.push("3"); | |
203 | - params.body.commandId.push("4"); | |
204 | - params.body.commandId.push("5"); | |
205 | - params.body.commandId.push("6"); | |
206 | - params.body.commandId.push("7"); | |
207 | - params.body.commandId.push("8"); | |
208 | - params.body.c = "ccc"; | |
209 | - | |
210 | - params.body.fields = "a,b,c,d"; | |
189 | + // params.body = {}; | |
190 | + // params.body.a = "aaa"; | |
191 | + // params.body.b = "bbb"; | |
192 | + // params.body.papa = []; | |
193 | + // params.body.papa.push("1"); | |
194 | + // params.body.papa.push("2"); | |
195 | + // params.body.commandId = []; | |
196 | + // params.body.commandId.push("1"); | |
197 | + // params.body.commandId.push("2"); | |
198 | + // params.body.commandId.push("3"); | |
199 | + // params.body.commandId.push("4"); | |
200 | + // params.body.commandId.push("5"); | |
201 | + // params.body.commandId.push("6"); | |
202 | + // params.body.commandId.push("7"); | |
203 | + // params.body.commandId.push("8"); | |
204 | + // params.body.c = "ccc"; | |
205 | + // params.body.fields = "a,b,c,d"; | |
211 | 206 | // console.log(params.body); |
212 | 207 | if(params.body) |
213 | 208 | { |
... | ... | @@ -280,7 +275,7 @@ function getUrl(params,limit) |
280 | 275 | // console.log(filter); |
281 | 276 | // console.log(fields); |
282 | 277 | |
283 | - console.log(returnData); | |
278 | + // console.log(returnData); | |
284 | 279 | |
285 | 280 | return returnData; |
286 | 281 | } | ... | ... |