Eunsu486

Modify category.js

...@@ -9,42 +9,34 @@ let ANIMAL_INFO_API_KEY = process.env.ANIMAL_API_KEY; ...@@ -9,42 +9,34 @@ let ANIMAL_INFO_API_KEY = process.env.ANIMAL_API_KEY;
9 let user_gu; 9 let user_gu;
10 let user_latitude; 10 let user_latitude;
11 let user_longitude; 11 let user_longitude;
12 +user_gu = 강북구;
13 +/*
14 +http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03
15 +?serviceKey=88dc66a7-9143-4af3-9f7b-098355b2c7f8&numOfRows=10&pageNo=1&keyword=동물병원
16 +&where=강북구
12 17
18 + System.out.println(Arrays.toString(hospitals));
19 +
20 +*/
13 router.get('/hospital', function (req, res) { 21 router.get('/hospital', function (req, res) {
14 let institute_url = 'http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03'; 22 let institute_url = 'http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03';
15 - let qs = `?KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}&Type=json`; 23 + let qs = `?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=10&pageNo=2&keyword=동물병원
16 - request({ 24 + &where=${user_gu}`;
17 - url: library_url + qs, 25 +
18 - method: 'GET'
19 - }, function (err, response, body) {
20 - if (!err && res.statusCode == 200) {
21 - let library_result = JSON.parse(body);
22 - let librarys = [];
23 - for (let i = 0; i < library_result.Tbggibllbrm[1].row.length; i++) {
24 - library = library_result.Tbggibllbrm[1].row[i];
25 - if (userArea(library, 'REFINE_LOTNO_ADDR', user_target)) {
26 - librarys.push(library);
27 - }
28 - }
29 - library_grade = evalGrade(library_A, 0.5, librarys.length);
30 request({ 26 request({
31 url: institute_url + qs, 27 url: institute_url + qs,
32 method: 'GET' 28 method: 'GET'
33 }, function (err, response, body) { 29 }, function (err, response, body) {
34 if (!err && res.statusCode == 200) { 30 if (!err && res.statusCode == 200) {
35 - let institute_result = JSON.parse(body); 31 + let hospital_result = JSON.parse(body);
36 - let institutes = []; 32 + let hospitals = [];
37 - for (let i = 0; i < institute_result.TninsttInstutM[1].row.length; i++) { 33 + for (let i = 0; i < hospital_result.Tbggibllbrm[1].row.length; i++) {
38 - institute = institute_result.TninsttInstutM[1].row[i]; 34 + library = hospital_result.Tbggibllbrm[1].row[i];
39 - if (userArea(institute, 'REFINE_LOTNO_ADDR', user_target)) { 35 + if (userArea(library, 'REFINE_LOTNO_ADDR', user_target)) {
40 - institutes.push(institute); 36 + hospitals.push(library);
41 - }
42 } 37 }
43 - institute_grade = evalGrade(institute_A, institute_B, institutes);
44 - grade = avgGrade(library_grade, institute_grade);
45 - res.render('result', { category: 'school', librarys: librarys, institutes: institutes, userLocation: userLocation, grade: grade });
46 } 38 }
47 - }) 39 + console.log([hospitals[1]]);
48 } 40 }
49 }) 41 })
50 }); 42 });
...\ No newline at end of file ...\ No newline at end of file
......