Commit 856a1a51 authored by 한규민's avatar 한규민
Browse files

상연관종류만 하면됨

parent 4656d091
......@@ -26,6 +26,7 @@ function App() {
<Router>
<Switch>
<Route path="/admin" component={AdminPage} />
<>
<div style={{ backgroundColor: "black" }}>
<SubNav />
<Header />
......@@ -47,6 +48,7 @@ function App() {
<Route path="/search" component={SearchPage} />
</Switch>
</div>
</>
</Switch>
</Router>
</AuthProvider>
......
......@@ -15,7 +15,6 @@ const findReservation = async () => {
}
const findOneReservation = async () => {
console.log("여기여기2");
const url = `${baseUrl}/api/reservation/findonereservation`;
const { data } = await axios.get(url);
return data
......
import { useState, useEffect } from "react";
import reservationApi from "../../apis/reservation.api";
import styles from "./reservation-details.module.scss";
import moment from 'moment';
const ReservationDetails = () => {
const [movies, setMovies] = useState([]);
......@@ -8,12 +10,9 @@ const ReservationDetails = () => {
const movieList = await reservationApi.findOneReservation();
setMovies(movieList);
}
useEffect(() => {
findReservaion();
}, [])
return (
<div className={`d-flex flex-column align-items-center ${styles.width}`}>
<div className={`${styles.header}`}>나의 예매 내역</div>
......@@ -26,11 +25,11 @@ const ReservationDetails = () => {
</div>
<div className={`${styles.span} d-flex flex-column`}>
<span className={`${styles.layout}`}>{movie.title}</span>
<span className={`${styles.layout}`}>예매확인번호</span>
<span className={`${styles.layout}`}></span>
<span className={`${styles.layout}`}></span>
<span className={`${styles.layout}`}>{movie.row} {movie.col}</span>
<span className={`${styles.layout}`}>결제금액</span>
<span className={`${styles.layout}`}>{moment(movie.data).format('YYYY-MM-DD')}</span>
<span className={`${styles.layout}`}>{moment(movie.start_time).format('HH:mm')} ~ {moment(movie.end_time).format('HH:mm')}</span>
<span className={`${styles.layout}`}>{movie.theaterName}</span>
<span className={`${styles.layout}`}>{ String.fromCharCode(movie.row + 64)} {movie.col}</span>
<span className={`${styles.layout}`}>{movie.totalFee}</span>
<span className={`${styles.layout}`}>{movie.payment}</span>
</div>
</div>
......
......@@ -67,7 +67,7 @@ const getAllMovie = async (req, res, next) => {
}
}
const getMovieById = async (req, res) => {
const getMovieById = async (req, res, next) => {
try {
const reservation = req.reservation
const movieId = reservation.map(movie => movie.movieId);
......@@ -83,14 +83,15 @@ const getMovieById = async (req, res) => {
})
)
reservation.map(reservation => {
const movieId = elements.find(el => reservation.movieId === el.movieId )
const movieId = elements.find(el => reservation.movieId === el.movieId );
reservation.dataValues = {
...reservation.dataValues,
poster_path: movieId.poster_path,
title: movieId.title
}
});
res.json(reservation);
req.reservation = reservation;
next();
} catch (error) {
return res.status(500).send(error.message || "영화 가져오기 중 에러 발생");
}
......
import jwt from "jsonwebtoken";
import { Movie, Reservation, Theater, TimeTable } from '../db/index.js'
import { Movie, Reservation, Theater, TheaterType, TimeTable } from '../db/index.js'
import config from '../config/app.config.js'
const findReservedSeats = async (req, res) => {
......@@ -23,7 +23,8 @@ const findReservation = async (req, res) => {
const reservation = await Reservation.findAll({
where: {
user: id
}
},
include: [Theater, TimeTable]
})
res.json(reservation)
} catch (error) {
......@@ -34,17 +35,16 @@ const findOneReservation = async (req, res, next) => {
try {
const token = req.cookies.butterStudio;
const { id, role } = jwt.verify(token, config.jwtSecret);
console.log(id, role);
const reservation = await Reservation.findAll({
where: {
userType: role,
user: id
user: id,
userType: role
},
include: [Theater, TimeTable]
include:[TimeTable, Theater]
});
console.log(reservation);
req.reservation = reservation
next()
// res.json(reservation);
req.reservation = reservation;
next();
} catch (error) {
res.status(500).send(error.message || "예매 내역을 찾는 중 오류 발생")
}
......
......@@ -9,7 +9,7 @@ const getTheaterInfo = async (req, res) => {
})
// console.log("theaterInfo====",theaterInfo)
return res.json(theaterInfo)
} catch (error){
} catch (error) {
console.log(error)
}
}
......@@ -42,6 +42,64 @@ const getTypes = async (req, res) => {
}
}
const getTheater = async (req, res, next) => {
try {
const reservation = req.reservation;
const theaterId = reservation.map(movie => movie.theaterId);
const elements = await Promise.all(
theaterId.map(async (theaterId) => {
const theater = await Theater.findOne({ where: { id: theaterId } });
const theaterData = {
theaterId: theater.id,
theaterName: theater.theaterName,
theatertypeId: theater.theatertypeId
}
return theaterData
})
);
reservation.map(reservation => {
const theaterId = elements.find(el => reservation.theaterId === el.theaterId);
reservation.dataValues = {
...reservation.dataValues,
theaterName: theaterId.theaterName,
theatertypeId: theaterId.theatertypeId
}
})
// req.reservation = reservation;
res.json(reservation)
} catch (error) {
return res.status(500).send(error.message || "상영관 정보 불러오기 실패")
}
}
const getTheaterType = async (req, res) => {
try {
const reservation = req.reservation;
const theatertypeId = reservation.map(movie => movie.theatertypeId);
const elements = await Promise.all(
theatertypeId.map(async (theatertypeId) => {
const theaterType = await TheaterType.findOne({ where: { id: theatertypeId } });
console.log(theaterType)
const theaterData = {
theaterTypeId: theaterType.id,
theaterTypeName: theaterType.theaterTypeName
}
return theaterData
})
);
console.log("elements : ", elements)
reservation.map(reservation => {
const theaterTypeName = elements.find(el => reservation.theaterTypeId === el.theaterTypeId);
reservation.dataValues = {
...reservation.dataValues,
theaterTypeName: theaterTypeName.theaterTypeName,
}
})
res.json(reservation);
} catch (error) {
return res.status(500).send(error.message || "상영관 정보 불러오기 실패")
}
}
const submit = async (req, res) => {
try {
const { id, theatertypeId, theaterName, rows, columns } = req.body
......@@ -76,6 +134,8 @@ export default {
getAll,
getOne,
getTypes,
getTheater,
getTheaterType,
submit,
remove,
getTheaterInfo
......
......@@ -30,6 +30,37 @@ const getAll = async (req, res) => {
return res.status(500).send(error.message || "상영시간표 정보 가져오는 중 에러 발생")
}
}
const getTimeTable = async (req, res, next) => {
try {
const reservation = req.reservation;
const timetableId = reservation.map(movie => movie.timetableId);
const elements = await Promise.all(
timetableId.map(async (timetableId) => {
const time = await TimeTable.findOne({ where: { id: timetableId } })
const movieData = {
timetableId: time.id,
date: time.date,
start_time: time.start_time,
end_time: time.end_time,
}
return movieData
})
);
reservation.map(reservation => {
const timetableId = elements.find(el => reservation.timetableId === el.timetableId);
reservation.dataValues = {
...reservation.dataValues,
date: timetableId.date,
start_time: timetableId.start_time,
end_time: timetableId.end_time,
}
});
req.reservation = reservation;
next();
} catch (error) {
return res.status(500).send(error.message || "상영 시간표 불러오기 실패")
}
}
const submit = async (req, res) => {
try {
......@@ -102,6 +133,7 @@ const remove = async (req, res) => {
export default {
getAll,
getTimeTable,
submit,
remove
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ import { User, Role, Guest, ConfirmNum } from '../db/index.js';
import fs from "fs";
import CryptoJS from "crypto-js";
import validator from "validator";
import axios from "axios";
// 현재 유저 상태 결정
const getUser = async (req, res) => {
try {
......@@ -149,11 +149,10 @@ const confirmMbnum = async (req, res) => {
const signature = hash.toString(CryptoJS.enc.Base64);
const phoneNumber = req.params.phone;
console.log(phoneNumber);
console.log("phoneNumber: ", phoneNumber);
//인증번호 생성
const verifyCode = Math.floor(Math.random() * (999999 - 100000)) + 100000;
console.log("verifyCode : ", verifyCode);
console.log(verifyCode);
let today = new Date();
let time = String(today.getTime());
// let result = await axios({
......@@ -182,8 +181,8 @@ const confirmMbnum = async (req, res) => {
// const resultMs = result.data.messages;
// console.log('resultMs', resultMs);
// console.log('response', res.data, res['data']);
const confirm = await ConfirmNum.findOne({ where: { phone: phoneNumber } });
if (confirm) {
await confirm.destroy();
......
......@@ -55,6 +55,7 @@ TimeTable.belongsTo(Theater);
Reservation.belongsTo(Theater);
Reservation.belongsTo(TimeTable);
export {
sequelize,
User,
......
import express from "express";
import movieCtrl from "../controllers/movie.controller.js";
import reservationCtrl from "../controllers/reservation.controller.js";
import timetableCtrl from "../controllers/timetable.controller.js";
import theaterCtrl from "../controllers/theater.controller.js"
const router = express.Router();
......@@ -10,7 +11,13 @@ router.route('/findreservation')
.get(reservationCtrl.findReservation)
router.route('/findonereservation')
.get(reservationCtrl.findOneReservation, movieCtrl.getMovieById)
.get(
reservationCtrl.findOneReservation,
movieCtrl.getMovieById,
timetableCtrl.getTimeTable,
theaterCtrl.getTheater,
// theaterCtrl.getTheaterType
)
router.route('/save')
.post(reservationCtrl.saveReservation)
......
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