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
bedd74ec
Commit
bedd74ec
authored
Jul 31, 2021
by
Kim, Subin
Browse files
관람료-상영관타입 연관 완성
parent
9fdda5c9
Changes
5
Hide whitespace changes
Inline
Side-by-side
client/src/apis/cinema.api.js
View file @
bedd74ec
...
@@ -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/components/Admin/TicketEditForm.js
View file @
bedd74ec
...
@@ -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
:
""
,
...
@@ -43,10 +44,11 @@ const TicketEditForm = ({ editFee, formRef }) => {
...
@@ -43,10 +44,11 @@ const TicketEditForm = ({ editFee, formRef }) => {
return
(
return
(
<
form
ref
=
{
formRef
}
onSubmit
=
{
handleSubmit
}
>
<
form
ref
=
{
formRef
}
onSubmit
=
{
handleSubmit
}
>
{
console
.
log
(
"
fidsapd===
"
,
editFee
)}
<
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 @
bedd74ec
...
@@ -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
>
...
...
server/controllers/ticketfee.controller.js
View file @
bedd74ec
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 @
bedd74ec
...
@@ -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
...
...
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