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-05-25 15:46:18 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
f7dd71ef3d5a5e0a7954ef3f6712eeba342ffcc5
f7dd71ef
2 parents
d02379cb
47354b48
Merge branch 'eunsu' into 'master'
Modify category.js See merge request
!2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
26 deletions
routes/category.js
routes/category.js
View file @
f7dd71e
...
...
@@ -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`
;
request
({
url
:
library_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
];
if
(
userArea
(
library
,
'REFINE_LOTNO_ADDR'
,
user_target
))
{
librarys
.
push
(
library
);
}
}
library_grade
=
evalGrade
(
library_A
,
0.5
,
librarys
.
length
);
let
qs
=
`?serviceKey=
${
ANIMAL_INFO_API_KEY
}
&numOfRows=10&pageNo=2&keyword=동물병원
&where=
${
user_gu
}
`
;
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
);
}
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
))
{
hospitals
.
push
(
library
);
}
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
...
...
Please
register
or
login
to post a comment