From d74856f6863ae3ec8aac9d3c7448c64779acda11 Mon Sep 17 00:00:00 2001 From: Sangwook Park <41150708+sw0501@users.noreply.github.com> Date: Fri, 9 Dec 2022 16:49:54 +0900 Subject: [PATCH] =?UTF-8?q?Modify:=20=ED=9C=A0=EC=B2=B4=EC=96=B4=EB=A6=AC?= =?UTF-8?q?=ED=94=84=ED=8A=B8=20=EC=9D=B4=EB=8F=99=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=EB=B3=84=EB=A1=9C=20=EA=B5=AC=EB=B6=84=ED=95=98=EC=97=AC=20res?= =?UTF-8?q?ponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 휠체어리프트 이동경로별로 구분하여 response --- Backend/routes/subwaydata.js | 52 ++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/Backend/routes/subwaydata.js b/Backend/routes/subwaydata.js index 1327bf6..55b613c 100644 --- a/Backend/routes/subwaydata.js +++ b/Backend/routes/subwaydata.js @@ -146,7 +146,8 @@ function getLiftMove(stCd, stNm, railCd, lnCd, callback) { try { console.log("LiftMove"); - //console.log(stNm); + + let liftMoveInfo = []; const url = 'https://openapi.kric.go.kr/openapi/vulnerableUserInfo/stationWheelchairLiftMovement'; let queryParams = '?' + encodeURIComponent('serviceKey'); @@ -158,13 +159,32 @@ function getLiftMove(stCd, stNm, railCd, lnCd, callback) { console.log(url + queryParams); + + return request({ url: url + queryParams, method: 'GET' }, function (error, response, body) { - liftMoveInfo = JSON.parse(body).body; - console.log(liftMoveInfo.length); + //목적지 별로 구분하여 제공 + const liftMoveParse = JSON.parse(body).body; + + let liftInfo = []; + + for (let i = 0; i < liftMoveParse.length; i++) { + if (liftMoveParse[i].mvTpOrdr == 1) { + if (liftInfo.length != 0) { + liftMoveInfo.push(liftInfo); + liftInfo = []; + } + } + liftInfo.push(liftMoveParse[i]); + } + if (liftInfo.length != 0) { + liftMoveInfo.push(liftInfo); + liftInfo = []; + } + callback(liftMoveInfo); }); } @@ -219,12 +239,30 @@ function getElevatorMove(stCd, stNm, railCd, lnCd, callback) { console.log(url + queryParams); + let elevatorMove = []; + return request({ url: url + queryParams, method: 'GET' }, function (error, response, body) { - JSON.parse(body).body; - callback(JSON.parse(body).body); + + let count = 0; + let index = "1"; + const elevatorMoveParse = JSON.parse(body).body; + for (let i = 0; i < elevatorMoveParse.length; i++) { + let elevatorInfo = []; + if (elevatorMoveParse[i].mvTpOrdr == 1) { + count++; + elevatorInfo.push(elevatorMoveParse[i]); + elevatorMove.push(elevatorInfo); + } + else { + + } + + } + //11223344 이런형식으로 나옴 + callback(elevatorMove); }); } catch (e) { @@ -529,9 +567,7 @@ router.get('/ElevatorMove/:stCd/:stNm/:railCd/:lnCd', async (req, res) => { await getElevatorMove(stCd, stNm, railCd, lnCd, callback => { console.log(callback); - return res.json({ - callback - }) + return res.json(callback); }); } catch (e) {