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) => { ...@@ -51,7 +51,7 @@ const findOneReservation = async (req, res, next) => {
} }
const saveReservation = async (req, res) => { const saveReservation = async (req, res) => {
try { 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 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: selectedTheater, theaterId: theaterId,
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
...@@ -20,16 +20,16 @@ const ReservationModel = (sequelize) => { ...@@ -20,16 +20,16 @@ const ReservationModel = (sequelize) => {
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,
} }
}, },
......
...@@ -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
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