Commit 3916c374 authored by Kim, Subin's avatar Kim, Subin
Browse files

Merge branch 'master' into kimpen

parents eb9bcd78 52c103b2
......@@ -51,7 +51,7 @@ const findOneReservation = async (req, res, next) => {
}
const saveReservation = async (req, res) => {
try {
const { movieId, selectedTheater, timetableId, payment, user, userType, totalFee } = req.body
const { movieId, theaterId, timetableId, payment, user, userType, totalFee } = req.body
const rows = req.body.selectedSeats.map(el => el.split('-')[0])
const cols = req.body.selectedSeats.map(el => el.split('-')[1])
for (let index = 0; index < rows.length; index++) {
......@@ -62,7 +62,7 @@ const saveReservation = async (req, res) => {
row: rows[index],
col: cols[index],
timetableId: timetableId,
theaterId: selectedTheater,
theaterId: theaterId,
payment: payment,
totalFee: totalFee,
})
......@@ -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 {
findReservedSeats,
findReservation,
findOneReservation,
saveReservation
saveReservation,
saveTid,
deleteReservation
}
\ No newline at end of file
......@@ -20,16 +20,16 @@ const ReservationModel = (sequelize) => {
col: {
type: DataTypes.INTEGER,
},
userType:{
userType: {
type: DataTypes.STRING,
},
user:{
user: {
type: DataTypes.INTEGER,
},
payment:{
payment: {
type: DataTypes.STRING,
},
totalFee:{
totalFee: {
type: DataTypes.INTEGER,
}
},
......
......@@ -15,4 +15,10 @@ router.route('/findonereservation')
router.route('/save')
.post(reservationCtrl.saveReservation)
router.route('/savetid')
.post(reservationCtrl.saveTid)
router.route('/delete')
.get(reservationCtrl.deleteReservation)
export default router;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment