From 921d7263ae23bd7ce10583bbbdc8296607483a3a Mon Sep 17 00:00:00 2001 From: Yeonggyun Kim Date: Sat, 25 Jan 2020 09:29:21 +0900 Subject: [PATCH] Add halt function --- common.js | 12 ++++++++++++ router/giksa.js | 7 ++++++- router/shuttlecock_i.js | 7 +++++++ router/shuttlecock_o.js | 6 ++++++ router/subway.js | 7 ++++++- router/yesulin.js | 7 ++++++- settings.json | 3 +++ 7 files changed, 46 insertions(+), 3 deletions(-) diff --git a/common.js b/common.js index 55550a8..5a625e7 100644 --- a/common.js +++ b/common.js @@ -46,5 +46,17 @@ function getDayKind() { } +function isHalt(){ + const haltList = data.calendar[4].halt; + console.log(haltList); + if(haltList.indexOf(now) !== -1){ + return "halted" + } else { + return "" + } +} + + module.exports.getDayKind = getDayKind module.exports.getDateKind = getDateKind +module.exports.isHalt = isHalt \ No newline at end of file diff --git a/router/giksa.js b/router/giksa.js index a978c71..87fcb2b 100644 --- a/router/giksa.js +++ b/router/giksa.js @@ -11,7 +11,7 @@ function urlParse (urlstr) { var datekind = ""; var daykind = ""; - +var isHalt = ""; router.get('/', (req, res) => { @@ -26,9 +26,11 @@ router.get('/', (req, res) => { //Short Path 로 접근 한 경우 datekind = func.getDateKind(); daykind = func.getDayKind(); + isHalt = func.isHalt(); } console.log("Date Kind : " + datekind + "\n") console.log("Day Kind : " + daykind + "\n"); + console.log("isHalted : " + isHalt + "\n"); switch (datekind) { case 'semester': // 학기중 @@ -55,6 +57,9 @@ router.get('/', (req, res) => { default: break } + if (isHalt == "halted") { + return res.status(200).json({ status: "Halt" }); + } try { var data = fs.readFileSync(jsonPath, 'UTF-8') diff --git a/router/shuttlecock_i.js b/router/shuttlecock_i.js index 0dc0f98..b322a12 100644 --- a/router/shuttlecock_i.js +++ b/router/shuttlecock_i.js @@ -11,6 +11,7 @@ function urlParse (urlstr) { var datekind = ""; var daykind = ""; +var isHalt = ""; router.get('/', (req, res) => { @@ -24,10 +25,12 @@ router.get('/', (req, res) => { if (urlArr.length == 2){ //Short Path 로 접근 한 경우 datekind = func.getDateKind() daykind = func.getDayKind() + isHalt = func.isHalt() } console.log("Date Kind : " + datekind + "\n"); console.log("Day Kind : " + daykind + "\n"); + console.log("isHalted : " + isHalt + "\n"); switch (datekind) { case 'semester': // 학기중 @@ -55,6 +58,10 @@ router.get('/', (req, res) => { break } + if (isHalt == "halted") { + return res.status(200).json({ status: "Halt" }); + } + try { var data = fs.readFileSync(jsonPath, 'UTF-8') } catch (err) { diff --git a/router/shuttlecock_o.js b/router/shuttlecock_o.js index 44fddbf..c1c2962 100644 --- a/router/shuttlecock_o.js +++ b/router/shuttlecock_o.js @@ -11,6 +11,7 @@ function urlParse (urlstr) { var datekind = ""; var daykind = ""; +var isHalt = ""; router.get('/', (req, res) => { @@ -24,10 +25,12 @@ router.get('/', (req, res) => { if (urlArr.length == 2){ //Short Path 로 접근 한 경우 datekind = func.getDateKind() daykind = func.getDayKind() + isHalt = func.isHalt() } console.log("Date Kind : " + datekind + "\n"); console.log("Day Kind : " + daykind + "\n"); + console.log("isHalted : " + isHalt + "\n"); switch (datekind) { case 'semester': // 학기중 @@ -54,6 +57,9 @@ router.get('/', (req, res) => { default: break } + if (isHalt == "halted") { + return res.status(200).json({ status: "Halt" }); + } try { var data = fs.readFileSync(jsonPath, 'UTF-8') diff --git a/router/subway.js b/router/subway.js index 3fd2f68..0f861cb 100644 --- a/router/subway.js +++ b/router/subway.js @@ -12,7 +12,7 @@ function urlParse (urlstr) { var datekind = ""; var daykind = ""; - +var isHalt = ""; router.get('/', (req, res) => { @@ -26,10 +26,12 @@ router.get('/', (req, res) => { if (urlArr.length == 2){ //Short Path 로 접근 한 경우 datekind = func.getDateKind() daykind = func.getDayKind() + isHalt = func.isHalt(); } console.log("Date Kind : " + datekind + "\n"); console.log("Day Kind : " + daykind + "\n"); + console.log("isHalted : " + isHalt + "\n"); switch (datekind) { case 'semester': // 학기중 @@ -56,6 +58,9 @@ router.get('/', (req, res) => { default: break } + if (isHalt == "halted") { + return res.status(200).json({ status: "Halt" }); + } try { var data = fs.readFileSync(jsonPath, 'UTF-8') diff --git a/router/yesulin.js b/router/yesulin.js index eb18a0e..3914d43 100644 --- a/router/yesulin.js +++ b/router/yesulin.js @@ -11,6 +11,7 @@ function urlParse (urlstr) { var datekind = ""; var daykind = ""; +var isHalt = ""; router.get('/', (req, res) => { @@ -24,10 +25,12 @@ router.get('/', (req, res) => { if (urlArr.length == 2){ //Short Path 로 접근 한 경우 datekind = func.getDateKind() daykind = func.getDayKind() + isHalt = func.isHalt() } console.log("Date Kind : " + datekind + "\n"); console.log("Day Kind : " + daykind + "\n"); + console.log("isHalted : " + isHalt + "\n"); switch (datekind) { @@ -55,7 +58,9 @@ router.get('/', (req, res) => { default: break } - + if(isHalt == "halted"){ + return res.status(200).json({status: "Halt" }) + } try { var data = fs.readFileSync(jsonPath, 'UTF-8') } catch (err) { diff --git a/settings.json b/settings.json index 12363d0..4eb818c 100644 --- a/settings.json +++ b/settings.json @@ -20,6 +20,9 @@ }, { "holiday": ["2019-12-25", "2020-01-01", "2020-01-24", "2020-01-25", "2020-01-26", "2020-01-27", "2020-03-01", "2020-04-15", "2020-04-30", "2020-05-05", "2020-05-15","2020-06-06", "2020-08-15", "2020-09-30", "2020-10-01", "2020-10-02", "2020-10-03", "2020-10-09", "2020-12-25"] + }, + { + "halt": ["2020-01-24", "2020-01-25", "2020-01-26", "2020-01-27"] } ] } \ No newline at end of file