Eunsu486

Merge branch 'eunsu' into 'master'

Modify list error

Merge From eunsu into master

See merge request !4
......@@ -21,7 +21,7 @@ router.post('/', function (req, res) {
router.get('/hospital', function (req, res) {
//api
var gu_select_encode = urlencode(gu_select);
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=%EB%8F%99%EB%AC%BC%EB%B3%91%EC%9B%90&where=${gu_select_encode}`;
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=200&pageNo=1&keyword=%EB%8F%99%EB%AC%BC%EB%B3%91%EC%9B%90&where=${gu_select_encode}`;
request(pet_url, function (err, response, body) {
if (err) {
console.log(`err => ${err}`)
......@@ -32,13 +32,22 @@ router.get('/hospital', 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 = itemList.item.length; //개수
var numRows = petJson.response.body.totalCount._text; //개수
if (numRows == 1) {
// state 정상인 것만 추리기
if (itemList.item.state._text == '정상') {
hospital_list.push(itemList.item);
}
}
else if (numRows == 0) { }
else {
for (i = 0; i < numRows; i++) {
// state 정상인 것만 추리기
if (itemList.item[i].state._text == '정상') {
hospital_list.push(itemList.item[i]);
}
}
}
//테스트용 console.log
var titles = '';
for (i = 0; i < hospital_list.length; i++) {
......@@ -56,7 +65,7 @@ router.get('/medicine', function (req, res) {
var gu_select_encode = urlencode(gu_select);
var menu = '동물약국';
var menu_encode = urlencode(menu);
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`;
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=200&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`;
request(pet_url, function (err, response, body) {
if (err) {
console.log(`err => ${err}`)
......@@ -67,13 +76,22 @@ router.get('/medicine', 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 = itemList.item.length; //개수
var numRows = petJson.response.body.totalCount._text; //개수
if (numRows == 1) {
// state 정상인 것만 추리기
if (itemList.item.state._text == '정상') {
category_list.push(itemList.item);
}
}
else if (numRows == 0) { }
else {
for (i = 0; i < numRows; i++) {
// state 정상인 것만 추리기
if (itemList.item[i].state._text == '정상') {
category_list.push(itemList.item[i]);
}
}
}
//테스트용 console.log
var titles = '';
for (i = 0; i < category_list.length; i++) {
......@@ -91,7 +109,7 @@ router.get('/appliance', function (req, res) {
var gu_select_encode = urlencode(gu_select);
var menu = '동물의료기기';
var menu_encode = urlencode(menu);
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`;
let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=200&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`;
request(pet_url, function (err, response, body) {
if (err) {
console.log(`err => ${err}`)
......
<h4>🌳 도시공원 현황</h4>
<h4>🌳 체육시설 현황</h4>
<table class="table">
<thead class="thead-dark">
<tr>
<th>도시공원명</th>
<th>체육시설명</th>
<th>도로명주소</th>
</tr>
</thead>
......@@ -20,6 +20,6 @@
</tbody>
</table>
<p class="sum">총 도시공원 개수 :
<p class="sum">총 체육시설 개수 :
<%=appliance_list.length%>
</p>
\ No newline at end of file
......