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
butter-studio
Commits
ab2a8d78
Commit
ab2a8d78
authored
Aug 10, 2021
by
Kim, Subin
Browse files
SearchResult Pagination 필요없음 -> 관련 기능 삭제
parent
4b0f9909
Changes
3
Hide whitespace changes
Inline
Side-by-side
client/src/components/Admin/MovieEdit.js
View file @
ab2a8d78
...
@@ -18,6 +18,7 @@ const MovieEdit = () => {
...
@@ -18,6 +18,7 @@ const MovieEdit = () => {
async
function
paginate
(
pageNum
)
{
async
function
paginate
(
pageNum
)
{
try
{
try
{
setError
(
""
)
const
{
TMDBmovies
,
totalPage
}
=
(
search
.
keyword
!==
''
)
?
await
movieApi
.
search
(
search
,
pageNum
)
:
await
movieApi
.
getAllfromTM
(
pageNum
)
const
{
TMDBmovies
,
totalPage
}
=
(
search
.
keyword
!==
''
)
?
await
movieApi
.
search
(
search
,
pageNum
)
:
await
movieApi
.
getAllfromTM
(
pageNum
)
setActivePage
(
pageNum
)
setActivePage
(
pageNum
)
setTotalPages
(
totalPage
)
setTotalPages
(
totalPage
)
...
...
client/src/components/SearchResult.js
View file @
ab2a8d78
...
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'
...
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'
import
{
useLocation
}
from
'
react-router-dom
'
import
{
useLocation
}
from
'
react-router-dom
'
import
queryString
from
'
query-string
'
import
queryString
from
'
query-string
'
import
MovieCard
from
"
./MovieCard/index.js
"
import
MovieCard
from
"
./MovieCard/index.js
"
import
Pagination
from
"
./Pagination.js
"
;
import
movieApi
from
'
../apis/movie.api.js
'
import
movieApi
from
'
../apis/movie.api.js
'
import
catchErrors
from
'
../utils/catchErrors.js
'
import
catchErrors
from
'
../utils/catchErrors.js
'
...
@@ -18,8 +19,8 @@ const SearchResult = () => {
...
@@ -18,8 +19,8 @@ const SearchResult = () => {
async
function
findforKeyword
()
{
async
function
findforKeyword
()
{
try
{
try
{
setError
(
""
)
setError
(
""
)
const
{
count
,
results
}
=
await
movieApi
.
search
({
type
:
"
home
"
,
keyword
:
title
})
const
res
=
await
movieApi
.
search
({
type
:
"
home
"
,
keyword
:
title
})
setResult
(
[...
results
]
)
setResult
(
res
)
}
catch
(
error
)
{
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
...
...
server/controllers/movie.controller.js
View file @
ab2a8d78
...
@@ -97,8 +97,6 @@ const getMovieById = async (req, res) => {
...
@@ -97,8 +97,6 @@ const getMovieById = async (req, res) => {
}
}
const
getMovieList
=
async
(
req
,
res
)
=>
{
const
getMovieList
=
async
(
req
,
res
)
=>
{
const
{
category
}
=
req
.
params
// console.log(category)
try
{
try
{
const
{
category
}
=
req
.
params
const
{
category
}
=
req
.
params
const
movieList
=
await
Movie
.
findAll
()
const
movieList
=
await
Movie
.
findAll
()
...
@@ -178,15 +176,15 @@ const findonlyTitle = async (req, res) => {
...
@@ -178,15 +176,15 @@ const findonlyTitle = async (req, res) => {
try
{
try
{
const
{
keyword
}
=
req
.
query
const
{
keyword
}
=
req
.
query
const
movieIds
=
[]
const
movieIds
=
[]
const
{
count
,
rows
}
=
await
Movie
.
findA
ndCountA
ll
({
const
findAll
=
await
Movie
.
findAll
({
where
:
{
where
:
{
title
:
{
title
:
{
[
Op
.
substring
]:
keyword
[
Op
.
substring
]:
keyword
}
}
}
}
});
});
if
(
rows
)
{
if
(
findAll
)
{
rows
.
forEach
(
movie
=>
movieIds
.
push
(
movie
.
movieId
))
findAll
.
forEach
(
movie
=>
movieIds
.
push
(
movie
.
movieId
))
const
elements
=
await
Promise
.
all
(
const
elements
=
await
Promise
.
all
(
movieIds
.
map
(
async
(
movieId
)
=>
{
movieIds
.
map
(
async
(
movieId
)
=>
{
const
movie
=
await
axios
.
get
(
`https://api.themoviedb.org/3/movie/
${
movieId
}
?api_key=
${
process
.
env
.
TMDB_APP_KEY
}
&language=ko-KR`
)
const
movie
=
await
axios
.
get
(
`https://api.themoviedb.org/3/movie/
${
movieId
}
?api_key=
${
process
.
env
.
TMDB_APP_KEY
}
&language=ko-KR`
)
...
@@ -200,8 +198,8 @@ const findonlyTitle = async (req, res) => {
...
@@ -200,8 +198,8 @@ const findonlyTitle = async (req, res) => {
return
{
...
movie
.
data
,
ticket_sales
:
cols
.
ticket_sales
,
vote_average
:
cols
.
vote_average
,
totalReservationRate
:
totalReservationRate
[
0
]
}
return
{
...
movie
.
data
,
ticket_sales
:
cols
.
ticket_sales
,
vote_average
:
cols
.
vote_average
,
totalReservationRate
:
totalReservationRate
[
0
]
}
})
})
)
)
return
res
.
json
(
{
count
:
movieIds
.
length
,
results
:
elements
}
)
return
res
.
json
(
elements
)
}
else
return
res
.
json
(
{
count
:
count
,
results
:
rows
}
)
}
else
return
res
.
json
(
findAll
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
영화 검색 중 에러 발생
"
);
return
res
.
status
(
500
).
send
(
error
.
message
||
"
영화 검색 중 에러 발생
"
);
}
}
...
...
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