Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source-group1
/
animal-Info
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Eunsu486
2021-06-01 20:56:27 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b21330836820eecad0c9eb1977daa85947974b3c
b2133083
1 parent
3629b820
Modify input function
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
routes/category.js
routes/category.js
View file @
b213308
...
...
@@ -15,14 +15,12 @@ router.post('/', function (req, res) {
var
body
=
req
.
body
;
gu_select
=
body
.
user_gu
;
console
.
log
(
gu_select
);
res
.
send
(
'Good'
);
});
//동물병원 함수
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
}
`
;
request
(
pet_url
,
function
(
err
,
response
,
body
)
{
if
(
err
)
{
...
...
@@ -52,15 +50,12 @@ router.get('/hospital', function (req, res) {
}
})
});
//동물약국
router
.
get
(
'/medicine'
,
function
(
req
,
res
)
{
//api
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
}
`
;
request
(
pet_url
,
function
(
err
,
response
,
body
)
{
if
(
err
)
{
...
...
@@ -90,15 +85,12 @@ router.get('/medicine', function (req, res) {
}
})
});
//의료기기
router
.
get
(
'/appliance'
,
function
(
req
,
res
)
{
//api
var
gu_select_encode
=
urlencode
(
gu_select
);
var
menu
=
'동물의료기기
판매및임대업체
'
;
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
}
`
;
request
(
pet_url
,
function
(
err
,
response
,
body
)
{
if
(
err
)
{
...
...
@@ -106,40 +98,48 @@ router.get('/appliance', function (req, res) {
}
else
{
if
(
res
.
statusCode
==
200
)
{
let
category
_list
=
[];
let
appliance
_list
=
[];
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
++
)
{
var
numRows
=
petJson
.
response
.
body
.
totalCount
.
_text
;
//개수
if
(
numRows
==
1
)
{
// state 정상인 것만 추리기
if
(
itemList
.
item
[
i
].
state
.
_text
==
'정상'
)
{
category_list
.
push
(
itemList
.
item
[
i
]);
if
(
itemList
.
item
.
state
.
_text
==
'정상'
)
{
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
]);
}
}
}
//테스트용 console.log
var
titles
=
''
;
for
(
i
=
0
;
i
<
category
_list
.
length
;
i
++
)
{
titles
=
titles
+
category
_list
[
i
].
title
.
_text
+
'\n'
;
for
(
i
=
0
;
i
<
appliance
_list
.
length
;
i
++
)
{
titles
=
titles
+
appliance
_list
[
i
].
title
.
_text
+
'\n'
;
}
console
.
log
(
titles
);
res
.
render
(
'result'
,
{
category
:
'appliance'
,
titles
:
titles
,
category_list
:
category
_list
});
res
.
render
(
'result'
,
{
category
:
'appliance'
,
titles
:
titles
,
appliance_list
:
appliance
_list
});
}
}
})
});
//체육시설
router
.
post
(
'/park'
,
function
(
req
,
res
)
{
router
.
get
(
'/park'
,
function
(
req
,
res
)
{
var
gu_select_encode
=
urlencode
(
gu_select
);
var
menu
=
[
"생활체육관"
,
"학교체육시설"
,
"풋살장"
,
"축구장"
];
// encoding for url
var
menu_encode
=
[];
for
(
var
j
=
0
;
j
<
menu
.
length
;
j
++
)
{
menu_encode
[
j
]
=
urlencode
(
menu
[
j
]);
}
var
gu_select_encode
=
urlencode
(
gu_select
);
//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
}
`
;
request
(
pet_url
,
function
(
err
,
response
,
body
)
{
...
...
Please
register
or
login
to post a comment