From f5cdd2fff0777c4a257cedd20a45706c6e120c94 Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Fri, 3 Nov 2023 21:24:20 +0900 Subject: [PATCH 01/11] =?UTF-8?q?feat:=20=EC=97=85=EC=A2=85=EC=97=90=20?= =?UTF-8?q?=EB=8C=80=ED=95=9C=20=EA=B0=80=EA=B2=8C=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?DB=EC=97=90=20insert=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scheduler/scheduler.ts | 52 +++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/scheduler/scheduler.ts b/src/scheduler/scheduler.ts index 3f947f0..0378727 100644 --- a/src/scheduler/scheduler.ts +++ b/src/scheduler/scheduler.ts @@ -9,32 +9,48 @@ export const dbScheduler = async () => { try { //업종명 const SANITTN_BIZCOND_NM = "chifood"; - const url = + const getHeadUrl = "https://openapi.gg.go.kr/Genrestrt" + SANITTN_BIZCOND_NM + "?key=" + key + "&type=json&pSize=5&pindex=1"; - const response = await axios.get(url); - const responseData: RestaurantResponse = response.data; + const getHead = await axios.get(getHeadUrl); + const headData: RestaurantResponse = getHead.data; - //[0] = head / [1] = row - const restaurants: Restaurant[] = responseData.Genrestrtchifood[1].row; + // 데이터 총 개수 + const total = headData.Genrestrtchifood[0].head[0].list_total_count; + // const total = 17; test용 값 + // 한번에 가져올 데이터 수 + const chunkSize = 5; - // DB에 들어갈 데이터들 - const restaurantInfo = { - restaurant_name: restaurants[0].BIZPLC_NM, - restaurant_type: restaurants[0].SANITTN_BIZCOND_NM, - adress: restaurants[0].REFINE_ROADNM_ADDR, - lat: Number(restaurants[0].REFINE_WGS84_LAT), - lon: Number(restaurants[0].REFINE_WGS84_LOGT), - }; - - // insert DB - const insertDB = await db.Restaurant.create(restaurantInfo); - - console.log("db에 insert : ", insertDB); + for (let idx = 1; idx < total; idx += chunkSize) { + console.log(idx, "번째 요청"); + let url = + "https://openapi.gg.go.kr/Genrestrt" + + SANITTN_BIZCOND_NM + + "?key=" + + key + + "&type=json&pSize=" + + chunkSize + + "&pindex=" + + Math.floor(idx / chunkSize + 1); + console.log("insert : ", url); + let response = await axios.get(url); + let responseData: RestaurantResponse = response.data; + let restaurants: Restaurant[] = responseData.Genrestrtchifood[1].row; + for (let i in restaurants) { + let restaurantInfo = { + restaurant_name: restaurants[i].BIZPLC_NM, + restaurant_type: restaurants[i].SANITTN_BIZCOND_NM, + adress: restaurants[i].REFINE_LOTNO_ADDR, // 도로명 주소가 없는 식당이 존재 함 + lat: Number(restaurants[i].REFINE_WGS84_LAT), + lon: Number(restaurants[i].REFINE_WGS84_LOGT), + }; + let insertDB = await db.Restaurant.create(restaurantInfo); + } + } } catch (error) { console.log("api 호출 중 오류 발생 : ", error); } From db96ab787c8ac3fb9c03670801f48e9acec9384e Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Sat, 4 Nov 2023 20:02:31 +0900 Subject: [PATCH 02/11] =?UTF-8?q?feat:=20=EC=A0=84=EC=B2=B4=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=84=A3=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=20=EB=B0=8F=20url=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scheduler/all_insert.ts | 55 +++++++++++++++++++++++++ src/scheduler/scheduler.ts | 81 ++----------------------------------- 2 files changed, 58 insertions(+), 78 deletions(-) create mode 100644 src/scheduler/all_insert.ts diff --git a/src/scheduler/all_insert.ts b/src/scheduler/all_insert.ts new file mode 100644 index 0000000..6a84354 --- /dev/null +++ b/src/scheduler/all_insert.ts @@ -0,0 +1,55 @@ +import axios from "axios"; +import db from "../db/models/index"; + +export const allInsertDB = async () => { + const key = process.env.api_key; + try { + //업종명 + + const getHeadUrl = + "https://openapi.gg.go.kr/Genrestrt" + + "?key=" + + key + + "&type=json&pSize=5&pindex=1"; + + const getHead = await axios.get(getHeadUrl); + const headData = getHead.data; + + // 데이터 총 개수 + // const total = headData.Genrestrtchifood[0].head[0].list_total_count; + const total = 17; + // 한번에 가져올 데이터 수 + const chunkSize = 5; + + for (let idx = 1; idx < total; idx += chunkSize) { + console.log(idx, "번째 요청"); + const url = + "https://openapi.gg.go.kr/GENRESTRT" + + "?key=" + + key + + "&type=json&pSize=" + + chunkSize + + "&pindex=" + + Math.floor(idx / chunkSize + 1); + console.log("url : ", url); + + // 전체 데이터 가져오기 + const response = await axios.get(url); + const responseData = response.data; + const restaurants = responseData.GENRESTRT[1].row; + + for (let i in restaurants) { + const restaurantInfo = { + restaurant_name: restaurants[i].BIZPLC_NM, + restaurant_type: restaurants[i].SANITTN_BIZCOND_NM, + adress: restaurants[i].REFINE_LOTNO_ADDR, // 도로명 주소가 없는 식당이 존재 함 + lat: Number(restaurants[i].REFINE_WGS84_LAT), + lon: Number(restaurants[i].REFINE_WGS84_LOGT), + }; + const insertDB = await db.Restaurant.create(restaurantInfo); + } + } + } catch (error) { + console.log("api 호출 중 오류 발생 : ", error); + } +}; diff --git a/src/scheduler/scheduler.ts b/src/scheduler/scheduler.ts index 0378727..1ff8040 100644 --- a/src/scheduler/scheduler.ts +++ b/src/scheduler/scheduler.ts @@ -1,85 +1,10 @@ import axios from "axios"; import db from "../db/models/index"; +import { allInsertDB } from "./all_insert"; + export const dbScheduler = async () => { console.log(new Date() + "Running Scheduler !!! "); - const key = process.env.api_key; - - try { - //업종명 - const SANITTN_BIZCOND_NM = "chifood"; - const getHeadUrl = - "https://openapi.gg.go.kr/Genrestrt" + - SANITTN_BIZCOND_NM + - "?key=" + - key + - "&type=json&pSize=5&pindex=1"; - - const getHead = await axios.get(getHeadUrl); - const headData: RestaurantResponse = getHead.data; - - // 데이터 총 개수 - const total = headData.Genrestrtchifood[0].head[0].list_total_count; - // const total = 17; test용 값 - // 한번에 가져올 데이터 수 - const chunkSize = 5; - - for (let idx = 1; idx < total; idx += chunkSize) { - console.log(idx, "번째 요청"); - let url = - "https://openapi.gg.go.kr/Genrestrt" + - SANITTN_BIZCOND_NM + - "?key=" + - key + - "&type=json&pSize=" + - chunkSize + - "&pindex=" + - Math.floor(idx / chunkSize + 1); - console.log("insert : ", url); - let response = await axios.get(url); - let responseData: RestaurantResponse = response.data; - let restaurants: Restaurant[] = responseData.Genrestrtchifood[1].row; - for (let i in restaurants) { - let restaurantInfo = { - restaurant_name: restaurants[i].BIZPLC_NM, - restaurant_type: restaurants[i].SANITTN_BIZCOND_NM, - adress: restaurants[i].REFINE_LOTNO_ADDR, // 도로명 주소가 없는 식당이 존재 함 - lat: Number(restaurants[i].REFINE_WGS84_LAT), - lon: Number(restaurants[i].REFINE_WGS84_LOGT), - }; - let insertDB = await db.Restaurant.create(restaurantInfo); - } - } - } catch (error) { - console.log("api 호출 중 오류 발생 : ", error); - } + await allInsertDB(); }; - -// api로 받아오는 json 값들을 미리 정의해주는 인터페이스 -interface Restaurant { - SIGUN_NM: string; - BIZPLC_NM: string; - LICENSG_DE: string; - BSN_STATE_NM: string; - SANITTN_BIZCOND_NM: string; - REFINE_LOTNO_ADDR: string; - REFINE_ROADNM_ADDR: string; - REFINE_ZIP_CD: string; - REFINE_WGS84_LOGT: string; - REFINE_WGS84_LAT: string; -} - -interface RestaurantResponse { - Genrestrtchifood: { - head: { - list_total_count: number; - RESULT: { - CODE: string; - MESSAGE: string; - }; - api_version: string; - }[]; - row: Restaurant[]; - }[]; -} From 4204c5a6f1f62112c9f84f9ae31148ff1cad4566 Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Mon, 6 Nov 2023 15:59:58 +0900 Subject: [PATCH 03/11] =?UTF-8?q?feat:=20=ED=8F=90=EC=97=85=20=EA=B0=80?= =?UTF-8?q?=EA=B2=8C=20=EC=B6=94=EA=B0=80=20x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scheduler/all_insert.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/scheduler/all_insert.ts b/src/scheduler/all_insert.ts index 6a84354..a7c0c26 100644 --- a/src/scheduler/all_insert.ts +++ b/src/scheduler/all_insert.ts @@ -39,14 +39,17 @@ export const allInsertDB = async () => { const restaurants = responseData.GENRESTRT[1].row; for (let i in restaurants) { - const restaurantInfo = { - restaurant_name: restaurants[i].BIZPLC_NM, - restaurant_type: restaurants[i].SANITTN_BIZCOND_NM, - adress: restaurants[i].REFINE_LOTNO_ADDR, // 도로명 주소가 없는 식당이 존재 함 - lat: Number(restaurants[i].REFINE_WGS84_LAT), - lon: Number(restaurants[i].REFINE_WGS84_LOGT), - }; - const insertDB = await db.Restaurant.create(restaurantInfo); + if (restaurants[i].BSN_STATE_NM == "폐업") { + // 폐업 가게 추가 x + const restaurantInfo = { + restaurant_name: restaurants[i].BIZPLC_NM, + restaurant_type: restaurants[i].SANITTN_BIZCOND_NM, + adress: restaurants[i].REFINE_LOTNO_ADDR, // 도로명 주소가 없는 식당이 존재 함 + lat: Number(restaurants[i].REFINE_WGS84_LAT), + lon: Number(restaurants[i].REFINE_WGS84_LOGT), + }; + const insertDB = await db.Restaurant.create(restaurantInfo); + } } } } catch (error) { From 953d22a266a3e6c1bc98be63116711589d37ad57 Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Mon, 6 Nov 2023 16:00:58 +0900 Subject: [PATCH 04/11] =?UTF-8?q?feat:=20=EC=97=BD=EC=97=89=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EA=B0=80=20=ED=8F=90=EC=97=85=EC=9D=B8=20=EA=B0=80?= =?UTF-8?q?=EA=B2=8C=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scheduler/all_insert.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scheduler/all_insert.ts b/src/scheduler/all_insert.ts index a7c0c26..79c3915 100644 --- a/src/scheduler/all_insert.ts +++ b/src/scheduler/all_insert.ts @@ -39,7 +39,7 @@ export const allInsertDB = async () => { const restaurants = responseData.GENRESTRT[1].row; for (let i in restaurants) { - if (restaurants[i].BSN_STATE_NM == "폐업") { + if (restaurants[i].BSN_STATE_NM != "폐업") { // 폐업 가게 추가 x const restaurantInfo = { restaurant_name: restaurants[i].BIZPLC_NM, From 0c340ae80783f513b7ecd6adb5cce4629c05ef77 Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Mon, 6 Nov 2023 16:25:37 +0900 Subject: [PATCH 05/11] =?UTF-8?q?feat:=20=EC=A0=84=EC=B2=B4=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=A0=80=EC=9E=A5,=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=202=EA=B0=80=EC=A7=80=20=EC=BC=80=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scheduler/all_insert.ts | 17 ++++++++++------- src/scheduler/scheduler.ts | 12 ++++++++++-- src/scheduler/update_restaurant.ts | 6 ++++++ 3 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 src/scheduler/update_restaurant.ts diff --git a/src/scheduler/all_insert.ts b/src/scheduler/all_insert.ts index 79c3915..233f744 100644 --- a/src/scheduler/all_insert.ts +++ b/src/scheduler/all_insert.ts @@ -7,7 +7,7 @@ export const allInsertDB = async () => { //업종명 const getHeadUrl = - "https://openapi.gg.go.kr/Genrestrt" + + "https://openapi.gg.go.kr/GENRESTRT" + "?key=" + key + "&type=json&pSize=5&pindex=1"; @@ -16,11 +16,11 @@ export const allInsertDB = async () => { const headData = getHead.data; // 데이터 총 개수 - // const total = headData.Genrestrtchifood[0].head[0].list_total_count; - const total = 17; + // const total = headData.GENRESTRT[0].head[0].list_total_count; + const total = 2000; // 한번에 가져올 데이터 수 - const chunkSize = 5; - + const chunkSize = 100; + var cnt = 0; for (let idx = 1; idx < total; idx += chunkSize) { console.log(idx, "번째 요청"); const url = @@ -39,8 +39,10 @@ export const allInsertDB = async () => { const restaurants = responseData.GENRESTRT[1].row; for (let i in restaurants) { - if (restaurants[i].BSN_STATE_NM != "폐업") { - // 폐업 가게 추가 x + if (restaurants[i].BSN_STATE_NM == "폐업") { + // 폐업 가게수 + // cnt++; + } else { const restaurantInfo = { restaurant_name: restaurants[i].BIZPLC_NM, restaurant_type: restaurants[i].SANITTN_BIZCOND_NM, @@ -52,6 +54,7 @@ export const allInsertDB = async () => { } } } + // console.log("폐업 가게 수 : ", cnt); } catch (error) { console.log("api 호출 중 오류 발생 : ", error); } diff --git a/src/scheduler/scheduler.ts b/src/scheduler/scheduler.ts index 1ff8040..6e38b03 100644 --- a/src/scheduler/scheduler.ts +++ b/src/scheduler/scheduler.ts @@ -1,10 +1,18 @@ import axios from "axios"; import db from "../db/models/index"; - +import { updateRestData } from "./update_restaurant"; import { allInsertDB } from "./all_insert"; export const dbScheduler = async () => { console.log(new Date() + "Running Scheduler !!! "); - await allInsertDB(); + const nowData = await db.Restaurant.count(); + + if (nowData > 0) { + console.log("0보다 큼"); + await updateRestData(); + } else { + console.log("DB에 데이터 없음"); + await allInsertDB(); + } }; diff --git a/src/scheduler/update_restaurant.ts b/src/scheduler/update_restaurant.ts new file mode 100644 index 0000000..2fda376 --- /dev/null +++ b/src/scheduler/update_restaurant.ts @@ -0,0 +1,6 @@ +import axios from "axios"; +import db from "../db/models/index"; + +export const updateRestData = async () => { + console.log("업데이트 "); +}; From e9dec828acd4969a7ee1139a1efea12e375f2cb9 Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Mon, 6 Nov 2023 16:56:09 +0900 Subject: [PATCH 06/11] =?UTF-8?q?docs:=20Readmd.md=EC=97=90=20apikey=20?= =?UTF-8?q?=EC=96=BB=EB=8A=94=20=EB=B2=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 7e49500..8a75b63 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,7 @@ npm run dev // ts-node로 실행 npm start ``` + +## api_key +- [경기데이터드림}(https://data.gg.go.kr/portal/mainPage.do) 접속 후 회원가입을 진행 +- 마이페이지에서 인증키 발급을 통해 apikey을 얻을 수 있습니다. From 67bd1467dbca6090ec566b67a3a30b2f9e497820 Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Mon, 6 Nov 2023 16:57:14 +0900 Subject: [PATCH 07/11] =?UTF-8?q?docs:=20Readme.md=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a75b63..e9fc2d9 100644 --- a/README.md +++ b/README.md @@ -19,5 +19,5 @@ npm start ``` ## api_key -- [경기데이터드림}(https://data.gg.go.kr/portal/mainPage.do) 접속 후 회원가입을 진행 +- [경기데이터드림](https://data.gg.go.kr/portal/mainPage.do) 접속 후 회원가입을 진행 - 마이페이지에서 인증키 발급을 통해 apikey을 얻을 수 있습니다. From 474d6f89d1304b95a54b1b109f6f21d1e2deac5d Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Mon, 6 Nov 2023 17:13:29 +0900 Subject: [PATCH 08/11] test: test commit --- src/app.ts | 4 ++-- src/scheduler/update_restaurant.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app.ts b/src/app.ts index 9e3f537..dc7c267 100644 --- a/src/app.ts +++ b/src/app.ts @@ -25,7 +25,7 @@ app.use("/openapi", swaggerUi.serve, swaggerUi.setup(openApiDocument)); db.sequelize .sync({ - force: true, //임시 + force: false, //임시 }) .then(() => { console.log("connected"); @@ -46,7 +46,7 @@ const router = s.router(contract, { }), }); -createExpressEndpoints(contract, router, app); +// createExpressEndpoints(contract, router, app); app.listen(3000, () => { console.log("Server On"); diff --git a/src/scheduler/update_restaurant.ts b/src/scheduler/update_restaurant.ts index 2fda376..85e400e 100644 --- a/src/scheduler/update_restaurant.ts +++ b/src/scheduler/update_restaurant.ts @@ -2,5 +2,6 @@ import axios from "axios"; import db from "../db/models/index"; export const updateRestData = async () => { - console.log("업데이트 "); + const date = new Date().getDay(); + console.log(date); }; From f2a94b520f287ba496b4d19a8f0c09da5a18831d Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Tue, 7 Nov 2023 13:42:34 +0900 Subject: [PATCH 09/11] test commit --- .vscode/settings.json | 3 +- package-lock.json | 420 +++++++++++++++++++++++++++++++++++++++++- package.json | 9 +- 3 files changed, 423 insertions(+), 9 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index eb26746..b23df9a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,5 +6,6 @@ "editor.formatOnSave": true, "editor.formatOnPaste": true, "editor.defaultFormatter": "esbenp.prettier-vscode" - } + }, + "typescript.tsdk": "node_modules\\typescript\\lib" } diff --git a/package-lock.json b/package-lock.json index 4c228bf..9aa33d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,7 @@ "redis": "^4.6.10", "sequelize": "^6.33.0", "swagger-ui-express": "^5.0.0", + "tsx": "^3.14.0", "zod": "^3.22.4" }, "devDependencies": { @@ -70,6 +71,336 @@ "node": ">=12" } }, + "node_modules/@esbuild/android-arm": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.20.tgz", + "integrity": "sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz", + "integrity": "sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.18.20.tgz", + "integrity": "sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz", + "integrity": "sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.18.20.tgz", + "integrity": "sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.20.tgz", + "integrity": "sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.18.20.tgz", + "integrity": "sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.18.20.tgz", + "integrity": "sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.18.20.tgz", + "integrity": "sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.18.20.tgz", + "integrity": "sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.18.20.tgz", + "integrity": "sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.18.20.tgz", + "integrity": "sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.18.20.tgz", + "integrity": "sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.18.20.tgz", + "integrity": "sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.18.20.tgz", + "integrity": "sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.20.tgz", + "integrity": "sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.18.20.tgz", + "integrity": "sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.18.20.tgz", + "integrity": "sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.18.20.tgz", + "integrity": "sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.18.20.tgz", + "integrity": "sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.18.20.tgz", + "integrity": "sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.20.tgz", + "integrity": "sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", @@ -969,8 +1300,7 @@ "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, "node_modules/bytes": { "version": "3.1.2", @@ -1375,6 +1705,42 @@ "es6-symbol": "^3.1.1" } }, + "node_modules/esbuild": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.20.tgz", + "integrity": "sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.18.20", + "@esbuild/android-arm64": "0.18.20", + "@esbuild/android-x64": "0.18.20", + "@esbuild/darwin-arm64": "0.18.20", + "@esbuild/darwin-x64": "0.18.20", + "@esbuild/freebsd-arm64": "0.18.20", + "@esbuild/freebsd-x64": "0.18.20", + "@esbuild/linux-arm": "0.18.20", + "@esbuild/linux-arm64": "0.18.20", + "@esbuild/linux-ia32": "0.18.20", + "@esbuild/linux-loong64": "0.18.20", + "@esbuild/linux-mips64el": "0.18.20", + "@esbuild/linux-ppc64": "0.18.20", + "@esbuild/linux-riscv64": "0.18.20", + "@esbuild/linux-s390x": "0.18.20", + "@esbuild/linux-x64": "0.18.20", + "@esbuild/netbsd-x64": "0.18.20", + "@esbuild/openbsd-x64": "0.18.20", + "@esbuild/sunos-x64": "0.18.20", + "@esbuild/win32-arm64": "0.18.20", + "@esbuild/win32-ia32": "0.18.20", + "@esbuild/win32-x64": "0.18.20" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -1570,6 +1936,19 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -1636,6 +2015,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-tsconfig": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.2.tgz", + "integrity": "sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -2594,6 +2984,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/retry-as-promised": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.4.tgz", @@ -2872,7 +3270,6 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -2881,7 +3278,6 @@ "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -3067,6 +3463,22 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", "dev": true }, + "node_modules/tsx": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-3.14.0.tgz", + "integrity": "sha512-xHtFaKtHxM9LOklMmJdI3BEnQq/D5F73Of2E1GDrITi9sgoVkvIsrQUTY1G8FlmGtA+awCI4EBlTRRYxkL2sRg==", + "dependencies": { + "esbuild": "~0.18.20", + "get-tsconfig": "^4.7.2", + "source-map-support": "^0.5.21" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, "node_modules/type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", diff --git a/package.json b/package.json index d12c53e..40441b9 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,10 @@ "node": ">=20.9.0" }, "scripts": { - "start": "ts-node ./src/app.ts", - "dev": "node --loader @swc-node/register/esm --watch ./src/app.ts", - "test": "node --loader @swc-node/register/esm --test ./src/**/*.test.ts", - "test:watch": "node --loader @swc-node/register/esm --watch --test ./src/**/*.test.ts" + "start": "node --import tsx ./src/app.ts", + "dev": "node --import tsx --watch ./src/app.ts", + "test": "node --import tsx --test ./src/**/*.test.ts", + "test:watch": "node --import tsx --watch --test ./src/**/*.test.ts" }, "devDependencies": { "@swc-node/register": "^1.6.8", @@ -47,6 +47,7 @@ "redis": "^4.6.10", "sequelize": "^6.33.0", "swagger-ui-express": "^5.0.0", + "tsx": "^3.14.0", "zod": "^3.22.4" } } From da80198a1566dad3e89d94e16084aaa8c46ea701 Mon Sep 17 00:00:00 2001 From: sphy1597 Date: Tue, 7 Nov 2023 22:38:16 +0900 Subject: [PATCH 10/11] =?UTF-8?q?feat:=20update=EA=B8=B0=EB=8A=A5,=20?= =?UTF-8?q?=ED=8F=90=EC=97=85=ED=95=9C=20=EA=B0=80=EA=B2=8C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.ts | 9 +-- src/scheduler/scheduler.ts | 3 +- src/scheduler/sectors.json | 28 +++++++++ src/scheduler/update_restaurant.ts | 93 +++++++++++++++++++++++++++++- 4 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 src/scheduler/sectors.json diff --git a/src/app.ts b/src/app.ts index cc4e9d8..8735417 100644 --- a/src/app.ts +++ b/src/app.ts @@ -3,7 +3,7 @@ import morgan from "morgan"; import testRouter from "./test/test.router.ts"; import dotenv from "dotenv"; import { userContract, userRouter } from "./user/user_router"; -import { dbScheduler } from "./scheduler/scheduler"; +import { dbScheduler } from "./scheduler/scheduler.ts"; import db from "./db/models"; import schedule from "node-schedule"; import { createExpressEndpoints, initServer } from "@ts-rest/express"; @@ -14,6 +14,7 @@ import { reviewRouter, reviewContract } from "./review/mod.ts"; import { restaurantsContract, restaurantsRouter } from "./restaurants"; import { initContract } from "@ts-rest/core"; import { regionsContract, regionsRouter } from "./regions"; +import {} from "node:fs"; dotenv.config(); @@ -73,9 +74,9 @@ createExpressEndpoints(reviewContract, reviewRouter, app, jwtMiddleware); app.listen(3000, () => { console.log("Server On"); - // schedule.scheduleJob("0 * * * * *", function () { - // dbScheduler(); - // }); + schedule.scheduleJob("0 * * * * *", function () { + dbScheduler(); + }); }); /* diff --git a/src/scheduler/scheduler.ts b/src/scheduler/scheduler.ts index 6e38b03..b232c98 100644 --- a/src/scheduler/scheduler.ts +++ b/src/scheduler/scheduler.ts @@ -6,13 +6,12 @@ import { allInsertDB } from "./all_insert"; export const dbScheduler = async () => { console.log(new Date() + "Running Scheduler !!! "); + // 오늘의 요일 0 ~ 6 const nowData = await db.Restaurant.count(); if (nowData > 0) { - console.log("0보다 큼"); await updateRestData(); } else { - console.log("DB에 데이터 없음"); await allInsertDB(); } }; diff --git a/src/scheduler/sectors.json b/src/scheduler/sectors.json new file mode 100644 index 0000000..c0deaaf --- /dev/null +++ b/src/scheduler/sectors.json @@ -0,0 +1,28 @@ +{ + "0": { + "data1": "Genrestrtcate", + "data2": "Genrestrtsash" }, + "1": { + "data1": "Genrestrtfastfood", + "data2": "Genrestrtstandpub" + }, + "2": { + "data1": "Genrestrtlunch", + "data2": "Genrestrtjpnfood" + }, + "3": { + "data1": "Genrestrtbsrpcook", + "data2": "Genrestrtchifood'" }, + "4": { + "data1": "Genrestrttratearm", + "data2": "Genrestrtbuff" + }, + "5": { + "data1": "Genrestrtsoup", + "data2": "Genrestrtfugu" + }, + "6": { + "data1": "Genrestrtmovmntcook", + "data2": "Kidscafe" + } +} diff --git a/src/scheduler/update_restaurant.ts b/src/scheduler/update_restaurant.ts index 2fda376..fd8b98f 100644 --- a/src/scheduler/update_restaurant.ts +++ b/src/scheduler/update_restaurant.ts @@ -1,6 +1,97 @@ import axios from "axios"; import db from "../db/models/index"; +import { readFileSync } from "node:fs"; +import { join, dirname } from "node:path"; +import { fileURLToPath } from "node:url"; +import { restaurantsRouter } from "../restaurants"; export const updateRestData = async () => { - console.log("업데이트 "); + const today = new Date(2023, 11, 10).getDay(); + // 하루에 2개의 업종별로 업데이트 + const path = join(dirname(fileURLToPath(import.meta.url)), "sectors.json"); + const raw = readFileSync(path, { encoding: "utf8" }); + const secotrs = JSON.parse(raw); + + await updateDB(secotrs[today].data1); +}; + +const updateDB = async (_sectors: string) => { + const key = process.env.api_key; + + try { + //업종명 + + const getHeadUrl = + "https://openapi.gg.go.kr/" + + _sectors + + "?key=" + + key + + "&type=json&pSize=5&pindex=1"; + + const getHead = await axios.get(getHeadUrl); + const headData = getHead.data; + + // 데이터 총 개수 + // const total = headData.GENRESTRT[0].head[0].list_total_count; + const total = 5; + // 한번에 가져올 데이터 수 + const chunkSize = 2; + var cnt = 0; + for (let idx = 1; idx < total; idx += chunkSize) { + const url = + "https://openapi.gg.go.kr/" + + _sectors + + "?key=" + + key + + "&type=json&pSize=" + + chunkSize + + "&pindex=" + + Math.floor(idx / chunkSize + 1); + + // 전체 데이터 가져오기 + const response = await axios.get(url); + const responseData = response.data; + const restaurants = responseData[_sectors][1].row; + + for (let i in restaurants) { + // 폐업한 가게 중에서 DB에 데이터가 있다면 삭제 + if (restaurants[i].BSN_STATE_NM == "폐업") { + const closed = await db.Restaurant.findOne({ + where: { + restaurant_name: restaurants[i].BIZPLC_NM, + adress: restaurants[i].REFINE_LOTNO_ADDR, + }, + }); + // 삭제 로직 + if (closed !== null) { + db.Restaurant.destroy({ + where: { + restaurant_name: restaurants[i].BIZPLC_NM, + adress: restaurants[i].REFINE_LOTNO_ADDR, + }, + }); + } + } else { + // 영업 중인 가게 정보 업데이트 + db.Restaurant.update( + { + restaurant_name: restaurants[i].BIZPLC_NM, + restaurant_type: restaurants[i].SANITTN_BIZCOND_NM, + adress: restaurants[i].REFINE_LOTNO_ADDR, // 도로명 주소가 없는 식당이 존재 함 + lat: Number(restaurants[i].REFINE_WGS84_LAT), + lon: Number(restaurants[i].REFINE_WGS84_LOGT), + }, + { + where: { + restaurant_name: restaurants[i].BIZPLC_NM, + adress: restaurants[i].REFINE_LOTNO_ADDR, + }, + }, + ); + } + } + } + } catch (error) { + console.log("api 호출 중 오류 발생 : ", error); + } }; From 30dd66e4c4252d39d0175aeff8eb1fda8fe640a8 Mon Sep 17 00:00:00 2001 From: scarf Date: Wed, 8 Nov 2023 07:33:45 +0900 Subject: [PATCH 11/11] style: prettier --- package-lock.json | 2 +- package.json | 2 +- src/scheduler/sectors.json | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6cf3024..52912cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3242,4 +3242,4 @@ } } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 922c880..c7c965f 100644 --- a/package.json +++ b/package.json @@ -47,4 +47,4 @@ "swagger-ui-express": "^5.0.0", "zod": "^3.22.4" } -} \ No newline at end of file +} diff --git a/src/scheduler/sectors.json b/src/scheduler/sectors.json index c0deaaf..241c4e1 100644 --- a/src/scheduler/sectors.json +++ b/src/scheduler/sectors.json @@ -1,7 +1,8 @@ { "0": { "data1": "Genrestrtcate", - "data2": "Genrestrtsash" }, + "data2": "Genrestrtsash" + }, "1": { "data1": "Genrestrtfastfood", "data2": "Genrestrtstandpub" @@ -12,7 +13,8 @@ }, "3": { "data1": "Genrestrtbsrpcook", - "data2": "Genrestrtchifood'" }, + "data2": "Genrestrtchifood'" + }, "4": { "data1": "Genrestrttratearm", "data2": "Genrestrtbuff"