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
2c820a72
Commit
2c820a72
authored
Jan 25, 2021
by
Lee SeoYeon
Browse files
.
parent
2eb0844a
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
client/.eslintcache
View file @
2c820a72
This diff is collapsed.
Click to expand it.
client/src/Bookmark.js
View file @
2c820a72
...
...
@@ -6,7 +6,7 @@ import { isAuthenticated } from './utils/auth'
const
INIT_PAGE
=
{
bookmark
:
[
'
성산일출봉
'
,
'
제주도
'
,
'
한라산
'
,
'
주상절리
'
,
'
오설록 티 뮤지엄
'
]
,
bookmark
:
[
'
성산일출봉
'
,
'
제주도
'
,
'
한라산
'
,
'
주상절리
'
,
'
오설록 티 뮤지엄
'
,
]
}
...
...
@@ -22,13 +22,14 @@ function Bookmark() {
const
userId
=
localStorage
.
getItem
(
'
loginStatus
'
)
async
function
getBookmark
(
)
{
async
function
getBookmark
()
{
try
{
setError
(
''
)
console
.
log
(
page
)
console
.
log
(
page
.
bookmark
)
const
bookmark
=
page
.
bookmark
console
.
log
(
userId
)
await
axios
.
p
os
t
(
`/api/users/bookmark`
,
{
bookmark
:
page
,
userId
:
userId
})
const
response
=
await
axios
.
p
u
t
(
`/api/users/bookmark`
,
{
bookmark
:
bookmark
,
userId
:
userId
})
console
.
log
(
response
.
data
)
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
...
...
client/src/Pages/Search.js
deleted
100644 → 0
View file @
2eb0844a
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
ohuh
from
'
../ohuh-sm.PNG
'
;
import
Place
from
'
../Components/Place
'
;
import
{
Container
,
Form
,
Row
,
Col
,
Card
,
Image
,
InputGroup
,
FormControl
,
Button
}
from
'
react-bootstrap
'
;
import
Paginations
from
'
../Components/Paginations
'
;
import
axios
from
'
axios
'
;
import
queryString
from
'
query-string
'
function
Search
(
props
)
{
const
endPage
=
10
;
const
[
state
,
setState
]
=
useState
(
false
);
const
[
index
,
setIndex
]
=
useState
(
1
);
const
[
showSet
,
setShowSet
]
=
useState
([
false
,
false
,
false
,
false
]);
const
[
search
,
setSearch
]
=
useState
(
queryString
.
parse
(
props
.
location
.
search
).
keyword
);
const
[
mobile
,
setMobile
]
=
useState
();
const
[
place
,
setPlace
]
=
useState
([{
name
:
""
,
category
:
""
,
address
:
""
}])
const
[
imgUrl
,
setImgUrl
]
=
useState
([])
const
[
association
,
setAssociation
]
=
useState
([])
// console.log("search###############", search)
const
getPlace
=
()
=>
{
axios
.
get
(
`/api/search/places?keyword=
${
search
}
`
)
.
then
(
res
=>
{
console
.
log
(
"
places=
"
,
res
.
data
)
setPlace
(
res
.
data
)
})
.
catch
(
err
=>
{
console
.
log
(
'
search.places 에러 발생
'
,
err
)
})
}
const
getImg
=
()
=>
{
axios
.
get
(
`/api/search/imges?keyword=
${
search
}
`
)
.
then
(
res
=>
{
console
.
log
(
"
images=
"
,
res
.
data
)
setImgUrl
(
res
.
data
)
})
.
catch
(
err
=>
{
console
.
log
(
'
search.images 에러 발생
'
,
err
)
})
}
const
getAssociation
=
()
=>
{
axios
.
get
(
`/api/search/association?keyword=
${
search
}
`
)
.
then
(
res
=>
{
console
.
log
(
"
Associations =
"
,
res
.
data
)
setAssociation
(
res
.
data
)
})
.
catch
(
err
=>
{
console
.
log
(
"
search.associations 에러 발생
"
,
err
)
})
}
useEffect
(()
=>
{
getPlace
()
getImg
()
getAssociation
()
if
(
window
.
innerWidth
<
960
)
{
setMobile
(
true
)
}
else
{
setMobile
(
false
)
}
if
(
state
)
{
props
.
history
.
push
(
'
/search?keyword=
'
+
search
)
setState
(
false
)
console
.
log
(
"
search야
"
,
search
)
}
},
[
search
]);
const
places
=
[{
name
:
"
한라산
"
,
address
:
"
제주 서귀포시 토평동 산15-1
"
,
img
:
"
https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg/269px-KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg?size=200x200
"
,
},
{
name
:
"
성산일출봉(sungsan)
"
,
address
:
"
제주 서귀포시 성산읍 성산리 1
"
,
img
:
"
https://www.jeju.go.kr/pub/site/geopark/images/sub/sub03/02%EC%A7%80%EC%A7%88%EB%A7%88%EC%9D%84%EC%9D%B4%EC%95%BC%EA%B8%B0/%EC%A7%80%EC%A7%88%EB%A7%88%EC%9D%84/%EC%A7%80%EC%A7%88%EB%A7%88%EC%9D%84_%EC%84%B1%EC%82%B0%EC%9D%BC%EC%B6%9C%EB%B4%89/1412402261.jpg?400/400
"
,
},
{
name
:
"
해녀의 집(haenyeo)
"
,
address
:
"
제주 서귀포시 성산읍 한도로 141-13지번오조리 3 오조해녀의집
"
,
img
:
"
https://mblogthumb-phinf.pstatic.net/MjAxNjExMTdfMTc0/MDAxNDc5MzU3ODU0ODQy.KZYXCjzsXT3rCsE4HXBfxyCg2buvluBvN_7NxVp7BSwg.loJc89d8JjGXdNCn-4yMd7aMWPjfrZn21TI9Hyzemkog.JPEG.icocam11/20161010_100205.jpg?type=w800
"
,
},
{
name
:
"
오설록 티 뮤지엄(osulloc)
"
,
address
:
"
제주 서귀포시 안덕면 신화역사로 15 오설록지번서광리 1235-1 오설록
"
,
img
:
"
https://cdnweb01.wikitree.co.kr/webdata/editor/202007/01/img_20200701143323_2ced7627.webp
"
,
},
{
name
:
"
오설록 티 뮤지엄(osulloc)
"
,
address
:
"
제주 서귀포시 안덕면 신화역사로 15 오설록지번서광리 1235-1 오설록
"
,
img
:
"
https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg/269px-KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg
"
,
}]
if
(
state
!==
false
)
{
// console.log(queryString.parse(props.location.search))
// = {keyword:search}
// return <Redirect to={{
// pathname: `/search?keyword=${search}`,
// state: { id: search },
// }} />;
// history.pushState(null, null, "?"+queryParams.toString());
// return <Redirect to={`/search?keyword=${search}`} />;
}
const
handlePage
=
(
num
)
=>
{
setIndex
(
num
);
}
const
handleChange
=
(
e
)
=>
{
setSearch
(
e
.
target
.
value
);
}
const
handleSubmit
=
(
e
)
=>
{
// e.preventDefault()
setState
(
true
);
}
function
paginate
(
items
,
pageNumber
,
itemNumber
)
{
const
page
=
[];
const
startIndex
=
(
pageNumber
-
1
)
*
itemNumber
for
(
var
i
=
0
;
i
<
itemNumber
;
i
++
)
{
page
.
push
(
items
[(
startIndex
+
i
)])
}
return
page
}
const
pagePlace
=
paginate
(
association
,
index
,
association
.
length
)
let
time
=
new
Date
()
return
(
<
Container
>
<
Link
to
=
"
/
"
className
=
"
d-flex justify-content-center
"
><
Image
src
=
{
ohuh
}
/></
Link
>
<
Row
className
=
"
mb-2
"
className
=
"
d-flex justify-content-center
"
>
<
Form
style
=
{{
width
:
"
90vw
"
}}
onSubmit
=
{
handleSubmit
}
>
<
InputGroup
size
=
"
lg
"
>
<
FormControl
placeholder
=
"
검색어를 입력하세요.
"
value
=
{
search
}
aria
-
label
=
"
Large
"
aria
-
describedby
=
"
inputGroup-sizing-sm
"
onChange
=
{
handleChange
}
/
>
<
InputGroup
.
Append
>
<
Button
type
=
"
submit
"
variant
=
"
outline-secondary
"
>
검색
<
/Button
>
<
/InputGroup.Append
>
<
/InputGroup
>
<
/Form
>
<
/Row
>
{
time
.
toLocaleString
()}
<
Row
className
=
"
d-flex flex-wrap
"
>
{
pagePlace
.
map
((
place
,
index
)
=>
{
return
(
<
Col
key
=
{
index
}
md
=
{
6
}
>
<
Card
align
=
"
center
"
border
=
"
info
"
style
=
{{
margin
:
"
3%
"
}}
>
<
Card
.
Title
style
=
{{
margin
:
"
3%
"
,
fontSize
:
'
200%
'
,
fontWeight
:
'
bold
'
}}
>
{
place
.
name
}
<
/Card.Title
>
<
Card
.
Img
variant
=
"
top
"
style
=
{{
padding
:
"
5%
"
,
width
:
"
100%
"
,
height
:
"
340px
"
}}
src
=
{
place
.
img
}
/
>
<
Card
.
Body
>
<
Card
.
Text
style
=
{{
overflow
:
'
auto
'
,
fontSize
:
'
25px
'
,
width
:
'
100%
'
,
height
:
"
80px
"
}}
>
{
place
.
address
}
<
/Card.Text
>
<
Button
variant
=
"
primary
"
onClick
=
{()
=>
{
const
showArr
=
[
false
,
false
,
false
,
false
]
showArr
[
index
]
=
true
setShowSet
(
showArr
)
}}
>
{
place
.
name
}
자세히
살펴보기
<
/Button
>
<
Place
place
=
{
place
}
index
=
{
index
}
show
=
{
showSet
[
index
]}
onHide
=
{()
=>
setShowSet
([
false
,
false
,
false
,
false
])}
/
>
<
/Card.Body
>
<
/Card
>
<
/Col
>
)
})}
<
/Row
>
<
Row
className
=
"
mt-2 d-flex justify-content-center
"
>
<
Paginations
index
=
{
index
}
endPage
=
{
endPage
}
handlePage
=
{
handlePage
}
><
/Paginations
>
<
/Row
>
<
/Container
>
);
}
export
default
Search
;
\ No newline at end of file
server/controllers/user.controller.js
View file @
2c820a72
...
...
@@ -7,19 +7,19 @@ const signup = async (req, res) => {
const
{
name
,
email
,
password
}
=
req
.
body
//구조분해해서 하나씩
console
.
log
(
name
,
email
,
password
)
try
{
//적어도 3개 맥시멈 10개 가 아니면
if
(
!
isLength
(
name
,
{
min
:
3
,
max
:
10
}))
{
if
(
!
isLength
(
name
,
{
min
:
3
,
max
:
10
}))
{
return
res
.
status
(
422
).
send
(
'
이름은 3-10자 사이입니다
'
)
}
else
if
(
!
isLength
(
password
,
{
min
:
6
}))
{
}
else
if
(
!
isLength
(
password
,
{
min
:
6
}))
{
return
res
.
status
(
422
).
send
(
'
비밀번호는 6자 이상입니다
'
)
}
else
if
(
!
isEmail
(
email
))
{
}
else
if
(
!
isEmail
(
email
))
{
return
res
.
status
(
422
).
send
(
'
유효하지 않은 이메일 형식입니다
'
)
}
const
user
=
await
User
.
findOne
({
email
})
const
user
=
await
User
.
findOne
({
email
})
if
(
user
)
{
return
res
.
status
(
422
).
send
(
`
${
email
}
이 이미 사용중입니다`
)
}
const
hash
=
await
bcrypt
.
hash
(
password
,
10
)
const
newUser
=
await
new
User
({
const
newUser
=
await
new
User
({
name
,
email
,
password
:
hash
...
...
@@ -47,14 +47,21 @@ 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
{
bookmark
,
userId
}
=
req
.
body
console
.
log
(
bookmark
,
userId
)
// const bookpage = req.body.bookmark
console
.
log
(
'
page:
'
,
bookmark
)
// const user = req.user.userId
console
.
log
(
'
userId:
'
,
userId
)
const
updatedUser
=
await
User
.
findOne
({
_id
:
userId
})
if
(
updatedUser
)
{
updatedUser
.
bookmark
=
bookmark
updatedUser
.
save
()
}
// const updatedUser = await new User({ bookmark }).save()
// res.json(updatedUser)
console
.
log
(
updatedUser
)
res
.
send
(
updatedUser
)
}
// const putBookmark = async (req, res) => {
...
...
@@ -78,4 +85,4 @@ const getBookmark = async (req, res) => {
// }
// }
export
default
{
signup
,
userById
,
getBookmark
}
\ No newline at end of file
export
default
{
signup
,
userById
,
getBookmark
}
\ No newline at end of file
server/routes/user.routes.js
View file @
2c820a72
...
...
@@ -7,7 +7,7 @@ router.route('/api/users/signup')
.
post
(
userCtrl
.
signup
)
router
.
route
(
'
/api/users/bookmark
'
)
.
p
os
t
(
userCtrl
.
getBookmark
)
.
p
u
t
(
userCtrl
.
getBookmark
)
// .get(userCtrl.putBookmark)
router
.
param
(
'
userId
'
,
userCtrl
.
userById
)
...
...
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