오수빈

add funtion park

......@@ -39,7 +39,6 @@ router.post('/hospital', function(req, res){
var itemList = petJson.response.body.items;
var numRows = petJson.response.body.totalCount._text; //개수
//-------------------------------------------------
if (numRows == 1){
// state 정상인 것만 추리기
if (itemList.item.state._text == '정상'){
......@@ -55,7 +54,6 @@ router.post('/hospital', function(req, res){
}
}
}
//-----------------------------------------------
//테스트용 console.log
for(i=0; i<hospital_list.length; i++){
......@@ -96,7 +94,6 @@ router.post('/medicine', function(req, res){
var itemList = petJson.response.body.items;
var numRows = petJson.response.body.totalCount._text; //개수
//-------------------------------------------------
if (numRows == 1){
// state 정상인 것만 추리기
if (itemList.item.state._text == '정상'){
......@@ -112,7 +109,6 @@ router.post('/medicine', function(req, res){
}
}
}
//-----------------------------------------------
//테스트용 console.log
for(i=0; i<medicine_list.length; i++){
......@@ -184,7 +180,6 @@ router.post('/appliance', function(req, res){
})
});
/*
//체육시설
router.post('/park', function(req, res){
//gu 받아오기
......@@ -201,7 +196,6 @@ router.post('/park', function(req, res){
//api
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[0]}&where=${gu_select_encode}`;
//let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=%EC%83%9D%ED%99%9C%EC%B2%B4%EC%9C%A1%EA%B4%80&where=${gu_select_encode}`;
request(pet_url, function(err, response, body){
if(err) {
console.log(`err => ${err}`)
......@@ -213,107 +207,113 @@ router.post('/park', function(req, res){
var result = convert.xml2json(body, {compact: true, spaces: 4});
var petJson = JSON.parse(result)
var itemList = petJson.response.body.items;
var numRows = petJson.response.body.totalCount._text; //개수
//-------------------------------------------------
if (numRows == 1){
// state 정상인 것만 추리기
if (itemList.item.state._text == '정상'){
appliance_list.push(itemList.item);
}
appliance_list.push(itemList.item);
}
else if (numRows == 0){}
else {
for (i=0; i<numRows; i++){
// state 정상인 것만 추리기
if (itemList.item[i].state._text == '정상'){
appliance_list.push(itemList.item[i]);
}
appliance_list.push(itemList.item[i]);
}
}
//-----------------------------------------------
}
}
//api
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[1]}&where=${gu_select_encode}`;
//let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=%EC%83%9D%ED%99%9C%EC%B2%B4%EC%9C%A1%EA%B4%80&where=${gu_select_encode}`;
request(pet_url, function(err, response, body){
if(err) {
console.log(`err => ${err}`)
}
else {
if(res.statusCode == 200) {
//var appliance_list = [];
//var titles = '';
//api
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[1]}&where=${gu_select_encode}`;
//let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=%EC%83%9D%ED%99%9C%EC%B2%B4%EC%9C%A1%EA%B4%80&where=${gu_select_encode}`;
request(pet_url, function(err, response, body){
if(err) {
console.log(`err => ${err}`)
}
else {
if(res.statusCode == 200) {
var result = convert.xml2json(body, {compact: true, spaces: 4});
var petJson = JSON.parse(result)
var result = convert.xml2json(body, {compact: true, spaces: 4});
var petJson = JSON.parse(result)
var itemList = petJson.response.body.items;
var numRows = itemList.item.length; //개수
for (i=0; i<numRows; i++){
appliance_list.push(itemList.item[i]);
var itemList = petJson.response.body.items;
var numRows = petJson.response.body.totalCount._text; //개수
if (numRows == 1){
appliance_list.push(itemList.item);
}
else if (numRows == 0){}
else {
for (i=0; i<numRows; i++){
appliance_list.push(itemList.item[i]);
}
}
}
//테스트용 console.log
for(i=0; i<appliance_list.length; i++){
titles = titles+appliance_list[i].title._text+'\n';
}
//api
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[2]}&where=${gu_select_encode}`;
request(pet_url, function(err, response, body){
if(err) {
console.log(`err => ${err}`)
}
else {
if(res.statusCode == 200) {
var result = convert.xml2json(body, {compact: true, spaces: 4});
var petJson = JSON.parse(result)
if (titles == '') {console.log('nothing');}
else {console.log(titles); }
var itemList = petJson.response.body.items;
var numRows = petJson.response.body.totalCount._text; //개수
if (numRows == 1){
appliance_list.push(itemList.item);
}
else if (numRows == 0){}
else {
for (i=0; i<numRows; i++){
appliance_list.push(itemList.item[i]);
}
}
}
}
}
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[2]}&where=${gu_select_encode}`;
//api
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[3]}&where=${gu_select_encode}`;
request(pet_url, function(err, response, body){
if(err) {
console.log(`err => ${err}`)
}
else {
if(res.statusCode == 200) {
//var appliance_list = [];
//var titles = '';
var result = convert.xml2json(body, {compact: true, spaces: 4});
var petJson = JSON.parse(result)
var itemList = petJson.response.body.items;
var numRows = petJson.response.body.totalCount._text; //개수
var result = convert.xml2json(body, {compact: true, spaces: 4});
var petJson = JSON.parse(result)
//-------------------------------------------------
if (numRows == 1){
// state 정상인 것만 추리기
if (itemList.item.state._text == '정상'){
var itemList = petJson.response.body.items;
var numRows = petJson.response.body.totalCount._text; //개수
if (numRows == 1){
appliance_list.push(itemList.item);
}
}
else if (numRows == 0){}
else {
for (i=0; i<numRows; i++){
// state 정상인 것만 추리기
if (itemList.item[i].state._text == '정상'){
else if (numRows == 0){}
else {
for (i=0; i<numRows; i++){
appliance_list.push(itemList.item[i]);
}
}
//테스트용 console.log
for(i=0; i<appliance_list.length; i++){
titles = titles+appliance_list[i].title._text+'\n';
}
if (titles == '') {console.log('nothing');}
else {console.log(titles); }
}
//-----------------------------------------------
//테스트용 console.log
for(i=0; i<appliance_list.length; i++){
titles = titles+appliance_list[i].title._text+'\n';
}
if (titles == '') {console.log('nothing');}
else {console.log(titles); }
}
}
}
res.render('result', { category: 'park', titles: titles, appliance_list: appliance_list });
});
});
});
});
});*/
});
module.exports = router;
\ No newline at end of file
......