From aa4160da56ab6f13cc2625fe0c32aca37f12385e Mon Sep 17 00:00:00 2001 From: Mohamad Ihsan Date: Mon, 31 Oct 2022 06:22:18 +0700 Subject: [PATCH] add validation card number prod or not with see the first number is 1 --- .../loadbalance/loadbalance.controller.js | 74 ++++++++++++ .../reservebalance.controller.js | 111 ++++++++++++++++++ 2 files changed, 185 insertions(+) diff --git a/application/modules/loadbalance/loadbalance.controller.js b/application/modules/loadbalance/loadbalance.controller.js index b54372b..a8bbc89 100644 --- a/application/modules/loadbalance/loadbalance.controller.js +++ b/application/modules/loadbalance/loadbalance.controller.js @@ -81,6 +81,43 @@ const loadingBalanceRequest = async (req, res) => { return res.status(200).json(result); } + // log debug + winston.logger.debug( + `${uniqueCode} checking production card number or not...` + ); + + if (process.env.SERVER_FOR == "production") { + if (card_number.substring(0, 1) != "1") { + result = { + code: "400", + message: "It's not production card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } else { + if (card_number.substring(0, 1) == "1") { + result = { + code: "400", + message: "It's production card number. Please use the development card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } + // time let now = moment().format("YYYY-MM-DD HH:mm:ss"); let year = moment().format("Y"); @@ -480,6 +517,43 @@ const loadingBalance = async (req, res) => { return res.status(200).json(result); } + // log debug + winston.logger.debug( + `${uniqueCode} checking production card number or not...` + ); + + if (process.env.SERVER_FOR == "production") { + if (card_number.substring(0, 1) != "1") { + result = { + code: "400", + message: "It's not production card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } else { + if (card_number.substring(0, 1) == "1") { + result = { + code: "400", + message: "It's production card number. Please use the development card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } + // time let now = moment().format("YYYY-MM-DD HH:mm:ss"); let today = moment().format("YYYY-MM-DD"); diff --git a/application/modules/reservebalance/reservebalance.controller.js b/application/modules/reservebalance/reservebalance.controller.js index 14e84bb..4a75d55 100644 --- a/application/modules/reservebalance/reservebalance.controller.js +++ b/application/modules/reservebalance/reservebalance.controller.js @@ -100,6 +100,43 @@ const checkReservation = async (req, res) => { return res.status(200).json(result); } + // log debug + winston.logger.debug( + `${uniqueCode} checking production card number or not...` + ); + + if (process.env.SERVER_FOR == "production") { + if (card_number.substring(0, 1) != "1") { + result = { + code: "400", + message: "It's not production card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } else { + if (card_number.substring(0, 1) == "1") { + result = { + code: "400", + message: "It's production card number. Please use the development card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } + // log debug winston.logger.debug( `${uniqueCode} checking reservation with pending status and in progress status...` @@ -182,6 +219,43 @@ const reservationValidate = async (req, res) => { return res.status(200).json(result); } + // log debug + winston.logger.debug( + `${uniqueCode} checking production card number or not...` + ); + + if (process.env.SERVER_FOR == "production") { + if (card_number.substring(0, 1) != "1") { + result = { + code: "400", + message: "It's not production card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } else { + if (card_number.substring(0, 1) == "1") { + result = { + code: "400", + message: "It's production card number. Please use the development card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } + // time let now = moment().format("YYYY-MM-DD HH:mm:ss"); let today = moment().format("YYYY-MM-DD"); @@ -468,6 +542,43 @@ const reservation = async (req, res) => { return res.status(200).json(result); } + // log debug + winston.logger.debug( + `${uniqueCode} checking production card number or not...` + ); + + if (process.env.SERVER_FOR == "production") { + if (card_number.substring(0, 1) != "1") { + result = { + code: "400", + message: "It's not production card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } else { + if (card_number.substring(0, 1) == "1") { + result = { + code: "400", + message: "It's production card number. Please use the development card number.", + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + } + // time let now = moment().format("YYYY-MM-DD HH:mm:ss"); let today = moment().format("YYYY-MM-DD");