Commit d923574ef52283a889d3a8fb1f52b3dab3337ddb
Exists in
master
and in
1 other branch
Merge branch 'master' of http://git.sourcecode.co.th/nattaponw/spw
Showing
5 changed files
with
29 additions
and
13 deletions
Show diff stats
ais-structure/src/config/express.js
| @@ -277,7 +277,7 @@ module.exports = function () { | @@ -277,7 +277,7 @@ module.exports = function () { | ||
| 277 | log.logSummary(JSON.parse(req.res.resBody)); | 277 | log.logSummary(JSON.parse(req.res.resBody)); |
| 278 | }else | 278 | }else |
| 279 | { | 279 | { |
| 280 | - res.status(200).json(responseMsg.error(req,cmd,40400)); | 280 | + res.status(200).json(responseMsg.unknow(req)); |
| 281 | } | 281 | } |
| 282 | next(); | 282 | next(); |
| 283 | } ); | 283 | } ); |
ais-structure/src/modules/helper/constants.js
| @@ -37,23 +37,23 @@ module.exports = Object.freeze({ | @@ -37,23 +37,23 @@ module.exports = Object.freeze({ | ||
| 37 | RESPONSERESULT:{ | 37 | RESPONSERESULT:{ |
| 38 | SUCCESS:{ | 38 | SUCCESS:{ |
| 39 | resultCode : '20000', | 39 | resultCode : '20000', |
| 40 | - resultDescription : 'Success' | 40 | + developerMessage : 'Success' |
| 41 | }, | 41 | }, |
| 42 | MISSING_INVALID:{ | 42 | MISSING_INVALID:{ |
| 43 | resultCode : '40300', | 43 | resultCode : '40300', |
| 44 | - resultDescription : 'Missing or invalid parameter' | 44 | + developerMessage : 'Missing or invalid parameter' |
| 45 | }, | 45 | }, |
| 46 | DATA_NOT_FOUND:{ | 46 | DATA_NOT_FOUND:{ |
| 47 | resultCode : '40401', | 47 | resultCode : '40401', |
| 48 | - resultDescription : 'Data Not Found' | 48 | + developerMessage : 'Data Not Found' |
| 49 | }, | 49 | }, |
| 50 | DATA_EXIST:{ | 50 | DATA_EXIST:{ |
| 51 | resultCode : '40301', | 51 | resultCode : '40301', |
| 52 | - resultDescription : 'Data Exist' | 52 | + developerMessage : 'Data Exist' |
| 53 | }, | 53 | }, |
| 54 | ERROR:{ | 54 | ERROR:{ |
| 55 | resultCode : '50000', | 55 | resultCode : '50000', |
| 56 | - resultDescription : 'System error' | 56 | + developerMessage : 'System error' |
| 57 | }, | 57 | }, |
| 58 | UNKNOW:{ | 58 | UNKNOW:{ |
| 59 | resultCode : '40400', | 59 | resultCode : '40400', |
ais-structure/src/modules/helper/responseMsg.js
| @@ -20,9 +20,6 @@ responseMsg.error = function (req,cmd,code){ | @@ -20,9 +20,6 @@ responseMsg.error = function (req,cmd,code){ | ||
| 20 | case 50000: | 20 | case 50000: |
| 21 | response = constants.RESPONSERESULT.ERROR; | 21 | response = constants.RESPONSERESULT.ERROR; |
| 22 | break; | 22 | break; |
| 23 | - case 40400: | ||
| 24 | - response = constants.RESPONSERESULT.UNKNOW; | ||
| 25 | - break; | ||
| 26 | default: | 23 | default: |
| 27 | response = constants.RESPONSERESULT.ERROR; | 24 | response = constants.RESPONSERESULT.ERROR; |
| 28 | } | 25 | } |
| @@ -66,6 +63,12 @@ responseMsg.direct = function (req,cmd,result,data) | @@ -66,6 +63,12 @@ responseMsg.direct = function (req,cmd,result,data) | ||
| 66 | return response; | 63 | return response; |
| 67 | }; | 64 | }; |
| 68 | 65 | ||
| 69 | - | 66 | +responseMsg.unknow = function (req) |
| 67 | +{ | ||
| 68 | + var response = constants.RESPONSERESULT.UNKNOW; | ||
| 69 | + stats.receiveUnknow(response.developerMessage); | ||
| 70 | + stats.sendUnknow(response.developerMessage); | ||
| 71 | + return response; | ||
| 72 | +}; | ||
| 70 | 73 | ||
| 71 | module.exports = responseMsg; | 74 | module.exports = responseMsg; |
| 72 | \ No newline at end of file | 75 | \ No newline at end of file |
ais-structure/src/modules/helper/stats.js
| 1 | var env = process.env.NODE_ENV || 'development'; | 1 | var env = process.env.NODE_ENV || 'development'; |
| 2 | var cfg = require('../../config/config.js').get(env); | 2 | var cfg = require('../../config/config.js').get(env); |
| 3 | var log = require('../helper/log.js'); | 3 | var log = require('../helper/log.js'); |
| 4 | +var constants = require('../helper/constants.js'); | ||
| 4 | 5 | ||
| 5 | var nodeName = cfg.app_name; | 6 | var nodeName = cfg.app_name; |
| 6 | var stat = []; | 7 | var stat = []; |
| @@ -57,7 +58,16 @@ stat.receiveBadResponse = function (fromNode,cmd,result){ | @@ -57,7 +58,16 @@ stat.receiveBadResponse = function (fromNode,cmd,result){ | ||
| 57 | writeStats(nodeName+" Receive "+fromNode+" Bad "+cmd+" Response "); | 58 | writeStats(nodeName+" Receive "+fromNode+" Bad "+cmd+" Response "); |
| 58 | }; | 59 | }; |
| 59 | 60 | ||
| 61 | +//unknow | ||
| 62 | +// CMF Receive Unknown URL Request | ||
| 63 | +// CMF Send Unknown URL | ||
| 64 | +stat.receiveUnknow = function(message){ | ||
| 65 | + writeStats(nodeName+" Receive "+message+" "+constants.REQUEST); | ||
| 66 | +}; | ||
| 60 | 67 | ||
| 68 | +stat.sendUnknow = function(message){ | ||
| 69 | + writeStats(nodeName+" Send "+message); | ||
| 70 | +}; | ||
| 61 | 71 | ||
| 62 | function writeStats(string) { | 72 | function writeStats(string) { |
| 63 | log.log(string); | 73 | log.log(string); |
ais-structure/src/modules/vizcard/vizCard.ctrl.js
| @@ -82,10 +82,13 @@ exports.vizcard = async function (req, res, next) { | @@ -82,10 +82,13 @@ exports.vizcard = async function (req, res, next) { | ||
| 82 | stats.receiveSACFResponse(sacf,sendCmd,"Error"); | 82 | stats.receiveSACFResponse(sacf,sendCmd,"Error"); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | - log.logDetail.addOutput(sacf,getCmd,constant.RESPONSE,response,response); | ||
| 86 | - res.status(200).json(response); | ||
| 87 | - next(); | 85 | + |
| 88 | } | 86 | } |
| 87 | + | ||
| 88 | + // console.log(response); | ||
| 89 | + log.logDetail.addOutput(sacf,getCmd,constant.RESPONSE,response,response); | ||
| 90 | + res.status(200).json(response); | ||
| 91 | + next(); | ||
| 89 | }; | 92 | }; |
| 90 | 93 | ||
| 91 | 94 |