Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김동훈
/
OpenSource_Project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
1
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Donghoon Kim
2018-12-14 08:51:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ab12ccabfba6fc4b8bf40ea39b1a3ec4e19a762a
ab12ccab
1 parent
80842acd
major bug fix #3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1 additions
and
119 deletions
mysql.js
public/Entertainment.html
public/index.html
api/getPlaceList.js → public/js/getPlaceList.js
routes/index.js
mysql.js
deleted
100644 → 0
View file @
80842ac
const
mysql
=
require
(
'promise-mysql'
)
module
.
exports
=
mysql
.
createConnection
({
host
:
"52.79.82.27"
,
user
:
"root"
,
password
:
"oss"
,
database
:
"OSS"
})
public/Entertainment.html
View file @
ab12cca
public/index.html
View file @
ab12cca
...
...
@@ -93,7 +93,7 @@
var
result_food
=
[]
var
result_room
=
[]
</script>
<script
type=
"text/javascript"
src=
"/js/getPlaceList.js"
></script>
<script
type=
"text/javascript"
src=
"
.
/js/getPlaceList.js"
></script>
<div
id=
"map"
></div>
<script
src=
"https://maps.googleapis.com/maps/api/js?key=AIzaSyDg4CkUEEt_96n1ork1nL5t4E_SpdKrgMI&libraries=places&callback=initMap"
async
defer
></script>
...
...
api
/getPlaceList.js
→
public/js
/getPlaceList.js
View file @
ab12cca
...
...
@@ -19,12 +19,6 @@ function initMap() {
lng
:
position
.
coords
.
longitude
};
var
map
=
new
google
.
maps
.
Map
(
document
.
getElementById
(
'map'
),
{
center
:
pos
,
zoom
:
17
});
infowindow
=
new
google
.
maps
.
InfoWindow
();
map
.
setCenter
(
pos
);
service
=
new
google
.
maps
.
places
.
PlacesService
(
map
);
...
...
@@ -44,20 +38,6 @@ function initMap() {
searchPlace
(
'zoo'
,
'entertainment'
);
searchPlace
(
'lodging'
,
'room'
);
// put data to db
for
(
var
i
=
0
;
i
<
results_food
.
length
;
i
++
)
{
//putDataToDB(results_food[i], 'food')
console
.
log
(
results_food
[
i
])
}
for
(
var
i
=
0
;
i
<
results_entertainment
.
length
;
i
++
)
{
//putDataToDB(results_entertainment[i], 'entertainment')
console
.
log
(
results_entertainment
[
i
])
}
for
(
var
i
=
0
;
i
<
results_room
.
length
;
i
++
)
{
//putDataToDB(results_room[i], 'room')
console
.
log
(
results_room
[
i
])
}
});
}
}
...
...
@@ -95,7 +75,6 @@ function searchPlace(str, placeType) {
function
callback_foods
(
results
,
status
)
{
if
(
status
===
google
.
maps
.
places
.
PlacesServiceStatus
.
OK
)
{
for
(
var
i
=
0
;
i
<
results
.
length
;
i
++
)
{
putDataToDB
(
results
[
i
],
'food'
)
createMarker_foods
(
results
[
i
]);
}
}
...
...
@@ -104,7 +83,6 @@ function callback_foods(results, status) {
function
callback_entertainment
(
results
,
status
)
{
if
(
status
===
google
.
maps
.
places
.
PlacesServiceStatus
.
OK
)
{
for
(
var
i
=
0
;
i
<
results
.
length
;
i
++
)
{
putDataToDB
(
results
[
i
],
'entertainment'
)
createMarker_entertainment
(
results
[
i
]);
}
}
...
...
@@ -113,7 +91,6 @@ function callback_entertainment(results, status) {
function
callback_rooms
(
results
,
status
)
{
if
(
status
===
google
.
maps
.
places
.
PlacesServiceStatus
.
OK
)
{
for
(
var
i
=
0
;
i
<
results
.
length
;
i
++
)
{
putDataToDB
(
results
[
i
],
'room'
)
createMarker_rooms
(
results
[
i
]);
}
}
...
...
@@ -160,81 +137,3 @@ function createMarker_rooms(place) {
infowindow
.
open
(
map
,
this
);
});
}
function
putDataToDB
(
result
,
category1
)
{
const
id
=
result
[
'id'
];
const
place_id
=
result
[
'place_id'
];
const
name
=
result
[
'name'
];
const
address
=
result
[
'vicinity'
];
let
category_big
=
category1
const
category_small
=
result
.
types
[
0
];
const
image
=
"default"
const
rating
=
result
.
rating
;
const
lng
=
result
.
geometry
.
viewport
.
ea
.
j
;
const
lat
=
result
.
geometry
.
viewport
.
la
.
j
;
if
(
rating
==
null
)
{
rating
=
0
;
}
const
QueryCheck
=
()
=>
{
if
(
!
id
||
!
place_id
||
!
name
||
!
address
||
!
category_big
||
!
category_small
||
!
image
||
!
rating
||
!
lng
||
!
lat
)
{
return
Promise
.
reject
({
message
:
'Query Error'
})
}
return
Promise
.
resolve
()
}
// 2. SQL Start
const
SQLStart
=
async
(
pool
)
=>
{
try
{
let
data
=
await
pool
.
query
(
'INSERT INTO PLACE(ID, PLACE_ID, NAME, ADDRESS, CATEGORY_BIG, CATEGORY_SMALL, IMAGE, RATING, LNG, LAT) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);'
,
[
id
,
place_id
,
name
,
address
,
category_big
,
category_small
,
image
,
rating
,
lng
,
lat
])
return
Promise
.
resolve
(
pool
)
}
catch
(
err
)
{
return
Promise
.
reject
(
err
)
}
}
// 3. Response
const
Response
=
(
rows
)
=>
{
return
res
.
status
(
200
).
json
(
rows
)
}
// 1. Query Check
const
FindQueryCheck
=
()
=>
{
if
(
!
id
)
{
return
Promise
.
reject
({
message
:
'Query Error'
})
}
else
return
pool
}
// 2. SQL Start
const
FindSQLStart
=
(
pool
)
=>
{
return
pool
.
query
(
'SELECT * FROM PLACE WHERE ID LIKE '
+
id
.
toString
())
}
// 3. Response
const
FindResponse
=
(
rows
)
=>
{
return
res
.
status
(
200
).
json
(
rows
)
}
if
([]
==
FindQueryCheck
()
.
then
(
FindSQLStart
)
.
then
(
FindResponse
)
.
catch
(
err
=>
{
if
(
err
)
{
return
res
.
status
(
500
).
json
(
err
.
message
||
err
)
}
}))
{
QueryCheck
()
.
then
(
SQLStart
)
.
then
(
Response
)
.
catch
(
err
=>
{
if
(
err
)
{
return
res
.
status
(
500
).
json
(
err
.
message
||
err
)
}
})
}
}
...
...
routes/index.js
deleted
100644 → 0
View file @
80842ac
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
/* GET home page. */
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
res
.
render
(
'index'
,
{
title
:
'Express'
});
});
module
.
exports
=
router
;
Please
register
or
login
to post a comment