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
dd1c9aee
Commit
dd1c9aee
authored
Aug 02, 2021
by
Jiwon Yoon
Browse files
Merge branch 'kimpen'
parents
44b5a715
2135143b
Changes
16
Hide whitespace changes
Inline
Side-by-side
client/src/apis/cinema.api.js
View file @
dd1c9aee
...
@@ -16,8 +16,8 @@ const getTicketFee = async () => {
...
@@ -16,8 +16,8 @@ const getTicketFee = async () => {
return
data
return
data
}
}
const
getTicketFeeOne
=
async
(
theater
T
ype
)
=>
{
const
getTicketFeeOne
=
async
(
theater
t
ype
Id
)
=>
{
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/api/info/ticketfee/
${
theater
T
ype
}
`
)
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/api/info/ticketfee/
${
theater
t
ype
Id
}
`
)
return
data
return
data
}
}
...
@@ -26,8 +26,8 @@ const editTicketFee = async (ticketFeeInfo) => {
...
@@ -26,8 +26,8 @@ const editTicketFee = async (ticketFeeInfo) => {
return
data
return
data
}
}
const
removeTicketFee
=
async
(
theater
T
ype
)
=>
{
const
removeTicketFee
=
async
(
theater
t
ype
Id
)
=>
{
const
{
data
}
=
await
axios
.
delete
(
`
${
baseUrl
}
/api/info/ticketfee?theaterType=
${
theater
T
ype
}
`
)
const
{
data
}
=
await
axios
.
delete
(
`
${
baseUrl
}
/api/info/ticketfee?theaterType
Id
=
${
theater
t
ype
Id
}
`
)
return
data
return
data
}
}
...
...
client/src/apis/movie.api.js
View file @
dd1c9aee
...
@@ -10,23 +10,24 @@ const getAllfromTM = async () => {
...
@@ -10,23 +10,24 @@ const getAllfromTM = async () => {
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/api/movie/all`
,
payload
)
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/api/movie/all`
,
payload
)
return
data
return
data
}
}
const
getMoviesfromTM
=
async
(
category
)
=>
{
const
getMoviesfromTM
=
async
(
category
)
=>
{
console
.
log
(
category
)
const
response
=
await
axios
.
get
(
`
${
baseUrl
}
/api/movie/showmovies/
${
category
}
`
)
const
response
=
await
axios
.
get
(
`
${
baseUrl
}
/api/movie/showmovies/
${
category
}
`
)
console
.
log
(
response
.
data
)
return
response
.
data
return
response
.
data
}
}
const
getMovieInfofromTM
=
async
(
id
)
=>
{
const
getMovieInfofromTM
=
async
(
id
)
=>
{
const
movieId
=
id
const
movieId
=
id
const
response
=
await
axios
.
get
(
`
${
TMDBUrl
}
/
${
movieId
}
?api_key=
${
process
.
env
.
REACT_APP_TMDB_API_KEY
}
&language=ko-KR`
)
const
response
=
await
axios
.
get
(
`
${
TMDBUrl
}
/
${
movieId
}
?api_key=
${
process
.
env
.
REACT_APP_TMDB_API_KEY
}
&language=ko-KR`
)
console
.
log
(
response
.
data
)
return
response
.
data
return
response
.
data
}
}
const
getImagesfromTM
=
async
(
id
)
=>
{
const
getImagesfromTM
=
async
(
id
)
=>
{
const
movieId
=
id
const
movieId
=
id
const
response
=
await
axios
.
get
(
`
${
TMDBUrl
}
/
${
movieId
}
/images?api_key=
${
process
.
env
.
REACT_APP_TMDB_API_KEY
}
`
)
const
response
=
await
axios
.
get
(
`
${
TMDBUrl
}
/
${
movieId
}
/images?api_key=
${
process
.
env
.
REACT_APP_TMDB_API_KEY
}
`
)
return
response
.
data
return
response
.
data
}
}
const
getCreditsfromTM
=
async
(
id
)
=>
{
const
getCreditsfromTM
=
async
(
id
)
=>
{
const
movieId
=
id
const
movieId
=
id
const
response
=
await
axios
.
get
(
`
${
TMDBUrl
}
/
${
movieId
}
/credits?api_key=
${
process
.
env
.
REACT_APP_TMDB_API_KEY
}
`
)
const
response
=
await
axios
.
get
(
`
${
TMDBUrl
}
/
${
movieId
}
/credits?api_key=
${
process
.
env
.
REACT_APP_TMDB_API_KEY
}
`
)
...
@@ -39,9 +40,14 @@ const getVideosfromTM = async (id) =>{
...
@@ -39,9 +40,14 @@ const getVideosfromTM = async (id) =>{
return
response
.
data
.
results
return
response
.
data
.
results
}
}
const
getListfromDB
=
async
()
=>
{
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/api/movie`
)
return
data
}
const
submit
=
async
(
movieId
)
=>
{
const
submit
=
async
(
movieId
)
=>
{
const
{
data
}
=
await
axios
.
post
(
`
${
baseUrl
}
/api/movie/
${
movieId
}
`
)
const
{
data
}
=
await
axios
.
post
(
`
${
baseUrl
}
/api/movie/
${
movieId
}
`
)
console
.
log
(
"
data==
"
,
data
)
return
data
}
}
const
remove
=
async
(
movieId
)
=>
{
const
remove
=
async
(
movieId
)
=>
{
...
@@ -66,6 +72,7 @@ const movieApi = {
...
@@ -66,6 +72,7 @@ const movieApi = {
getImagesfromTM
,
getImagesfromTM
,
getCreditsfromTM
,
getCreditsfromTM
,
getVideosfromTM
,
getVideosfromTM
,
getListfromDB
,
submit
,
submit
,
remove
,
remove
,
search
,
search
,
...
...
client/src/apis/theater.api.js
View file @
dd1c9aee
...
@@ -6,8 +6,8 @@ const getAll = async () => {
...
@@ -6,8 +6,8 @@ const getAll = async () => {
return
data
return
data
}
}
const
getOne
=
async
()
=>
{
const
getOne
=
async
(
theaterId
)
=>
{
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/api/theater`
)
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/api/theater
/
${
theaterId
}
`
)
return
data
return
data
}
}
...
@@ -17,12 +17,12 @@ const getTheaterType = async () => {
...
@@ -17,12 +17,12 @@ const getTheaterType = async () => {
}
}
const
sendData
=
async
(
theater
)
=>
{
const
sendData
=
async
(
theater
)
=>
{
const
{
data
}
=
await
axios
.
put
(
`
${
baseUrl
}
/api/theater
/type
`
,
theater
)
const
{
data
}
=
await
axios
.
put
(
`
${
baseUrl
}
/api/theater`
,
theater
)
return
data
return
data
}
}
const
remove
=
async
()
=>
{
const
remove
=
async
(
theaterId
)
=>
{
const
{
data
}
=
await
axios
.
delete
(
`
${
baseUrl
}
/api/theater`
)
const
{
data
}
=
await
axios
.
delete
(
`
${
baseUrl
}
/api/theater
/
${
theaterId
}
`
)
return
data
return
data
}
}
...
...
client/src/components/Admin/TheaterEditForm.js
View file @
dd1c9aee
...
@@ -4,8 +4,9 @@ import catchErrors from "../../utils/catchErrors.js";
...
@@ -4,8 +4,9 @@ import catchErrors from "../../utils/catchErrors.js";
import
styles
from
"
./admin.module.scss
"
;
import
styles
from
"
./admin.module.scss
"
;
const
INIT_THEATER
=
{
const
INIT_THEATER
=
{
id
:
0
,
theaterName
:
""
,
theaterName
:
""
,
theater
T
ype
:
0
,
theater
t
ype
Id
:
0
,
rows
:
1
,
rows
:
1
,
columns
:
1
columns
:
1
}
}
...
@@ -51,22 +52,23 @@ const TheaterEditForm = ({ edit, formRef }) => {
...
@@ -51,22 +52,23 @@ const TheaterEditForm = ({ edit, formRef }) => {
}
}
return
(
return
(
<
form
ref
=
{
formRef
}
onSubmit
=
{
handleSubmit
}
>
<
form
ref
=
{
formRef
}
className
=
"
mb-5
"
onSubmit
=
{
handleSubmit
}
>
<
div
className
=
"
d-flex justify-content-lg-between row row-cols-2 row-cols-lg-
4
gx-0 gy-2 gy-lg-0 mb-2 mb-lg-3
"
>
<
div
className
=
"
d-flex justify-content-lg-between row row-cols-2 row-cols-lg-
5
gx-0 gy-2 gy-lg-0 mb-2 mb-lg-3
"
>
<
label
htmlfor
=
"
theaterName
"
className
=
"
col-3 col-lg-auto col-form-label
"
>
상영관
이름
<
/label
>
<
label
htmlfor
=
"
theaterName
"
className
=
"
col-3 col-lg-auto col-form-label
"
>
상영관
이름
<
/label
>
<
div
className
=
"
col-
9
col-lg-4
"
>
<
div
className
=
"
col-
8
col-lg-4
"
>
<
input
className
=
{
`form-control
${
styles
.
shadowNone
}
`
}
id
=
"
theaterName
"
name
=
"
theaterName
"
type
=
"
text
"
value
=
{
theater
.
theaterName
}
onChange
=
{
handleChange
}
/
>
<
input
className
=
{
`form-control
${
styles
.
shadowNone
}
`
}
id
=
"
theaterName
"
name
=
"
theaterName
"
type
=
"
text
"
value
=
{
theater
.
theaterName
}
onChange
=
{
handleChange
}
/
>
<
/div
>
<
/div
>
<
label
htmlfor
=
"
theaterName
"
className
=
"
col-auto col-form-label mx-2 mx-lg-0
"
>
관
<
/label
>
<
label
htmlfor
=
"
theaterType
"
className
=
"
col-3 col-lg-auto col-form-label text-lg-center
"
>
상영관
종류
<
/label
>
<
label
htmlfor
=
"
theaterType
"
className
=
"
col-3 col-lg-auto col-form-label text-lg-center
"
>
상영관
종류
<
/label
>
<
div
className
=
"
col-9 col-lg-5
"
>
<
div
className
=
"
col-9 col-lg-5
"
>
<
select
className
=
{
`form-select
${
styles
.
shadowNone
}
${
styles
.
selectInput
}
`
}
id
=
"
theater
T
ype
"
name
=
"
theater
T
ype
"
onChange
=
{
handleChange
}
aria
-
label
=
"
select theaterType
"
defaultValue
=
{
theater
.
theaterType
}
>
<
select
className
=
{
`form-select
${
styles
.
shadowNone
}
${
styles
.
selectInput
}
`
}
id
=
"
theater
t
ype
Id
"
name
=
"
theater
t
ype
Id
"
value
=
{
theater
.
theatertypeId
}
onChange
=
{
handleChange
}
aria
-
label
=
"
select theaterType
"
defaultValue
=
"
0
"
>
{
types
.
length
!==
0
?
{
types
.
length
!==
0
?
types
.
map
((
type
,
index
)
=>
{
types
.
map
((
type
,
index
)
=>
{
if
(
index
===
0
)
return
<>
if
(
index
===
0
)
return
<>
<
option
value
=
"
0
"
disabled
>
상영관
종류를
선택해주십시오
.
<
/option
>
<
option
value
=
"
0
"
disabled
>
상영관
종류를
선택해주십시오
.
<
/option
>
<
option
value
=
{
type
.
id
}
>
{
type
.
theaterType
}
<
/option
>
<
option
value
=
{
type
.
id
}
>
{
type
.
theaterType
Name
}
<
/option
>
<
/
>
<
/
>
else
return
<
option
value
=
{
type
.
id
}
>
{
type
.
theaterType
}
<
/option
>
else
return
<
option
value
=
{
type
.
id
}
>
{
type
.
theaterType
Name
}
<
/option
>
})
})
:
<
option
value
=
"
0
"
disabled
>
서버에
등록된
상영관
종류가
없습니다
.
<
/option>
}
:
<
option
value
=
"
0
"
disabled
>
서버에
등록된
상영관
종류가
없습니다
.
<
/option>
}
<
/select
>
<
/select
>
...
...
client/src/components/Admin/TheaterTable.js
View file @
dd1c9aee
...
@@ -21,10 +21,10 @@ const TheaterTable = ({ setEdit, formRef }) => {
...
@@ -21,10 +21,10 @@ const TheaterTable = ({ setEdit, formRef }) => {
}
}
}
}
async
function
editTheater
()
{
async
function
editTheater
(
theaterId
)
{
try
{
try
{
setError
(
""
)
setError
(
""
)
const
res
=
await
theaterApi
.
getOne
()
const
res
=
await
theaterApi
.
getOne
(
theaterId
)
setEdit
({
...
res
})
setEdit
({
...
res
})
formRef
?.
current
.
scrollIntoView
({
behavior
:
"
smooth
"
,
block
:
"
center
"
})
formRef
?.
current
.
scrollIntoView
({
behavior
:
"
smooth
"
,
block
:
"
center
"
})
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -32,10 +32,10 @@ const TheaterTable = ({ setEdit, formRef }) => {
...
@@ -32,10 +32,10 @@ const TheaterTable = ({ setEdit, formRef }) => {
}
}
}
}
async
function
deleteTheater
()
{
async
function
deleteTheater
(
theaterId
)
{
try
{
try
{
setError
(
""
)
setError
(
""
)
await
theaterApi
.
remove
()
await
theaterApi
.
remove
(
theaterId
)
alert
(
"
해당 상영관 정보를 성공적으로 삭제했습니다.
"
)
alert
(
"
해당 상영관 정보를 성공적으로 삭제했습니다.
"
)
getTheaterList
()
getTheaterList
()
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -56,13 +56,13 @@ const TheaterTable = ({ setEdit, formRef }) => {
...
@@ -56,13 +56,13 @@ const TheaterTable = ({ setEdit, formRef }) => {
<
tbody
>
<
tbody
>
{
theaterList
.
length
!==
0
?
theaterList
.
map
(
info
=>
{
theaterList
.
length
!==
0
?
theaterList
.
map
(
info
=>
<
tr
>
<
tr
>
<
td
>
ads
<
/td
>
<
td
>
{
info
.
theaterName
}
관
<
/td
>
<
td
>
ads
<
/td
>
<
td
>
{
info
.
theatertype
.
theaterTypeName
}
<
/td
>
<
td
>
ads
<
/td
>
<
td
>
{
info
.
rows
}
행
{
info
.
columns
}
열
<
br
/>
총
{
info
.
rows
*
info
.
columns
}
석
<
/td
>
<
td
>
<
td
>
<
div
className
=
"
d-flex flex-column
"
>
<
div
className
=
"
d-flex flex-column
"
>
<
button
type
=
"
button
"
className
=
"
btn btn-primary my-1
"
onClick
=
{()
=>
editTheater
()}
>
수정
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-primary my-1
"
onClick
=
{()
=>
editTheater
(
info
.
id
)}
>
수정
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-danger my-1
"
onClick
=
{()
=>
deleteTheater
()}
>
삭제
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-danger my-1
"
onClick
=
{()
=>
deleteTheater
(
info
.
id
)}
>
삭제
<
/button
>
<
/div
>
<
/div
>
<
/td
>
<
/td
>
<
/tr>
)
<
/tr>
)
...
...
client/src/components/Admin/TicketEditForm.js
View file @
dd1c9aee
...
@@ -4,7 +4,8 @@ import catchErrors from "../../utils/catchErrors.js";
...
@@ -4,7 +4,8 @@ import catchErrors from "../../utils/catchErrors.js";
import
styles
from
"
./admin.module.scss
"
;
import
styles
from
"
./admin.module.scss
"
;
const
INIT_TICKETFEE
=
{
const
INIT_TICKETFEE
=
{
theaterType
:
""
,
theatertypeId
:
0
,
theaterTypeName
:
""
,
weekdays
:
""
,
weekdays
:
""
,
weekend
:
""
,
weekend
:
""
,
morning
:
""
,
morning
:
""
,
...
@@ -46,7 +47,7 @@ const TicketEditForm = ({ editFee, formRef }) => {
...
@@ -46,7 +47,7 @@ const TicketEditForm = ({ editFee, formRef }) => {
<
div
className
=
"
d-flex row row-cols-2 mb-2 mb-md-3 gx-0 gy-2 gy-md-0
"
>
<
div
className
=
"
d-flex row row-cols-2 mb-2 mb-md-3 gx-0 gy-2 gy-md-0
"
>
<
label
htmlfor
=
"
theaterType
"
className
=
"
col-md-auto col-form-label text-center text-md-start
"
>
상영관
종류
<
/label
>
<
label
htmlfor
=
"
theaterType
"
className
=
"
col-md-auto col-form-label text-center text-md-start
"
>
상영관
종류
<
/label
>
<
div
className
=
"
col-md-4 col-lg-3 mx-md-2
"
>
<
div
className
=
"
col-md-4 col-lg-3 mx-md-2
"
>
<
input
className
=
{
`form-control
${
styles
.
shadowNone
}
`
}
type
=
"
text
"
id
=
"
theaterType
"
name
=
"
theaterType
"
value
=
{
ticketFee
.
theaterType
}
onChange
=
{
handleChange
}
/
>
<
input
className
=
{
`form-control
${
styles
.
shadowNone
}
`
}
type
=
"
text
"
id
=
"
theaterType
Name
"
name
=
"
theaterType
Name
"
value
=
{
ticketFee
.
theaterType
Name
}
onChange
=
{
handleChange
}
/
>
<
/div
>
<
/div
>
<
label
htmlfor
=
"
defaultPrice
"
className
=
"
col-md-auto col-form-label text-center text-md-start
"
>
기본
가격
<
/label
>
<
label
htmlfor
=
"
defaultPrice
"
className
=
"
col-md-auto col-form-label text-center text-md-start
"
>
기본
가격
<
/label
>
<
div
className
=
"
col-md-3 col-lg-2 mx-md-2
"
>
<
div
className
=
"
col-md-3 col-lg-2 mx-md-2
"
>
...
...
client/src/components/Admin/TicketFeeTable.js
View file @
dd1c9aee
...
@@ -20,10 +20,10 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
...
@@ -20,10 +20,10 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
}
}
}
}
async
function
editRow
(
theater
T
ype
)
{
async
function
editRow
(
theater
t
ype
Id
)
{
try
{
try
{
setError
(
""
)
setError
(
""
)
const
res
=
await
cinemaApi
.
getTicketFeeOne
(
theater
T
ype
)
const
res
=
await
cinemaApi
.
getTicketFeeOne
(
theater
t
ype
Id
)
setEditFee
({
...
res
})
setEditFee
({
...
res
})
formRef
?.
current
.
scrollIntoView
({
behavior
:
"
smooth
"
,
block
:
"
center
"
})
formRef
?.
current
.
scrollIntoView
({
behavior
:
"
smooth
"
,
block
:
"
center
"
})
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -31,10 +31,10 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
...
@@ -31,10 +31,10 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
}
}
}
}
async
function
deleteData
(
theater
T
ype
)
{
async
function
deleteData
(
theater
t
ype
Id
)
{
try
{
try
{
setError
(
""
)
setError
(
""
)
await
cinemaApi
.
removeTicketFee
(
theater
T
ype
)
await
cinemaApi
.
removeTicketFee
(
theater
t
ype
Id
)
alert
(
"
해당 관람료 정보를 성공적으로 삭제했습니다.
"
)
alert
(
"
해당 관람료 정보를 성공적으로 삭제했습니다.
"
)
getInfo
()
getInfo
()
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -64,7 +64,7 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
...
@@ -64,7 +64,7 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
{
ticketFee
.
length
!==
0
?
ticketFee
.
map
(
info
=>
{
ticketFee
.
length
!==
0
?
ticketFee
.
map
(
info
=>
<>
<>
<
tr
>
<
tr
>
<
td
rowSpan
=
"
6
"
className
=
{
`d-block d-md-table-cell
${
styles
.
Row
}
${
styles
.
type
}
`
}
>
{
info
.
theater
Typ
e
}
<
/td
>
<
td
rowSpan
=
"
6
"
className
=
{
`d-block d-md-table-cell
${
styles
.
Row
}
${
styles
.
type
}
`
}
>
{
info
.
theater
type
.
theaterTypeNam
e
}
<
/td
>
<
td
rowSpan
=
"
3
"
className
=
{
`d-block d-md-table-cell
${
styles
.
Row
}
${
styles
.
moreData
}
`
}
data
-
label
=
"
- 청소년 / 성인 / 경로
"
>
주중
(
월
~
목
)
<
/td
>
<
td
rowSpan
=
"
3
"
className
=
{
`d-block d-md-table-cell
${
styles
.
Row
}
${
styles
.
moreData
}
`
}
data
-
label
=
"
- 청소년 / 성인 / 경로
"
>
주중
(
월
~
목
)
<
/td
>
<
td
className
=
"
d-inline-block d-md-table-cell
"
>
조조
(
06
:
00
~
)
<
/td
>
<
td
className
=
"
d-inline-block d-md-table-cell
"
>
조조
(
06
:
00
~
)
<
/td
>
<
td
className
=
"
d-inline-block d-md-table-cell
"
>
{
priceToString
(
info
.
weekdays
+
info
.
morning
+
info
.
youth
+
info
.
defaultPrice
)}
원
<
/td
>
<
td
className
=
"
d-inline-block d-md-table-cell
"
>
{
priceToString
(
info
.
weekdays
+
info
.
morning
+
info
.
youth
+
info
.
defaultPrice
)}
원
<
/td
>
...
@@ -72,8 +72,8 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
...
@@ -72,8 +72,8 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
<
td
className
=
"
d-inline-block d-md-table-cell
"
>
{
priceToString
(
info
.
weekdays
+
info
.
morning
+
info
.
senior
+
info
.
defaultPrice
)}
원
<
/td
>
<
td
className
=
"
d-inline-block d-md-table-cell
"
>
{
priceToString
(
info
.
weekdays
+
info
.
morning
+
info
.
senior
+
info
.
defaultPrice
)}
원
<
/td
>
<
td
rowSpan
=
"
6
"
className
=
"
d-none d-md-table-cell
"
>
<
td
rowSpan
=
"
6
"
className
=
"
d-none d-md-table-cell
"
>
<
div
className
=
"
d-flex flex-column
"
>
<
div
className
=
"
d-flex flex-column
"
>
<
button
type
=
"
button
"
className
=
"
btn btn-primary my-1
"
onClick
=
{()
=>
editRow
(
info
.
theater
T
ype
)}
>
수정
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-primary my-1
"
onClick
=
{()
=>
editRow
(
info
.
theater
t
ype
Id
)}
>
수정
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-danger my-1
"
onClick
=
{()
=>
deleteData
(
info
.
theater
T
ype
)}
>
삭제
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-danger my-1
"
onClick
=
{()
=>
deleteData
(
info
.
theater
t
ype
Id
)}
>
삭제
<
/button
>
<
/div
>
<
/div
>
<
/td
>
<
/td
>
<
/tr
>
<
/tr
>
...
@@ -109,8 +109,8 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
...
@@ -109,8 +109,8 @@ const TicketFeeTable = ({ setEditFee, formRef }) => {
<
td
className
=
"
d-inline-block d-md-table-cell
"
>
{
priceToString
(
info
.
weekend
+
info
.
night
+
info
.
senior
+
info
.
defaultPrice
)}
원
<
/td
>
<
td
className
=
"
d-inline-block d-md-table-cell
"
>
{
priceToString
(
info
.
weekend
+
info
.
night
+
info
.
senior
+
info
.
defaultPrice
)}
원
<
/td
>
<
td
className
=
{
`d-block d-md-none
${
styles
.
borderTop
}
`
}
>
<
td
className
=
{
`d-block d-md-none
${
styles
.
borderTop
}
`
}
>
<
div
className
=
"
d-flex justify-content-end
"
>
<
div
className
=
"
d-flex justify-content-end
"
>
<
button
type
=
"
button
"
className
=
"
btn btn-primary
"
onClick
=
{()
=>
editRow
(
info
.
theater
T
ype
)}
>
수정
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-primary
"
onClick
=
{()
=>
editRow
(
info
.
theater
t
ype
Id
)}
>
수정
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-danger ms-2
"
onClick
=
{()
=>
deleteData
(
info
.
theater
T
ype
)}
>
삭제
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-danger ms-2
"
onClick
=
{()
=>
deleteData
(
info
.
theater
t
ype
Id
)}
>
삭제
<
/button
>
<
/div
>
<
/div
>
<
/td
>
<
/td
>
<
/tr
>
<
/tr
>
...
...
client/src/components/Admin/TimeTable.js
0 → 100644
View file @
dd1c9aee
const
TimeTable
=
()
=>
{
return
(
<>
<
/
>
)
}
export
default
TimeTable
\ No newline at end of file
client/src/components/Admin/TimeTableEdit.js
View file @
dd1c9aee
import
TimeTableEditForm
from
"
./TimeTableEditForm
"
;
import
TimeTable
from
"
./TimeTable
"
;
const
TimeTableEdit
=
()
=>
{
const
TimeTableEdit
=
()
=>
{
return
(
return
(
<>
<>
<
h2
className
=
"
border-bottom border-2 text-center pb-2 me-2
"
>
현재
상영시간표
정보
<
/h2
>
<
div
>
<
TimeTableEditForm
/>
<
TimeTable
/>
<
/div
>
<
/
>
<
/
>
)
)
}
}
...
...
client/src/components/Admin/TimeTableEditForm.js
0 → 100644
View file @
dd1c9aee
import
{
useState
,
useEffect
}
from
"
react
"
;
import
movieApi
from
"
../../apis/movie.api.js
"
;
import
theaterApi
from
"
../../apis/theater.api.js
"
;
import
catchErrors
from
"
../../utils/catchErrors.js
"
;
import
styles
from
"
./admin.module.scss
"
;
const
INIT_MOVIE
=
{
movieId
:
0
,
title
:
""
,
release_date
:
""
,
end_date
:
""
,
theater
:
[],
times
:
[]
}
const
TimeTableEditForm
=
()
=>
{
const
[
movieList
,
setMovieList
]
=
useState
([])
const
[
theaterList
,
setTheaterList
]
=
useState
([])
const
[
selectId
,
setSelectId
]
=
useState
(
0
)
const
[
selectMovie
,
setSelectMovie
]
=
useState
({})
const
[
selectInfo
,
setSelectInfo
]
=
useState
({
theater
:
0
,
start
:
""
,
end
:
""
})
const
[
showTimes
,
setShowTimes
]
=
useState
({
list
:
[]
})
const
[
sendInfo
,
setSendInfo
]
=
useState
(
INIT_MOVIE
)
const
[
error
,
setError
]
=
useState
(
""
)
useEffect
(()
=>
{
getMoviesfromDB
()
getTheater
()
},
[])
async
function
getMoviesfromDB
()
{
try
{
setError
(
""
)
const
res
=
await
movieApi
.
getListfromDB
()
setMovieList
(
res
)
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
async
function
getTheater
()
{
try
{
setError
(
""
)
const
res
=
await
theaterApi
.
getAll
()
setTheaterList
(
res
)
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
function
addRunTime
(
start
,
runTime
)
{
const
startArr
=
start
.
split
(
'
:
'
)
const
add
=
Number
(
startArr
[
1
])
+
runTime
let
hours
=
Number
(
startArr
[
0
])
+
Math
.
floor
(
add
/
60
)
if
(
hours
<=
9
)
hours
=
'
0
'
+
hours
if
(
hours
/
24
>
0
)
hours
=
'
0
'
+
hours
%
24
else
if
(
hours
<=
9
)
hours
=
'
0
'
+
hours
let
mins
=
add
%
60
if
(
mins
<=
9
)
mins
=
'
0
'
+
mins
setSelectInfo
({
...
selectInfo
,
"
start
"
:
start
,
"
end
"
:
hours
+
'
:
'
+
mins
})
}
function
addData
()
{
const
{
list
}
=
showTimes
const
isSelect
=
Object
.
values
(
selectInfo
).
every
((
el
)
=>
Boolean
(
el
))
if
(
isSelect
)
{
const
theater
=
theaterList
.
find
(
theater
=>
theater
.
theatertypeId
===
selectInfo
.
theater
)
if
(
theater
)
{
const
myTime
=
{
theaterTypeId
:
selectInfo
.
theater
,
theaterName
:
theater
.
theaterName
+
'
관 /
'
+
theater
.
theatertype
.
theaterTypeName
,
start
:
selectInfo
.
start
,
end
:
selectInfo
.
end
}
setShowTimes
({
list
:
list
.
concat
(
myTime
)
})
}
else
alert
(
'
선택한 상영관을 찾지 못했습니다. 다시 시도하길 바랍니다.
'
)
}
else
alert
(
'
추가할 데이터의 갯수가 부족합니다. 모든 항목을 입력해주시길 바랍니다.
'
)
setSelectInfo
({
...
selectInfo
,
theater
:
0
,
start
:
""
,
end
:
""
})
}
function
delData
(
index
)
{
let
{
list
}
=
showTimes
list
=
list
.
splice
(
index
,
1
)
setShowTimes
({
list
:
list
})
}
async
function
handleChange
(
e
)
{
try
{
setError
(
""
)
const
{
name
,
value
}
=
e
.
target
if
(
name
===
"
movieId
"
)
{
setSelectId
(
value
)
const
res
=
await
movieApi
.
getMovieInfofromTM
(
value
)
setSelectMovie
({
...
res
})
setSendInfo
({
...
sendInfo
,
movieId
:
value
,
title
:
res
.
title
,
release_date
:
res
.
release_date
,
end_date
:
""
})
}
else
if
(
name
===
"
end_date
"
)
{
setSendInfo
({
...
sendInfo
,
[
name
]:
value
})
}
else
if
(
name
===
"
theater
"
)
{
setSelectInfo
({
...
selectInfo
,
[
name
]:
Number
(
value
)
})
}
else
if
(
name
===
"
start
"
)
{
addRunTime
(
value
,
selectMovie
.
runtime
)
}
else
setSelectInfo
({
...
selectInfo
,
[
name
]:
value
})
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
async
function
handleSubmit
(
e
)
{
e
.
preventDefault
()
try
{
setError
(
""
)
alert
(
"
해당 상영시간표 정보 등록이 성공적으로 완료되었습니다.
"
)
window
.
location
.
reload
()
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
return
(
<
form
onSubmit
=
{
handleSubmit
}
>
{
console
.
log
(
"
select==
"
,
showTimes
)}
<
select
className
=
{
`form-select mb-3
${
styles
.
shadowNone
}
${
styles
.
selectInput
}
`
}
id
=
"
movieId
"
name
=
"
movieId
"
value
=
{
selectId
}
onChange
=
{
handleChange
}
aria
-
label
=
"
select movie
"
defaultValue
=
"
0
"
>
{
movieList
.
length
!==
0
?
movieList
.
map
((
movie
,
index
)
=>
{
if
(
index
===
0
)
return
<>
<
option
value
=
"
0
"
disabled
>
영화를
선택해주십시오
.
<
/option
>
<
option
value
=
{
movie
.
movieId
}
>
{
movie
.
title
}
<
/option
>
<
/
>
else
return
<
option
value
=
{
movie
.
movieId
}
>
{
movie
.
title
}
<
/option
>
})
:
<
option
value
=
"
0
"
disabled
>
서버에
등록된
영화가
없습니다
.
<
/option>
}
<
/select
>
<
div
className
=
"
col-md-6 mb-3
"
>
<
label
htmlFor
=
"
release_date
"
className
=
"
form-label
"
>
상영시작일
<
/label
>
<
input
type
=
"
text
"
className
=
{
`form-control
${
styles
.
shadowNone
}
`
}
id
=
"
release_date
"
name
=
"
release_date
"
value
=
{
selectMovie
?.
release_date
||
''
}
disabled
/>
<
/div
>
<
div
className
=
"
col-md-6 mb-3
"
>
<
label
htmlFor
=
"
end_date
"
className
=
"
form-label
"
>
상영종료일
<
/label
>
<
input
type
=
"
date
"
className
=
{
`form-control
${
styles
.
shadowNone
}
`
}
id
=
"
end_date
"
name
=
"
end_date
"
value
=
{
sendInfo
.
end_date
}
min
=
{
sendInfo
.
release_date
}
onChange
=
{
handleChange
}
/
>
<
/div
>
<
p
>
시간대
설정
<
/p
>
<
ul
className
=
"
list-group list-group-flush
"
>
{
showTimes
.
list
.
length
!==
0
?
showTimes
.
list
.
map
((
timeInfo
,
index
)
=>
<
li
className
=
"
list-group-item d-flex justify-content-between align-items-center
"
>
{
timeInfo
.
theaterName
}
&
nbsp
;
&
nbsp
;
&
nbsp
;{
timeInfo
.
start
}
~
{
timeInfo
.
end
}
<
button
type
=
"
button
"
className
=
"
btn btn-danger
"
onClick
=
{()
=>
delData
(
index
)}
>
삭제
<
/button
>
<
/li>
)
: <li className="list-group-item text-center">추가된 시간대가 없습니다. 폼을 작성해 시간대를 추가해 주세요.</
li
>
}
<
/ul
>
<
div
>
<
div
>
<
select
className
=
{
`form-select mb-3
${
styles
.
shadowNone
}
${
styles
.
selectInput
}
`
}
id
=
"
theater
"
name
=
"
theater
"
value
=
{
selectInfo
.
theater
}
onChange
=
{
handleChange
}
aria
-
label
=
"
select theater
"
defaultValue
=
"
0
"
>
{
theaterList
.
length
!==
0
?
theaterList
.
map
((
theater
,
index
)
=>
{
if
(
index
===
0
)
return
<>
<
option
value
=
"
0
"
disabled
>
상영관을
선택해주십시오
.
<
/option
>
<
option
value
=
{
theater
.
theatertypeId
}
>
{
theater
.
theaterName
}
관
/
{
theater
.
theatertype
.
theaterTypeName
}
<
/option
>
<
/
>
else
return
<
option
value
=
{
theater
.
theatertypeId
}
>
{
theater
.
theaterName
}
관
/
{
theater
.
theatertype
.
theaterTypeName
}
<
/option
>
})
:
<
option
value
=
"
0
"
disabled
>
서버에
등록된
상영관이
없습니다
.
<
/option>
}
<
/select
>
<
/div
>
<
div
>
<
input
type
=
"
time
"
id
=
"
start
"
name
=
"
start
"
value
=
{
selectInfo
.
start
}
onChange
=
{
handleChange
}
disabled
=
{
!
selectId
||
!
selectInfo
.
theater
}
/
>
<
p
>
{(
selectId
&&
selectInfo
.
start
!==
""
)
?
"
~
"
+
selectInfo
.
end
:
""
}
<
/p
>
<
/div
>
<
div
>
<
button
type
=
"
button
"
className
=
{
`btn btn-dark
${
styles
.
customBtn
}
`
}
onClick
=
{
addData
}
>
추가
<
/button
>
<
/div
>
<
/div
>
<
div
>
<
button
type
=
"
submit
"
className
=
{
`btn btn-dark
${
styles
.
customBtn
}
`
}
>
등록
<
/button
>
<
/div
>
<
/form
>
)
}
export
default
TimeTableEditForm
\ No newline at end of file
server/controllers/movie.controller.js
View file @
dd1c9aee
...
@@ -3,20 +3,25 @@ import { Movie } from '../db/index.js'
...
@@ -3,20 +3,25 @@ import { Movie } from '../db/index.js'
import
sequelize
from
'
sequelize
'
import
sequelize
from
'
sequelize
'
const
{
Op
}
=
sequelize
const
{
Op
}
=
sequelize
const
getListfromDB
=
async
(
req
,
res
)
=>
{
try
{
const
findAll
=
await
Movie
.
findAll
({
attributes
:
[
'
movieId
'
,
'
title
'
,
'
release_date
'
]
})
res
.
json
(
findAll
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
영화 목록 가져오기 중 에러 발생
"
);
}
}
const
getMovieByCategory
=
async
(
req
,
res
,
next
,
category
)
=>
{
const
getMovieByCategory
=
async
(
req
,
res
,
next
,
category
)
=>
{
try
{
try
{
console
.
log
(
category
)
const
TMDBmovieIds
=
[]
const
TMDBmovieIds
=
[]
const
movieIds
=
[]
const
movieIds
=
[]
console
.
log
(
process
.
env
.
TMDB_APP_KEY
)
const
response
=
await
axios
.
get
(
`https://api.themoviedb.org/3/movie/
${
category
}
?api_key=
${
process
.
env
.
TMDB_APP_KEY
}
&language=ko-KR&page=1`
)
const
response
=
await
axios
.
get
(
`https://api.themoviedb.org/3/movie/
${
category
}
?api_key=
${
process
.
env
.
TMDB_APP_KEY
}
&language=ko-KR&page=1`
)
console
.
log
(
response
.
data
)
const
TMDBmovies
=
response
.
data
.
results
const
TMDBmovies
=
response
.
data
.
results
TMDBmovies
.
forEach
(
element
=>
{
TMDBmovies
.
forEach
(
element
=>
{
TMDBmovieIds
.
push
(
element
.
id
)
TMDBmovieIds
.
push
(
element
.
id
)
})
})
console
.
log
(
TMDBmovies
)
const
responseAfterCompare
=
await
Movie
.
findAll
({
const
responseAfterCompare
=
await
Movie
.
findAll
({
where
:
{
where
:
{
movieId
:
{
movieId
:
{
...
@@ -27,7 +32,6 @@ const getMovieByCategory = async (req, res, next, category) => {
...
@@ -27,7 +32,6 @@ const getMovieByCategory = async (req, res, next, category) => {
responseAfterCompare
.
forEach
(
el
=>
{
responseAfterCompare
.
forEach
(
el
=>
{
movieIds
.
push
(
el
.
movieId
)
movieIds
.
push
(
el
.
movieId
)
})
})
console
.
log
(
'
movieIds=
'
,
movieIds
)
req
.
movieIds
=
movieIds
req
.
movieIds
=
movieIds
next
()
next
()
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -38,14 +42,12 @@ const getMovieByCategory = async (req, res, next, category) => {
...
@@ -38,14 +42,12 @@ const getMovieByCategory = async (req, res, next, category) => {
const
getMovieById
=
async
(
req
,
res
)
=>
{
const
getMovieById
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
movieIds
=
req
.
movieIds
const
movieIds
=
req
.
movieIds
console
.
log
(
movieIds
)
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`
)
return
movie
.
data
return
movie
.
data
})
})
)
)
console
.
log
(
elements
)
res
.
json
(
elements
)
res
.
json
(
elements
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
영화 가져오기 중 에러 발생
"
);
return
res
.
status
(
500
).
send
(
error
.
message
||
"
영화 가져오기 중 에러 발생
"
);
...
@@ -107,7 +109,6 @@ const getAllMovie = async (req, res, next) => {
...
@@ -107,7 +109,6 @@ const getAllMovie = async (req, res, next) => {
const
getMovieList
=
async
(
req
,
res
)
=>
{
const
getMovieList
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
movieList
=
await
Movie
.
findAll
()
const
movieList
=
await
Movie
.
findAll
()
// console.log(movieList)
const
movieIds
=
[]
const
movieIds
=
[]
movieList
.
forEach
(
el
=>
{
movieList
.
forEach
(
el
=>
{
movieIds
.
push
(
el
.
movieId
)
movieIds
.
push
(
el
.
movieId
)
...
@@ -117,8 +118,7 @@ const getMovieList = async(req,res)=>{
...
@@ -117,8 +118,7 @@ const getMovieList = async(req,res)=>{
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`
)
return
movie
.
data
return
movie
.
data
})
})
)
)
console
.
log
(
elements
)
res
.
json
(
elements
)
res
.
json
(
elements
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
...
@@ -184,6 +184,7 @@ const findaboutAll = async (req, res, next) => {
...
@@ -184,6 +184,7 @@ const findaboutAll = async (req, res, next) => {
}
}
export
default
{
export
default
{
getListfromDB
,
getMovieByCategory
,
getMovieByCategory
,
getMovieById
,
getMovieById
,
getAllMovie
,
getAllMovie
,
...
...
server/controllers/theater.controller.js
View file @
dd1c9aee
import
{
Theater
,
T
icketFe
e
}
from
"
../db/index.js
"
;
import
{
Theater
,
T
heaterTyp
e
}
from
"
../db/index.js
"
;
const
getTheaterInfo
=
async
(
req
,
res
)
=>
{
const
getTheaterInfo
=
async
(
req
,
res
)
=>
{
const
{
theaterNum
}
=
req
.
body
const
{
theaterNum
}
=
req
.
body
...
@@ -15,17 +15,27 @@ const getTheaterInfo = async (req, res) => {
...
@@ -15,17 +15,27 @@ const getTheaterInfo = async (req, res) => {
}
}
const
getAll
=
async
(
req
,
res
)
=>
{
const
getAll
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
findList
=
await
Theater
.
findAll
({
include
:
[{
model
:
TicketFee
,
attributes
:
[
"
theaterType
"
]
}]
})
const
findList
=
await
Theater
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
},
include
:
[
TheaterType
],
order
:
[[
'
theaterName
'
]]
})
console
.
log
(
"
Ads==
"
,
findList
)
return
res
.
json
(
findList
)
return
res
.
json
(
findList
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
}
}
}
}
const
getOne
=
async
(
req
,
res
)
=>
{
try
{
const
{
theaterId
}
=
req
.
params
const
find
=
await
Theater
.
findOne
({
where
:
{
id
:
theaterId
}
,
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
if
(
!
find
)
throw
new
Error
(
"
해당 정보를 찾지 못했습니다.
"
);
return
res
.
json
(
find
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
}
}
const
getTypes
=
async
(
req
,
res
)
=>
{
const
getTypes
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
findTypes
=
await
T
icketFe
e
.
findAll
({
attributes
:
[
'
id
'
,
'
theaterType
'
]
})
const
findTypes
=
await
T
heaterTyp
e
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
return
res
.
json
(
findTypes
)
return
res
.
json
(
findTypes
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
...
@@ -34,10 +44,10 @@ const getTypes = async (req, res) => {
...
@@ -34,10 +44,10 @@ const getTypes = async (req, res) => {
const
submit
=
async
(
req
,
res
)
=>
{
const
submit
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
{
id
}
=
req
.
body
const
{
id
,
theatertypeId
,
theaterName
,
rows
,
columns
}
=
req
.
body
let
response
=
null
let
response
=
null
if
(
id
)
response
=
await
Theater
.
update
({
...
req
.
body
},
{
where
:
{
id
:
id
}
})
if
(
id
)
response
=
await
Theater
.
update
({
theatertypeId
,
theaterName
,
rows
,
columns
},
{
where
:
{
id
:
id
}
})
else
response
=
await
Theater
.
create
({
...
req
.
body
})
else
response
=
await
Theater
.
create
({
theatertypeId
,
theaterName
,
rows
,
columns
})
return
res
.
json
(
response
)
return
res
.
json
(
response
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 저장 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 저장 중 에러 발생
"
)
...
@@ -46,7 +56,10 @@ const submit = async (req, res) => {
...
@@ -46,7 +56,10 @@ const submit = async (req, res) => {
const
remove
=
async
(
req
,
res
)
=>
{
const
remove
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
{
theaterId
}
=
req
.
params
const
delNum
=
await
Theater
.
destroy
({
where
:
{
id
:
theaterId
}
})
if
(
delNum
)
res
.
json
(
delNum
)
else
throw
new
Error
(
"
해당 정보를 서버에서 삭제하는데 실패했습니다.
"
);
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 삭제 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 삭제 중 에러 발생
"
)
}
}
...
@@ -54,6 +67,7 @@ const remove = async (req, res) => {
...
@@ -54,6 +67,7 @@ const remove = async (req, res) => {
export
default
{
export
default
{
getAll
,
getAll
,
getOne
,
getTypes
,
getTypes
,
submit
,
submit
,
remove
,
remove
,
...
...
server/controllers/ticketfee.controller.js
View file @
dd1c9aee
import
{
TicketFee
}
from
"
../db/index.js
"
;
import
{
TheaterType
,
TicketFee
}
from
"
../db/index.js
"
;
const
getAll
=
async
(
req
,
res
)
=>
{
const
getAll
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
findAll
=
await
TicketFee
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
const
findAll
=
await
TicketFee
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
,
include
:
[
TheaterType
]
})
return
res
.
json
(
findAll
)
return
res
.
json
(
findAll
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보 가져오는 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보 가져오는 중 에러 발생
"
)
...
@@ -11,8 +11,9 @@ const getAll = async (req, res) => {
...
@@ -11,8 +11,9 @@ const getAll = async (req, res) => {
const
getOne
=
async
(
req
,
res
)
=>
{
const
getOne
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
{
theaterType
}
=
req
.
params
const
{
theaterTypeId
}
=
req
.
params
const
find
=
await
TicketFee
.
findOne
({
where
:
{
theaterType
:
theaterType
},
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
const
find
=
await
TicketFee
.
findOne
({
where
:
{
theatertypeId
:
theaterTypeId
},
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
},
include
:
[
TheaterType
]
})
find
.
dataValues
.
theaterTypeName
=
find
.
dataValues
.
theatertype
.
dataValues
.
theaterTypeName
if
(
!
find
)
throw
new
Error
(
"
해당 정보를 찾지 못했습니다.
"
);
if
(
!
find
)
throw
new
Error
(
"
해당 정보를 찾지 못했습니다.
"
);
return
res
.
json
(
find
)
return
res
.
json
(
find
)
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -22,26 +23,29 @@ const getOne = async (req, res) => {
...
@@ -22,26 +23,29 @@ const getOne = async (req, res) => {
const
edit
=
async
(
req
,
res
)
=>
{
const
edit
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
{
theater
Type
}
=
req
.
body
const
{
theater
typeId
,
theaterTypeName
,
defaultPrice
,
weekdays
,
weekend
,
morning
,
day
,
night
,
youth
,
adult
,
senior
}
=
req
.
body
let
response
=
null
let
response
=
null
const
result
=
await
T
icketFe
e
.
findOrCreate
({
const
result
=
await
T
heaterTyp
e
.
findOrCreate
({
where
:
{
theaterType
:
theater
T
ype
},
where
:
{
id
:
theater
t
ype
Id
},
defaults
:
{
...
req
.
body
}
defaults
:
{
theaterTypeName
:
theaterTypeName
}
})
})
if
(
!
result
[
1
])
{
if
(
result
[
1
])
{
const
updateData
=
await
TicketFee
.
update
({
...
req
.
body
},
{
where
:
{
theaterType
:
theaterType
}
})
response
=
await
TicketFee
.
create
({
theatertypeId
:
result
[
0
].
id
,
defaultPrice
,
weekdays
,
weekend
,
morning
,
day
,
night
,
youth
,
adult
,
senior
})
response
=
updateData
}
else
{
}
else
response
=
result
[
0
]
await
TheaterType
.
update
({
theaterTypeName
:
theaterTypeName
},
{
where
:
{
id
:
theatertypeId
}
})
response
=
await
TicketFee
.
update
({
defaultPrice
,
weekdays
,
weekend
,
morning
,
day
,
night
,
youth
,
adult
,
senior
},
{
where
:
{
theatertypeId
:
result
[
0
].
id
}
})
}
return
res
.
json
(
response
)
return
res
.
json
(
response
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보 수정 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보
추가 및
수정 중 에러 발생
"
)
}
}
}
}
const
remove
=
async
(
req
,
res
)
=>
{
const
remove
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
{
theaterType
}
=
req
.
query
const
{
theaterTypeId
}
=
req
.
query
const
delNum
=
await
TicketFee
.
destroy
({
where
:
{
theaterType
:
theaterType
}
})
const
delNum
=
await
TicketFee
.
destroy
({
where
:
{
theatertypeId
:
theaterTypeId
}
})
await
TheaterType
.
destroy
({
where
:
{
id
:
theaterTypeId
}
})
if
(
delNum
)
res
.
json
(
delNum
)
if
(
delNum
)
res
.
json
(
delNum
)
else
throw
new
Error
(
"
해당 정보를 서버에서 삭제하는데 실패했습니다.
"
);
else
throw
new
Error
(
"
해당 정보를 서버에서 삭제하는데 실패했습니다.
"
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
server/routes/cinema.route.js
View file @
dd1c9aee
...
@@ -10,7 +10,7 @@ router
...
@@ -10,7 +10,7 @@ router
.
put
(
cinemaCtrl
.
edit
)
.
put
(
cinemaCtrl
.
edit
)
router
router
.
route
(
"
/ticketfee/:theaterType
"
)
.
route
(
"
/ticketfee/:theaterType
Id
"
)
.
get
(
ticketfeeCtrl
.
getOne
)
.
get
(
ticketfeeCtrl
.
getOne
)
router
router
...
...
server/routes/movie.route.js
View file @
dd1c9aee
...
@@ -5,12 +5,14 @@ const router = express.Router();
...
@@ -5,12 +5,14 @@ const router = express.Router();
router
router
.
route
(
"
/
"
)
.
route
(
"
/
"
)
// .pos
t(movieCtrl.
comparePopularMovie
)
.
ge
t
(
movieCtrl
.
getListfromDB
)
router
.
route
(
'
/showmovies/:category
'
)
router
.
route
(
'
/showmovies/:category
'
)
.
get
(
movieCtrl
.
getMovieById
)
.
get
(
movieCtrl
.
getMovieById
)
router
.
route
(
'
/movielist
'
)
router
.
route
(
'
/movielist
'
)
.
get
(
movieCtrl
.
getMovieList
)
.
get
(
movieCtrl
.
getMovieList
)
router
router
...
...
server/routes/theater.route.js
View file @
dd1c9aee
...
@@ -10,10 +10,14 @@ router
...
@@ -10,10 +10,14 @@ router
.
route
(
"
/
"
)
.
route
(
"
/
"
)
.
get
(
theaterCtrl
.
getAll
)
.
get
(
theaterCtrl
.
getAll
)
.
put
(
theaterCtrl
.
submit
)
.
put
(
theaterCtrl
.
submit
)
.
delete
(
theaterCtrl
.
remove
)
router
router
.
route
(
"
/type
"
)
.
route
(
"
/type
"
)
.
get
(
theaterCtrl
.
getTypes
)
.
get
(
theaterCtrl
.
getTypes
)
router
.
route
(
"
/:theaterId
"
)
.
get
(
theaterCtrl
.
getOne
)
.
delete
(
theaterCtrl
.
remove
)
export
default
router
;
export
default
router
;
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