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
3916c374
Commit
3916c374
authored
Aug 11, 2021
by
Kim, Subin
Browse files
Merge branch 'master' into kimpen
parents
eb9bcd78
52c103b2
Changes
23
Hide whitespace changes
Inline
Side-by-side
server/controllers/reservation.controller.js
View file @
3916c374
...
@@ -51,7 +51,7 @@ const findOneReservation = async (req, res, next) => {
...
@@ -51,7 +51,7 @@ const findOneReservation = async (req, res, next) => {
}
}
const
saveReservation
=
async
(
req
,
res
)
=>
{
const
saveReservation
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
{
movieId
,
selectedT
heater
,
timetableId
,
payment
,
user
,
userType
,
totalFee
}
=
req
.
body
const
{
movieId
,
t
heater
Id
,
timetableId
,
payment
,
user
,
userType
,
totalFee
}
=
req
.
body
const
rows
=
req
.
body
.
selectedSeats
.
map
(
el
=>
el
.
split
(
'
-
'
)[
0
])
const
rows
=
req
.
body
.
selectedSeats
.
map
(
el
=>
el
.
split
(
'
-
'
)[
0
])
const
cols
=
req
.
body
.
selectedSeats
.
map
(
el
=>
el
.
split
(
'
-
'
)[
1
])
const
cols
=
req
.
body
.
selectedSeats
.
map
(
el
=>
el
.
split
(
'
-
'
)[
1
])
for
(
let
index
=
0
;
index
<
rows
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
rows
.
length
;
index
++
)
{
...
@@ -62,7 +62,7 @@ const saveReservation = async (req, res) => {
...
@@ -62,7 +62,7 @@ const saveReservation = async (req, res) => {
row
:
rows
[
index
],
row
:
rows
[
index
],
col
:
cols
[
index
],
col
:
cols
[
index
],
timetableId
:
timetableId
,
timetableId
:
timetableId
,
theaterId
:
selectedT
heater
,
theaterId
:
t
heater
Id
,
payment
:
payment
,
payment
:
payment
,
totalFee
:
totalFee
,
totalFee
:
totalFee
,
})
})
...
@@ -81,9 +81,46 @@ const saveReservation = async (req, res) => {
...
@@ -81,9 +81,46 @@ const saveReservation = async (req, res) => {
}
}
}
}
const
saveTid
=
async
(
req
,
res
)
=>
{
try
{
const
{
tid
}
=
req
.
body
const
token
=
req
.
cookies
.
butterStudio
;
const
{
id
,
role
}
=
jwt
.
verify
(
token
,
config
.
jwtSecret
);
await
Reservation
.
update
({
tid
:
tid
},
{
where
:
{
userType
:
role
,
user
:
id
}
})
res
.
json
({
message
:
'
Tid 저장 OK
'
})
}
catch
(
error
)
{
console
.
log
(
error
)
res
.
status
(
500
).
send
(
error
.
message
||
"
예매DB에 Tid 저장 실패
"
)
}
}
const
deleteReservation
=
async
(
req
,
res
)
=>
{
try
{
const
token
=
req
.
cookies
.
butterStudio
;
const
{
id
,
role
}
=
jwt
.
verify
(
token
,
config
.
jwtSecret
);
await
Reservation
.
destroy
({
where
:
{
userType
:
role
,
user
:
id
}
});
res
.
json
({
message
:
'
결제실패로 인한 예매DB삭제
'
})
}
catch
(
error
)
{
console
.
log
(
error
)
res
.
status
(
500
).
send
(
error
.
message
||
"
예매DB 삭제실패
"
)
}
}
export
default
{
export
default
{
findReservedSeats
,
findReservedSeats
,
findReservation
,
findReservation
,
findOneReservation
,
findOneReservation
,
saveReservation
saveReservation
,
saveTid
,
deleteReservation
}
}
\ No newline at end of file
server/models/reservation.model.js
View file @
3916c374
...
@@ -13,23 +13,23 @@ const ReservationModel = (sequelize) => {
...
@@ -13,23 +13,23 @@ const ReservationModel = (sequelize) => {
},
},
movieId
:
{
movieId
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
},
},
row
:
{
row
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
},
},
col
:
{
col
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
},
},
userType
:{
userType
:
{
type
:
DataTypes
.
STRING
,
type
:
DataTypes
.
STRING
,
},
},
user
:{
user
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
},
},
payment
:{
payment
:
{
type
:
DataTypes
.
STRING
,
type
:
DataTypes
.
STRING
,
},
},
totalFee
:{
totalFee
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
}
}
},
},
...
...
server/routes/reservation.route.js
View file @
3916c374
...
@@ -15,4 +15,10 @@ router.route('/findonereservation')
...
@@ -15,4 +15,10 @@ router.route('/findonereservation')
router
.
route
(
'
/save
'
)
router
.
route
(
'
/save
'
)
.
post
(
reservationCtrl
.
saveReservation
)
.
post
(
reservationCtrl
.
saveReservation
)
router
.
route
(
'
/savetid
'
)
.
post
(
reservationCtrl
.
saveTid
)
router
.
route
(
'
/delete
'
)
.
get
(
reservationCtrl
.
deleteReservation
)
export
default
router
;
export
default
router
;
\ No newline at end of file
Prev
1
2
Next
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