Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
search-page
Commits
52aff595
Commit
52aff595
authored
Jan 25, 2021
by
Lee SeoYeon
Browse files
..
parent
f81deda0
Changes
4
Show whitespace changes
Inline
Side-by-side
server/controllers/place.controller.js
View file @
52aff595
import
Places
from
'
../models/Place.js
'
import
cheerio
from
'
cheerio
'
import
fs
from
'
fs
'
//
import fs from 'fs'
import
axios
from
'
axios
'
;
const
searchPlace
=
async
(
req
,
res
)
=>
{
...
...
@@ -37,7 +37,7 @@ const searchImg = async (req, res) => {
let
DuplicateCheckImg
=
await
Places
.
findOne
({
name
:
req
.
query
.
keyword
})
if
(
DuplicateCheckImg
)
{
if
(
DuplicateCheckImg
.
img
!==
"
https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd
"
)
{
res
.
send
(
DuplicateCheckImg
)
console
.
log
(
"
333333333333333333333333333IMG@@@@@@@@@@@@@@@@@@@ 기존이미지줄력중
"
)
...
...
@@ -52,22 +52,20 @@ const searchImg = async (req, res) => {
let
name
=
req
.
query
.
keyword
let
$1
=
cheerio
.
load
(
html
);
axios
.
get
(
imgUrl
)
.
then
(
async
(
response
)
=>
{
const
html
=
response
.
data
let
name
=
req
.
query
.
keyword
let
$1
=
cheerio
.
load
(
html
);
let
images
=
$1
(
'
.RAyV4b
'
).
find
(
'
img
'
).
attr
(
'
src
'
)
//사진만 업데이트
let
Place
=
await
Places
.
findOne
({
name
:
req
.
query
.
keyword
})
Place
.
times
.
push
(
new
Date
().
toLocaleString
())
await
Places
.
updateOne
({
name
:
req
.
query
.
keyword
},
{
img
:
images
,
times
:
Place
.
times
})
res
.
send
(
images
)
})
}
else
{
console
.
log
(
"
IMG에러
"
)
}
}
...
...
@@ -79,13 +77,12 @@ const searchAssociation = async (req, res) => {
// if (!Place) {
// res.send([])
// }
if
(
!
Place
)
{
res
.
status
(
404
).
send
({
error
:
"
Place.address is null
"
})
}
else
{
let
addresse
=
Place
.
address
.
split
(
'
'
)[
0
]
let
AssociationsId
=
[]
let
addressPlaces
=
new
RegExp
(
`
${
addresse
}
`
)
let
responsePlaces
=
await
Places
.
find
({
address
:
addressPlaces
})
res
.
send
(
responsePlaces
)
let
AssociationsId
=
[]
let
addressPlaces
=
new
RegExp
(
`
${
addresse
}
`
)
console
.
log
(
"
여기보세요
"
,
addressPlaces
)
...
...
server/controllers/user.controller.js
View file @
52aff595
...
...
@@ -46,6 +46,24 @@ const userById = async (req, res, next, id) => {
}
}
const
getBookmark
=
async
(
req
,
res
)
=>
{
const
{
page
,
userId
}
=
req
.
body
req
.
body
=
page
console
.
log
(
'
page:
'
,
page
)
req
.
user
=
userId
console
.
log
(
'
userId:
'
,
userId
)
await
User
.
updateOne
({
'
userId
'
:
userId
},
{
'
bookmark
'
:
page
})
const
updatedUser
=
await
user
.
save
()
res
.
json
(
updatedUser
)
}
// const putBookmark = async (req, res) => {
// const newBookmark = new Bookmark ({
// bookmark,
// }).save()
// console.log(newBookmark)
// res.json(newBookmark)
// }
// const bookMark = async (req, res) => {
// const {title, url} = req.body
// console.log(title, url)
...
...
@@ -60,4 +78,4 @@ const userById = async (req, res, next, id) => {
// }
// }
export
default
{
signup
,
userById
}
\ No newline at end of file
export
default
{
signup
,
userById
,
getBookmark
}
\ No newline at end of file
server/routes/review.routes.js
View file @
52aff595
import
express
from
'
express
'
import
review
from
'
.
./controllers/review.controller.js
'
import
review
from
'
../controllers/review.controller.js
'
const
router
=
express
.
Router
()
...
...
server/routes/user.routes.js
View file @
52aff595
import
express
from
"
express
"
import
userCtrl
from
"
../controllers/user.controller.js
"
import
userCtrl
from
'
../controllers/user.controller.js
'
const
router
=
express
.
Router
()
router
.
route
(
'
/api/users/signup
'
)
.
post
(
userCtrl
.
signup
)
router
.
route
(
'
/api/users/bookmark
'
)
.
post
(
userCtrl
.
getBookmark
)
// .get(userCtrl.putBookmark)
router
.
param
(
'
userId
'
,
userCtrl
.
userById
)
// router.route('/api/users/bookmark')
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment