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
bc54f42c
Commit
bc54f42c
authored
Feb 01, 2021
by
baesangjune
Browse files
커밋
parent
1bd65831
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/controllers/place.controller.js
View file @
bc54f42c
import
Places
from
'
../models/Place.js
'
import
cheerio
from
'
cheerio
'
import
fs
from
'
fs
'
import
axios
from
'
axios
'
;
import
{
nextTick
}
from
'
process
'
;
const
searchPlace
=
async
(
req
,
res
,
next
,)
=>
{
...
...
@@ -23,7 +25,9 @@ const searchPlace = async (req, res, next,) => {
})
req
.
places
=
places
}
next
()
}
const
searchImg
=
async
(
req
,
res
,
next
)
=>
{
...
...
@@ -43,32 +47,23 @@ const searchImg = async (req, res, next) => {
let
$1
=
cheerio
.
load
(
html
);
let
images
=
$1
(
'
.RAyV4b
'
).
find
(
'
img
'
).
attr
(
'
src
'
)
req
.
places
.
img
=
images
<<<<<<<
HEAD
=======
console
.
log
(
"
4141414141414141
"
,
req
.
places
)
//사진만 업데이트
// let Place2 = await Places.findOne({ name: req.query.keyword })
>>>>>>>
origin
/
cherry
req
.
places
.
times
.
push
(
new
Date
().
toLocaleString
())
const
newPlaces
=
await
new
Places
(
req
.
places
).
save
()
next
()
})
}
else
{
console
.
log
(
"
이미지 생성 오류발생!!
"
)
}
}
const
searchAssociation
=
async
(
req
,
res
)
=>
{
let
Place3
=
req
.
places
.
address
if
(
!
Place3
)
{
<<<<<<<
HEAD
=======
console
.
log
(
"
asdfasdfasdf222222222222222222dsaf2222222222214123q5
"
,
Place3
)
>>>>>>>
origin
/
cherry
res
.
send
({
error
:
"
Place.address is null
"
})
}
else
{
let
addresse
=
Place3
.
split
(
'
'
)[
0
]
let
AssociationsId
=
[]
let
addressPlaces
=
new
RegExp
(
`
${
addresse
}
`
)
let
responsePlaces
=
await
Places
.
find
({
address
:
addressPlaces
}).
sort
({
updatedAt
:
-
1
})
res
.
send
(
responsePlaces
)
...
...
@@ -76,4 +71,4 @@ const searchAssociation = async (req, res) => {
}
export
default
{
searchImg
,
searchPlace
,
searchAssociation
}
export
default
{
searchImg
,
searchPlace
,
searchAssociation
}
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