From 90f9d22438de7b1acb0c7122668b2bdc0b899eaa Mon Sep 17 00:00:00 2001 From: Sumate Kongpui Date: Thu, 23 Aug 2018 12:02:19 +0700 Subject: [PATCH] update unknow req --- ais-structure/src/config/express.js | 2 +- ais-structure/src/modules/helper/constants.js | 10 +++++----- ais-structure/src/modules/helper/responseMsg.js | 11 +++++++---- ais-structure/src/modules/helper/stats.js | 10 ++++++++++ ais-structure/src/modules/vizcard/vizCard.ctrl.js | 9 ++++++--- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/ais-structure/src/config/express.js b/ais-structure/src/config/express.js index 9272ced..4144b8b 100644 --- a/ais-structure/src/config/express.js +++ b/ais-structure/src/config/express.js @@ -277,7 +277,7 @@ module.exports = function () { log.logSummary(JSON.parse(req.res.resBody)); }else { - res.status(200).json(responseMsg.error(req,cmd,40400)); + res.status(200).json(responseMsg.unknow(req)); } next(); } ); diff --git a/ais-structure/src/modules/helper/constants.js b/ais-structure/src/modules/helper/constants.js index 8fd11be..b41c329 100644 --- a/ais-structure/src/modules/helper/constants.js +++ b/ais-structure/src/modules/helper/constants.js @@ -37,23 +37,23 @@ module.exports = Object.freeze({ RESPONSERESULT:{ SUCCESS:{ resultCode : '20000', - resultDescription : 'Success' + developerMessage : 'Success' }, MISSING_INVALID:{ resultCode : '40300', - resultDescription : 'Missing or invalid parameter' + developerMessage : 'Missing or invalid parameter' }, DATA_NOT_FOUND:{ resultCode : '40401', - resultDescription : 'Data Not Found' + developerMessage : 'Data Not Found' }, DATA_EXIST:{ resultCode : '40301', - resultDescription : 'Data Exist' + developerMessage : 'Data Exist' }, ERROR:{ resultCode : '50000', - resultDescription : 'System error' + developerMessage : 'System error' }, UNKNOW:{ resultCode : '40400', diff --git a/ais-structure/src/modules/helper/responseMsg.js b/ais-structure/src/modules/helper/responseMsg.js index 54d341d..8bf1859 100644 --- a/ais-structure/src/modules/helper/responseMsg.js +++ b/ais-structure/src/modules/helper/responseMsg.js @@ -20,9 +20,6 @@ responseMsg.error = function (req,cmd,code){ case 50000: response = constants.RESPONSERESULT.ERROR; break; - case 40400: - response = constants.RESPONSERESULT.UNKNOW; - break; default: response = constants.RESPONSERESULT.ERROR; } @@ -66,6 +63,12 @@ responseMsg.direct = function (req,cmd,result,data) return response; }; - +responseMsg.unknow = function (req) +{ + var response = constants.RESPONSERESULT.UNKNOW; + stats.receiveUnknow(response.developerMessage); + stats.sendUnknow(response.developerMessage); + return response; +}; module.exports = responseMsg; \ No newline at end of file diff --git a/ais-structure/src/modules/helper/stats.js b/ais-structure/src/modules/helper/stats.js index 612f413..d6b387b 100644 --- a/ais-structure/src/modules/helper/stats.js +++ b/ais-structure/src/modules/helper/stats.js @@ -1,6 +1,7 @@ var env = process.env.NODE_ENV || 'development'; var cfg = require('../../config/config.js').get(env); var log = require('../helper/log.js'); +var constants = require('../helper/constants.js'); var nodeName = cfg.app_name; var stat = []; @@ -57,7 +58,16 @@ stat.receiveBadResponse = function (fromNode,cmd,result){ writeStats(nodeName+" Receive "+fromNode+" Bad "+cmd+" Response "); }; +//unknow +// CMF Receive Unknown URL Request +// CMF Send Unknown URL +stat.receiveUnknow = function(message){ + writeStats(nodeName+" Receive "+message+" "+constants.REQUEST); +}; +stat.sendUnknow = function(message){ + writeStats(nodeName+" Send "+message); +}; function writeStats(string) { log.log(string); diff --git a/ais-structure/src/modules/vizcard/vizCard.ctrl.js b/ais-structure/src/modules/vizcard/vizCard.ctrl.js index f8b3fe1..def6bb5 100644 --- a/ais-structure/src/modules/vizcard/vizCard.ctrl.js +++ b/ais-structure/src/modules/vizcard/vizCard.ctrl.js @@ -81,10 +81,13 @@ exports.vizcard = async function (req, res, next) { stats.receiveSACFResponse(sacf,sendCmd,"Error"); } - log.logDetail.addOutput(sacf,getCmd,constant.RESPONSE,response,response); - res.status(200).json(response); - next(); + } + + // console.log(response); + log.logDetail.addOutput(sacf,getCmd,constant.RESPONSE,response,response); + res.status(200).json(response); + next(); }; -- libgit2 0.21.2