Commit b253306b897ad8ac030943818b115814ba364545
1 parent
479b9d98
Exists in
master
and in
1 other branch
update log get customer
Showing
3 changed files
with
53 additions
and
30 deletions
Show diff stats
ais-structure/src/modules/customer/customer.ctrl.js
... | ... | @@ -10,22 +10,32 @@ exports.customer = async function (req, res, next) { |
10 | 10 | var sendCmd = "Customer"; |
11 | 11 | var sacf = "SACF"; |
12 | 12 | var d01 = "D01" |
13 | - | |
14 | - log.startlog(getCmd,req); | |
15 | - log.logDetail.addInput(sacf,getCmd,constant.REQUEST,req,req.body); | |
13 | + var method = constant.METHOD.GET | |
16 | 14 | |
17 | 15 | var err = validator(req,getCmd); |
18 | - | |
16 | + | |
17 | + if(req.params.customerId){ | |
18 | + var customerId = req.params.customerId | |
19 | + } else if(req.params.userData && req.params.userType){ | |
20 | + var customerId = req.params.userData+"@"+req.params.userType | |
21 | + } else { | |
22 | + var customerId = req.query.clientName+"@"+req.query.commandId; | |
23 | + } | |
24 | + | |
25 | + log.startlog(method+"_"+getCmd,req.query.commandId,customerId); | |
26 | + log.logDetail.addInput(req.query.clientName,getCmd,constant.REQUEST,req,req.body); | |
27 | + | |
19 | 28 | if(err.length > 0) |
20 | 29 | { |
30 | + log.addErrorSummary(req.query.clientName,method+"_"+getCmd,"null","Fail"); | |
21 | 31 | log.log(err,'error'); |
22 | 32 | var response = responseMsg.error(req,getCmd,40300); |
23 | 33 | // res.status(200).json(response); |
24 | 34 | }else |
25 | 35 | { |
36 | + log.addSuccessSummary(req.query.clientName,method+"_"+getCmd,"null","Success"); | |
26 | 37 | var objectData = req.query; |
27 | - | |
28 | - const result = await connection.requestJsonToD01(objectData,sendCmd,constant.METHOD.GET); | |
38 | + const result = await connection.requestJsonToD01(objectData,sendCmd,method); | |
29 | 39 | // console.log(Object.keys(result)) |
30 | 40 | log.logDetail.addInput(d01,sendCmd,constant.RESPONSE,result,result.response); |
31 | 41 | if(typeof result.err === 'undefined'){ |
... | ... | @@ -35,28 +45,29 @@ exports.customer = async function (req, res, next) { |
35 | 45 | { |
36 | 46 | if(resultObj.resultData && resultObj.resultData.length>0) |
37 | 47 | { |
38 | - stats.receiveRestResponse(d01,constant.METHOD.GET,sendCmd,"Success"); | |
48 | + stats.receiveRestResponse(d01,method,sendCmd,"Success"); | |
39 | 49 | var response = responseMsg.success(req,getCmd,resultObj); |
40 | - log.addSuccessSummary(d01,sendCmd,response); | |
50 | + log.addSuccessSummary(d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
41 | 51 | }else |
42 | 52 | { |
43 | - stats.receiveRestResponse(d01,constant.METHOD.GET,sendCmd,"Data Not Found"); | |
53 | + stats.receiveRestResponse(d01,method,sendCmd,"Data Not Found"); | |
44 | 54 | var response = responseMsg.error(req,getCmd,40300); |
45 | - log.addErrorSummary(d01,sendCmd,response); | |
55 | + log.addErrorSummary(d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
46 | 56 | } |
47 | 57 | } |
48 | 58 | } else { |
59 | + stats.receiveRestResponse(d01,method,sendCmd,"Error"); | |
49 | 60 | response = responseMsg.direct(req,getCmd,result.response); |
50 | - log.addErrorSummary(d01,sendCmd,response); | |
61 | + log.addErrorSummary(d01,method+"_"+sendCmd,response.resultCode,response.developerMessage); | |
51 | 62 | } |
52 | 63 | } |
53 | 64 | |
54 | 65 | if(!response){ |
55 | 66 | var response = responseMsg.error(req,getCmd,50000); |
56 | - stats.receiveResponse(sacf,sendCmd,"Error"); | |
67 | + stats.receiveRestResponse(d01,method,sendCmd,"Error"); | |
57 | 68 | } |
58 | 69 | |
59 | - log.logDetail.addOutput(sacf,getCmd,constant.RESPONSE,response,response); | |
70 | + log.logDetail.addOutput(req.query.clientName,getCmd,constant.RESPONSE,response,response); | |
60 | 71 | res.status(200).json(response); |
61 | 72 | next(); |
62 | 73 | }; |
... | ... | @@ -65,17 +76,18 @@ exports.customer = async function (req, res, next) { |
65 | 76 | function validator(req,api) |
66 | 77 | { |
67 | 78 | var list = []; |
68 | - // list.push([true,"queryStr","commandId","String"]); | |
79 | + list.push([true,"queryStr","commandId","String"]); | |
80 | + list.push([true,"queryStr","clientName","String"]); | |
69 | 81 | var err = validatorHelper(req,list,api) |
70 | 82 | |
71 | - if((typeof req.query["userType"] !== 'undefined') && (typeof req.query["userData"] === 'undefined')) | |
72 | - { | |
73 | - var errDes = { | |
74 | - Param : "userData", | |
75 | - Reason : "Missing" | |
76 | - } | |
77 | - err.push(errDes); | |
78 | - } | |
83 | + // if((typeof req.query["userType"] !== 'undefined') && (typeof req.query["userData"] === 'undefined')) | |
84 | + // { | |
85 | + // var errDes = { | |
86 | + // Param : "userData", | |
87 | + // Reason : "Missing" | |
88 | + // } | |
89 | + // err.push(errDes); | |
90 | + // } | |
79 | 91 | |
80 | 92 | if(err.length > 0) |
81 | 93 | stats.receiveBadRequest(req.method,api); | ... | ... |
ais-structure/src/modules/helper/log.js
... | ... | @@ -59,7 +59,7 @@ logger.startlog = function (cmdData,session,identity) |
59 | 59 | logger.addSuccessSummary = function (nodeData,cmdData,resultCode,developerMessage) |
60 | 60 | { |
61 | 61 | summary = { |
62 | - node : nodeData, | |
62 | + node : undefinedToNull(nodeData), | |
63 | 63 | cmd : cmdData, |
64 | 64 | resultCode : resultCode, |
65 | 65 | resultDesc : developerMessage, |
... | ... | @@ -72,7 +72,7 @@ logger.addSuccessSummary = function (nodeData,cmdData,resultCode,developerMessag |
72 | 72 | logger.addErrorSummary = function (nodeData,cmdData,resultCode,developerMessage) |
73 | 73 | { |
74 | 74 | summary = { |
75 | - node : nodeData, | |
75 | + node : undefinedToNull(nodeData), | |
76 | 76 | cmd : cmdData, |
77 | 77 | resultCode : resultCode, |
78 | 78 | resultDesc : developerMessage, |
... | ... | @@ -119,7 +119,7 @@ var addlogDetailData = function(inputType,node,cmd,type,rawData,data){ |
119 | 119 | } |
120 | 120 | |
121 | 121 | detail.input = { |
122 | - node : node, | |
122 | + node : undefinedToNull(node), | |
123 | 123 | cmd : cmd, |
124 | 124 | type : type, |
125 | 125 | rawData : raw, |
... | ... | @@ -131,7 +131,7 @@ var addlogDetailData = function(inputType,node,cmd,type,rawData,data){ |
131 | 131 | else if(inputType == 'output') |
132 | 132 | { |
133 | 133 | detail.output = { |
134 | - node : node, | |
134 | + node : undefinedToNull(node), | |
135 | 135 | cmd : cmd, |
136 | 136 | type : type, |
137 | 137 | rawData : rawData, |
... | ... | @@ -160,6 +160,16 @@ var logDetailData = { |
160 | 160 | |
161 | 161 | logger.logDetail = logDetailData; |
162 | 162 | |
163 | +var undefinedToNull = function(data){ | |
164 | + if(!data){ | |
165 | + data = 'null'; | |
166 | + } else { | |
167 | + data = data; | |
168 | + } | |
169 | + | |
170 | + return data; | |
171 | +} | |
172 | + | |
163 | 173 | |
164 | 174 | |
165 | 175 | ... | ... |
ais-structure/src/modules/vizcard/vizCard.ctrl.js
... | ... | @@ -14,8 +14,10 @@ exports.vizcard = async function (req, res, next) { |
14 | 14 | var sacf = "SACF"; |
15 | 15 | var method = constant.METHOD.GET; |
16 | 16 | |
17 | - log.startlog(method+"_"+getCmd,req.query.commandId,null); | |
18 | - log.logDetail.addInput(sacf,method+"_"+getCmd,constant.REQUEST,req,req.body); | |
17 | + var customerId = req.query.clientName+"@"+req.query.commandId; | |
18 | + | |
19 | + log.startlog(method+"_"+getCmd,req.query.commandId,customerId); | |
20 | + log.logDetail.addInput(req.query.clientName,method+"_"+getCmd,constant.REQUEST,req,req.body); | |
19 | 21 | |
20 | 22 | var err = validator(req,getCmd); |
21 | 23 | |
... | ... | @@ -40,8 +42,7 @@ exports.vizcard = async function (req, res, next) { |
40 | 42 | moblieNo : req.query.moblieNo |
41 | 43 | }; |
42 | 44 | |
43 | - const result = await connection.requestSoapToSACF(objectData,sendCmd,constant.METHOD.POST | |
44 | - ); | |
45 | + const result = await connection.requestSoapToSACF(objectData,sendCmd,constant.METHOD.POST); | |
45 | 46 | // console.log(result.err) |
46 | 47 | |
47 | 48 | if(typeof result.err === 'undefined'){ | ... | ... |