Eunsu486

Merge branch 'master'

...@@ -21,7 +21,7 @@ router.post('/', function (req, res) { ...@@ -21,7 +21,7 @@ router.post('/', function (req, res) {
21 router.get('/hospital', function (req, res) { 21 router.get('/hospital', function (req, res) {
22 //api 22 //api
23 var gu_select_encode = urlencode(gu_select); 23 var gu_select_encode = urlencode(gu_select);
24 - 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}`; 24 + 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}`;
25 request(pet_url, function (err, response, body) { 25 request(pet_url, function (err, response, body) {
26 if (err) { 26 if (err) {
27 console.log(`err => ${err}`) 27 console.log(`err => ${err}`)
...@@ -32,11 +32,20 @@ router.get('/hospital', function (req, res) { ...@@ -32,11 +32,20 @@ router.get('/hospital', function (req, res) {
32 var result = convert.xml2json(body, { compact: true, spaces: 4 }); 32 var result = convert.xml2json(body, { compact: true, spaces: 4 });
33 var petJson = JSON.parse(result) 33 var petJson = JSON.parse(result)
34 var itemList = petJson.response.body.items; 34 var itemList = petJson.response.body.items;
35 - var numRows = itemList.item.length; //개수 35 + var numRows = petJson.response.body.totalCount._text; //개수
36 - for (i = 0; i < numRows; i++) { 36 + if (numRows == 1) {
37 // state 정상인 것만 추리기 37 // state 정상인 것만 추리기
38 - if (itemList.item[i].state._text == '정상') { 38 + if (itemList.item.state._text == '정상') {
39 - hospital_list.push(itemList.item[i]); 39 + hospital_list.push(itemList.item);
40 + }
41 + }
42 + else if (numRows == 0) { }
43 + else {
44 + for (i = 0; i < numRows; i++) {
45 + // state 정상인 것만 추리기
46 + if (itemList.item[i].state._text == '정상') {
47 + hospital_list.push(itemList.item[i]);
48 + }
40 } 49 }
41 } 50 }
42 //테스트용 console.log 51 //테스트용 console.log
...@@ -56,7 +65,7 @@ router.get('/medicine', function (req, res) { ...@@ -56,7 +65,7 @@ router.get('/medicine', function (req, res) {
56 var gu_select_encode = urlencode(gu_select); 65 var gu_select_encode = urlencode(gu_select);
57 var menu = '동물약국'; 66 var menu = '동물약국';
58 var menu_encode = urlencode(menu); 67 var menu_encode = urlencode(menu);
59 - 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}`; 68 + 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}`;
60 request(pet_url, function (err, response, body) { 69 request(pet_url, function (err, response, body) {
61 if (err) { 70 if (err) {
62 console.log(`err => ${err}`) 71 console.log(`err => ${err}`)
...@@ -67,11 +76,20 @@ router.get('/medicine', function (req, res) { ...@@ -67,11 +76,20 @@ router.get('/medicine', function (req, res) {
67 var result = convert.xml2json(body, { compact: true, spaces: 4 }); 76 var result = convert.xml2json(body, { compact: true, spaces: 4 });
68 var petJson = JSON.parse(result) 77 var petJson = JSON.parse(result)
69 var itemList = petJson.response.body.items; 78 var itemList = petJson.response.body.items;
70 - var numRows = itemList.item.length; //개수 79 + var numRows = petJson.response.body.totalCount._text; //개수
71 - for (i = 0; i < numRows; i++) { 80 + if (numRows == 1) {
72 // state 정상인 것만 추리기 81 // state 정상인 것만 추리기
73 - if (itemList.item[i].state._text == '정상') { 82 + if (itemList.item.state._text == '정상') {
74 - category_list.push(itemList.item[i]); 83 + category_list.push(itemList.item);
84 + }
85 + }
86 + else if (numRows == 0) { }
87 + else {
88 + for (i = 0; i < numRows; i++) {
89 + // state 정상인 것만 추리기
90 + if (itemList.item[i].state._text == '정상') {
91 + category_list.push(itemList.item[i]);
92 + }
75 } 93 }
76 } 94 }
77 //테스트용 console.log 95 //테스트용 console.log
...@@ -91,7 +109,7 @@ router.get('/appliance', function (req, res) { ...@@ -91,7 +109,7 @@ router.get('/appliance', function (req, res) {
91 var gu_select_encode = urlencode(gu_select); 109 var gu_select_encode = urlencode(gu_select);
92 var menu = '동물의료기기'; 110 var menu = '동물의료기기';
93 var menu_encode = urlencode(menu); 111 var menu_encode = urlencode(menu);
94 - 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}`; 112 + 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}`;
95 request(pet_url, function (err, response, body) { 113 request(pet_url, function (err, response, body) {
96 if (err) { 114 if (err) {
97 console.log(`err => ${err}`) 115 console.log(`err => ${err}`)
......
1 -<h4>🌳 도시공원 현황</h4> 1 +<h4>🌳 체육시설 현황</h4>
2 <table class="table"> 2 <table class="table">
3 <thead class="thead-dark"> 3 <thead class="thead-dark">
4 <tr> 4 <tr>
5 - <th>도시공원명</th> 5 + <th>체육시설명</th>
6 <th>도로명주소</th> 6 <th>도로명주소</th>
7 </tr> 7 </tr>
8 </thead> 8 </thead>
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
20 20
21 </tbody> 21 </tbody>
22 </table> 22 </table>
23 -<p class="sum">총 도시공원 개수 : 23 +<p class="sum">총 체육시설 개수 :
24 <%=appliance_list.length%> 24 <%=appliance_list.length%>
25 </p> 25 </p>
...\ No newline at end of file ...\ No newline at end of file
......