Commit 91f86b1ab3cf756e7e60f4b87f50fcadf46b0255
Exists in
master
and in
1 other branch
Merge branch 'master' of http://git.sourcecode.co.th/nattaponw/spw
Showing
5 changed files
with
40 additions
and
18 deletions
Show diff stats
ais-structure/src/config/express.js
| @@ -18,6 +18,7 @@ var passport = require('passport'); | @@ -18,6 +18,7 @@ var passport = require('passport'); | ||
| 18 | var memCache = require('memory-cache'); | 18 | var memCache = require('memory-cache'); |
| 19 | var jwtDecode = require('jwt-decode'); | 19 | var jwtDecode = require('jwt-decode'); |
| 20 | var uuid = require('uuid'); | 20 | var uuid = require('uuid'); |
| 21 | +var log = require('../modules/helper/log.js'); | ||
| 21 | 22 | ||
| 22 | var expireTimeDef = 30 * 60 * 1000; //minutes * seconds * 1000 ==> ms | 23 | var expireTimeDef = 30 * 60 * 1000; //minutes * seconds * 1000 ==> ms |
| 23 | memCache.put('expires-ms-def', expireTimeDef); | 24 | memCache.put('expires-ms-def', expireTimeDef); |
| @@ -266,6 +267,13 @@ module.exports = function () { | @@ -266,6 +267,13 @@ module.exports = function () { | ||
| 266 | // // Future Action. | 267 | // // Future Action. |
| 267 | // }); | 268 | // }); |
| 268 | /* ------------- [END NOT MATCH ROUTE - 404 ] ------------ */ | 269 | /* ------------- [END NOT MATCH ROUTE - 404 ] ------------ */ |
| 270 | + | ||
| 271 | + app.use( function( req, res, next ) { | ||
| 272 | + // console.log("end"); | ||
| 273 | + // console.log(req.res.resBody); | ||
| 274 | + log.logSummary(req.res.resBody); | ||
| 275 | +} ); | ||
| 276 | + | ||
| 269 | return app; | 277 | return app; |
| 270 | }; | 278 | }; |
| 271 | /* ------------- [END IMPLEMENT] ------------ */ | 279 | /* ------------- [END IMPLEMENT] ------------ */ |
| 272 | \ No newline at end of file | 280 | \ No newline at end of file |
ais-structure/src/modules/customer/customer.ctrl.js
| @@ -42,9 +42,10 @@ exports.customer = async function (req, res, next) { | @@ -42,9 +42,10 @@ exports.customer = async function (req, res, next) { | ||
| 42 | var response = responseMsg.error(req,getCmd,50000); | 42 | var response = responseMsg.error(req,getCmd,50000); |
| 43 | 43 | ||
| 44 | log.logDetail.addOutput("Client",getCmd,"Response",response,response); | 44 | log.logDetail.addOutput("Client",getCmd,"Response",response,response); |
| 45 | - log.logDetail.write(); | ||
| 46 | - // log.logSummary(); | 45 | + // log.logDetail.write(); |
| 46 | + log.logSummary(); | ||
| 47 | res.status(200).json(response); | 47 | res.status(200).json(response); |
| 48 | + next(); | ||
| 48 | }; | 49 | }; |
| 49 | 50 | ||
| 50 | 51 |
ais-structure/src/modules/helper/connection.js
| @@ -11,9 +11,10 @@ var connection = []; | @@ -11,9 +11,10 @@ var connection = []; | ||
| 11 | connection.requestSoapToSACF = async function (soap,cmd,myMethod) { | 11 | connection.requestSoapToSACF = async function (soap,cmd,myMethod) { |
| 12 | 12 | ||
| 13 | var params = { | 13 | var params = { |
| 14 | - url : cfg.service.SACF[myMethod+"_"+cmd+"_URL"], | ||
| 15 | - body : messageSOAP.objectToSOAP(soap,cmd), | ||
| 16 | - method : myMethod | 14 | + url : cfg.service.SACF[myMethod+"_"+cmd+"_URL"], |
| 15 | + body : messageSOAP.objectToSOAP(soap,cmd), | ||
| 16 | + method : myMethod, | ||
| 17 | + timeout : cfg.service.SACF[myMethod+"_"+cmd+"_Timeout"] | ||
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | log.logDetail.addOutput(cfg.service.SACF.Name,cmd,"Request",params.body,soap); | 20 | log.logDetail.addOutput(cfg.service.SACF.Name,cmd,"Request",params.body,soap); |
| @@ -26,9 +27,10 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | @@ -26,9 +27,10 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | ||
| 26 | var service = cfg.service.D01; | 27 | var service = cfg.service.D01; |
| 27 | // JSON.stringify(json) | 28 | // JSON.stringify(json) |
| 28 | var params = { | 29 | var params = { |
| 29 | - url : service[myMethod+"_"+cmd+"_URL"], | ||
| 30 | - body : obj, | ||
| 31 | - method : myMethod | 30 | + url : service[myMethod+"_"+cmd+"_URL"], |
| 31 | + body : obj, | ||
| 32 | + method : myMethod, | ||
| 33 | + timeout : service[myMethod+"_"+cmd+"_Timeout"] | ||
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | var result = {}; | 36 | var result = {}; |
| @@ -114,17 +116,25 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | @@ -114,17 +116,25 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | ||
| 114 | 116 | ||
| 115 | } | 117 | } |
| 116 | 118 | ||
| 117 | - if(!result.response.resultCode) | ||
| 118 | - result.err = "Miss resultCode"; | ||
| 119 | - | ||
| 120 | - if(!result.response.resultDescription) | ||
| 121 | - result.err = "Miss resultDescription"; | 119 | + // console.log(result); |
| 120 | + | ||
| 121 | + if(result.response) | ||
| 122 | + { | ||
| 123 | + if(!result.response.resultCode) | ||
| 124 | + result.err = "Miss resultCode"; | ||
| 122 | 125 | ||
| 123 | - // console.log(result); | ||
| 124 | - // delete result.body; | 126 | + if(!result.response.resultDescription) |
| 127 | + result.err = "Miss resultDescription"; | ||
| 128 | + } | ||
| 125 | 129 | ||
| 126 | if(result.err) | 130 | if(result.err) |
| 127 | - stats.reciveResponse(service.Name,cmd,"Error"); | 131 | + { |
| 132 | + result.response = {}; | ||
| 133 | + result.response.resultCode = "50000"; | ||
| 134 | + | ||
| 135 | + // stats.reciveResponse(service.Name,cmd,"Error"); | ||
| 136 | + } | ||
| 137 | + | ||
| 128 | 138 | ||
| 129 | return result; | 139 | return result; |
| 130 | 140 | ||
| @@ -158,11 +168,12 @@ function asyncRequest (params = {},cmd,node) { | @@ -158,11 +168,12 @@ function asyncRequest (params = {},cmd,node) { | ||
| 158 | return new Promise((resolve, reject) => { | 168 | return new Promise((resolve, reject) => { |
| 159 | request(params, function (error, response, body) { | 169 | request(params, function (error, response, body) { |
| 160 | 170 | ||
| 161 | - stats.sendRequest(node,cmd); | 171 | + |
| 162 | 172 | ||
| 163 | if (error) { | 173 | if (error) { |
| 164 | 174 | ||
| 165 | - stats.reciveResponse(node,cmd,"Error"); | 175 | + // console.log("End : "+new Date().toISOString()); |
| 176 | + console.log(error.code); | ||
| 166 | resolve({ | 177 | resolve({ |
| 167 | 'body' : body, | 178 | 'body' : body, |
| 168 | 'err' : error | 179 | 'err' : error |
ais-structure/src/modules/vizcard/vizCard.ctrl.js
| @@ -66,6 +66,7 @@ exports.vizcard = async function (req, res, next) { | @@ -66,6 +66,7 @@ exports.vizcard = async function (req, res, next) { | ||
| 66 | log.logDetail.write(); | 66 | log.logDetail.write(); |
| 67 | log.logSummary(response); | 67 | log.logSummary(response); |
| 68 | res.status(200).json(response); | 68 | res.status(200).json(response); |
| 69 | + next(); | ||
| 69 | } | 70 | } |
| 70 | }; | 71 | }; |
| 71 | 72 |
ais-structure/src/modules/vizcard/vizCard.route.js
| 1 | module.exports = function (app) { | 1 | module.exports = function (app) { |
| 2 | var vizcardCtrl = app.modules.vizcard.vizCardCtrl; | 2 | var vizcardCtrl = app.modules.vizcard.vizCardCtrl; |
| 3 | var postVizcardCtrl = app.modules.vizcard.postVizCardCtrl; | 3 | var postVizcardCtrl = app.modules.vizcard.postVizCardCtrl; |
| 4 | + var log = require('../helper/log.js'); | ||
| 4 | 5 | ||
| 5 | 6 | ||
| 6 | 7 |