Eunsu486

Merge branch 'eunsu' into 'master'

Modify category.js



See merge request !2
......@@ -9,42 +9,34 @@ let ANIMAL_INFO_API_KEY = process.env.ANIMAL_API_KEY;
let user_gu;
let user_latitude;
let user_longitude;
user_gu = 강북구;
/*
http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03
?serviceKey=88dc66a7-9143-4af3-9f7b-098355b2c7f8&numOfRows=10&pageNo=1&keyword=동물병원
&where=강북구
System.out.println(Arrays.toString(hospitals));
*/
router.get('/hospital', function (req, res) {
let institute_url = 'http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03';
let qs = `?KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}&Type=json`;
let qs = `?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=10&pageNo=2&keyword=동물병원
&where=${user_gu}`;
request({
url: library_url + qs,
url: institute_url + qs,
method: 'GET'
}, function (err, response, body) {
if (!err && res.statusCode == 200) {
let library_result = JSON.parse(body);
let librarys = [];
for (let i = 0; i < library_result.Tbggibllbrm[1].row.length; i++) {
library = library_result.Tbggibllbrm[1].row[i];
let hospital_result = JSON.parse(body);
let hospitals = [];
for (let i = 0; i < hospital_result.Tbggibllbrm[1].row.length; i++) {
library = hospital_result.Tbggibllbrm[1].row[i];
if (userArea(library, 'REFINE_LOTNO_ADDR', user_target)) {
librarys.push(library);
hospitals.push(library);
}
}
library_grade = evalGrade(library_A, 0.5, librarys.length);
request({
url: institute_url + qs,
method: 'GET'
}, function (err, response, body) {
if (!err && res.statusCode == 200) {
let institute_result = JSON.parse(body);
let institutes = [];
for (let i = 0; i < institute_result.TninsttInstutM[1].row.length; i++) {
institute = institute_result.TninsttInstutM[1].row[i];
if (userArea(institute, 'REFINE_LOTNO_ADDR', user_target)) {
institutes.push(institute);
}
}
institute_grade = evalGrade(institute_A, institute_B, institutes);
grade = avgGrade(library_grade, institute_grade);
res.render('result', { category: 'school', librarys: librarys, institutes: institutes, userLocation: userLocation, grade: grade });
}
})
console.log([hospitals[1]]);
}
})
});
\ No newline at end of file
......