Commit 64d60802 authored by 한규민's avatar 한규민
Browse files

Merge branch 'master' into gyumin

parents dca77d17 44b5a715
import nodemailer from "nodemailer" import nodemailer from "nodemailer"
const SendMail = async (req,res) => { const SendMail = async (req,res) => {
// console.log(req.body) const {email, title, cinema,selectedTheater, time, nickname} = req.body
const {email} = req.body const selectedSeats = req.body.selectedSeats
console.log(email) const sendMail = async (email,title, cinema,selectedTheater, time, nickname, selectedSeats) => {
const sendMail = async (email) => {
// 메일을 전달해줄 객체 // 메일을 전달해줄 객체
const transporter = nodemailer.createTransport({ const transporter = nodemailer.createTransport({
// service: "gmail",
host: 'smtp.gmail.com', host: 'smtp.gmail.com',
port: 465, port: 465,
secure: true, secure: true,
...@@ -16,7 +14,6 @@ const SendMail = async (req,res) => { ...@@ -16,7 +14,6 @@ const SendMail = async (req,res) => {
user: "angelayoon99@gmail.com", user: "angelayoon99@gmail.com",
clientId: process.env.GMAIL_CLIENTID, clientId: process.env.GMAIL_CLIENTID,
clientSecret: process.env.GMAIL_CLIENTSECRET, clientSecret: process.env.GMAIL_CLIENTSECRET,
accessToken: process.env.GMAIL_ACCESS_TOKEN,
refreshToken: process.env.GMAIL_REFRESH_TOKEN, refreshToken: process.env.GMAIL_REFRESH_TOKEN,
}, },
tls: { tls: {
...@@ -26,10 +23,10 @@ const SendMail = async (req,res) => { ...@@ -26,10 +23,10 @@ const SendMail = async (req,res) => {
// 메일 옵션 // 메일 옵션
const mailOptions = { const mailOptions = {
from: `윤지원 <angelayoon99@gmail.com>`, from: `${cinema} <angelayoon99@gmail.com>`,
to: "jiwon5393@naver.com", to: `${email}`,
subject: "사용자 계정 확인용 메일.", subject: `${cinema} 예매확인내역: ${title}`,
text: "Test Mail from Test Server.", text: `${nickname}님의 예매: ${title} / ${cinema} / ${selectedTheater}관 / 일시: ${time} / ${selectedSeats} /`,
}; };
// 메일 전송 // 메일 전송
...@@ -42,7 +39,7 @@ const SendMail = async (req,res) => { ...@@ -42,7 +39,7 @@ const SendMail = async (req,res) => {
} }
} }
sendMail(email); sendMail(email,title, cinema,selectedTheater, time, nickname, selectedSeats);
} }
......
import axios from 'axios'
import { Reservation,Theater } from '../db/index.js'
import sequelize from 'sequelize'
const { Op } = sequelize
const findReservation = async (req,res) => {
const {timetable} = req.body
try {
const reservedSeats = await Reservation.findAll({
where: {
timetable:timetable
}
})
console.log(reservedSeats)
res.json(reservedSeats)
} catch (error) {
return res.status(500).send(error.message || "이미 예매되어있는 좌석을 찾는 중 오류발생")
}
}
export default {findReservation}
\ No newline at end of file
import { Theater, TicketFee } from "../db/index.js";
const getTheaterInfo = async (req, res) => {
const { theaterNum } = req.body
try {
const theaterInfo = await Theater.findOne({
where: { theaterNum: theaterNum },
attributes: ['theaterNum', 'rows', 'columns', 'theaterType']
})
// console.log("theaterInfo====",theaterInfo)
return res.json(theaterInfo)
} catch (error){
console.log(error)
}
}
const getAll = async (req, res) => {
try {
const findList = await Theater.findAll({ include: [{ model: TicketFee, attributes: ["theaterType"] }] })
console.log("Ads==", findList)
return res.json(findList)
} catch (error) {
return res.status(500).send(error.message || "상영관 정보 가져오는 중 에러 발생")
}
}
const getTypes = async (req, res) => {
try {
const findTypes = await TicketFee.findAll({ attributes: ['id', 'theaterType'] })
return res.json(findTypes)
} catch (error) {
return res.status(500).send(error.message || "상영관 정보 가져오는 중 에러 발생")
}
}
const submit = async (req, res) => {
try {
const { id } = req.body
let response = null
if (id) response = await Theater.update({ ...req.body }, { where: { id: id } })
else response = await Theater.create({ ...req.body })
return res.json(response)
} catch (error) {
return res.status(500).send(error.message || "상영관 정보 저장 중 에러 발생")
}
}
const remove = async (req, res) => {
try {
} catch (error) {
return res.status(500).send(error.message || "상영관 정보 삭제 중 에러 발생")
}
}
export default {
getAll,
getTypes,
submit,
remove,
getTheaterInfo
}
import jwt from "jsonwebtoken"; import jwt from "jsonwebtoken";
import config from "../config/app.config.js"; import config from "../config/app.config.js";
import { User, Role } from '../db/index.js'; import { User, Role } from '../db/index.js';
<<<<<<< HEAD
import fs from "fs"; import fs from "fs";
=======
<<<<<<< HEAD
>>>>>>> master
const getUser = async (req, res) => { const getUser = async (req, res) => {
try { try {
...@@ -17,6 +21,9 @@ const getUser = async (req, res) => { ...@@ -17,6 +21,9 @@ const getUser = async (req, res) => {
return res.status(500).send("유저를 가져오지 못했습니다."); return res.status(500).send("유저를 가져오지 못했습니다.");
} }
} }
=======
// import Twilio from "twilio";
>>>>>>> jiwon
const login = async (req, res) => { const login = async (req, res) => {
try { try {
...@@ -92,8 +99,8 @@ const compareId = async (req, res) => { ...@@ -92,8 +99,8 @@ const compareId = async (req, res) => {
} }
const confirmMbnum = async (req, res) => { const confirmMbnum = async (req, res) => {
const id = req.params.id; // const id = req.params.id;
const token = req.params.token; // const token = req.params.token;
// const client = Twilio(id, token); // const client = Twilio(id, token);
// // console.log(client); // // console.log(client);
...@@ -206,6 +213,7 @@ const comparePw = async (req, res) => { ...@@ -206,6 +213,7 @@ const comparePw = async (req, res) => {
} }
} }
<<<<<<< HEAD
const overlap = async (decoded, dataType, data) => { const overlap = async (decoded, dataType, data) => {
try { try {
let overlap = await User.findOne({ where: { id: decoded.id } }); let overlap = await User.findOne({ where: { id: decoded.id } });
...@@ -226,6 +234,9 @@ const overlap = async (decoded, dataType, data) => { ...@@ -226,6 +234,9 @@ const overlap = async (decoded, dataType, data) => {
} }
} }
=======
<<<<<<< HEAD
>>>>>>> master
const modifyUser = async (req, res) => { const modifyUser = async (req, res) => {
try { try {
const token = req.cookies.butterStudio; const token = req.cookies.butterStudio;
...@@ -256,6 +267,21 @@ const modifyUser = async (req, res) => { ...@@ -256,6 +267,21 @@ const modifyUser = async (req, res) => {
res.status(500).send("수정 에러. 나중에 다시 시도 해주세요"); res.status(500).send("수정 에러. 나중에 다시 시도 해주세요");
} }
}; };
=======
const getUserInfo = async (req,res)=>{
const {id} = req.body
console.log(id)
try {
const userInfo = await User.findOne({
where:{id:id},
attributes:["userId","email","nickname","birth","phoneNumber"]
})
res.json(userInfo)
} catch (error) {
console.log(error)
}
}
>>>>>>> jiwon
export default { export default {
getUser, getUser,
...@@ -264,8 +290,16 @@ export default { ...@@ -264,8 +290,16 @@ export default {
compareId, compareId,
confirmMbnum, confirmMbnum,
signup, signup,
<<<<<<< HEAD
getMember, getMember,
uploadProfile, uploadProfile,
=======
getNickName,
<<<<<<< HEAD
>>>>>>> master
comparePw, comparePw,
modifyUser modifyUser
=======
getUserInfo
>>>>>>> jiwon
} }
...@@ -4,6 +4,7 @@ import RoleModel from "../models/role.model.js"; ...@@ -4,6 +4,7 @@ import RoleModel from "../models/role.model.js";
import MovieModel from "../models/movie.model.js"; import MovieModel from "../models/movie.model.js";
import CinemaModel from "../models/cinema.model.js"; import CinemaModel from "../models/cinema.model.js";
import TheaterModel from "../models/theater.model.js"; import TheaterModel from "../models/theater.model.js";
import TheaterTypeModel from "../models/theatertype.model.js";
import TicketFeeModel from "../models/ticketfee.model.js"; import TicketFeeModel from "../models/ticketfee.model.js";
import TimeTableModel from '../models/role.model.js'; import TimeTableModel from '../models/role.model.js';
import ReservationModel from '../models/reservation.model.js'; import ReservationModel from '../models/reservation.model.js';
...@@ -30,6 +31,7 @@ const Role = RoleModel(sequelize) ...@@ -30,6 +31,7 @@ const Role = RoleModel(sequelize)
const Movie = MovieModel(sequelize) const Movie = MovieModel(sequelize)
const Cinema = CinemaModel(sequelize) const Cinema = CinemaModel(sequelize)
const Theater = TheaterModel(sequelize) const Theater = TheaterModel(sequelize)
const TheaterType = TheaterTypeModel(sequelize)
const TicketFee = TicketFeeModel(sequelize) const TicketFee = TicketFeeModel(sequelize)
const TimeTable = TimeTableModel(sequelize) const TimeTable = TimeTableModel(sequelize)
const Reservation = ReservationModel(sequelize) const Reservation = ReservationModel(sequelize)
...@@ -37,7 +39,9 @@ const Reservation = ReservationModel(sequelize) ...@@ -37,7 +39,9 @@ const Reservation = ReservationModel(sequelize)
User.belongsTo(Role); User.belongsTo(Role);
Role.hasOne(User); Role.hasOne(User);
TicketFee.hasOne(Theater, { foreignKey: "theaterType", targetKey: "theaterType", onDelete : "Cascade" }); Theater.belongsTo(TheaterType);
TicketFee.belongsTo(TheaterType, { onDelete: 'CASCADE' });
export { export {
sequelize, sequelize,
...@@ -46,6 +50,7 @@ export { ...@@ -46,6 +50,7 @@ export {
Movie, Movie,
Cinema, Cinema,
Theater, Theater,
TheaterType,
TicketFee, TicketFee,
TimeTable, TimeTable,
Reservation Reservation
......
...@@ -29,8 +29,8 @@ sequelize ...@@ -29,8 +29,8 @@ sequelize
password: "admin!", password: "admin!",
roleId: adminRole?.id, roleId: adminRole?.id,
}); });
}else{}
} else { }
app.listen(appConfig.port, () => { app.listen(appConfig.port, () => {
console.log(`Server is running on port ${appConfig.port}`); console.log(`Server is running on port ${appConfig.port}`);
}); });
...@@ -39,4 +39,4 @@ sequelize ...@@ -39,4 +39,4 @@ sequelize
console.log(err); console.log(err);
}); });
export default {} export default {}
\ No newline at end of file \ No newline at end of file
...@@ -18,7 +18,7 @@ const ReservationModel = (sequelize) => { ...@@ -18,7 +18,7 @@ const ReservationModel = (sequelize) => {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
}, },
row: { row: {
type: DataTypes.STRING, type: DataTypes.INTEGER,
}, },
col: { col: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
......
...@@ -6,12 +6,16 @@ const TheaterModel = (sequelize) => { ...@@ -6,12 +6,16 @@ const TheaterModel = (sequelize) => {
const Theater = sequelize.define( const Theater = sequelize.define(
"theater", "theater",
{ {
theaterNum: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true,
},
theaterName: {
type: DataTypes.STRING
}, },
rows: { rows: {
type: DataTypes.STRING, type: DataTypes.INTEGER,
}, },
columns: { columns: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
......
import Sequelize from "sequelize";
const { DataTypes } = Sequelize;
const TheaterTypeModel = (sequelize) => {
const TheaterType = sequelize.define(
"theatertype",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
theaterTypeName: {
type: DataTypes.STRING,
unique: true
}
},
{
timestamps: true,
freezeTableName: true,
tableName: "theatertypes"
}
);
return TheaterType;
};
export default TheaterTypeModel;
\ No newline at end of file
...@@ -11,9 +11,6 @@ const TicketFeeModel = (sequelize) => { ...@@ -11,9 +11,6 @@ const TicketFeeModel = (sequelize) => {
primaryKey: true, primaryKey: true,
autoIncrement: true, autoIncrement: true,
}, },
theaterType: {
type: DataTypes.STRING
},
weekdays: { weekdays: {
type: DataTypes.INTEGER type: DataTypes.INTEGER
}, },
......
import express from "express"; import express from "express";
import userRouter from './user.route.js' import userRouter from './user.route.js'
import movieRouter from './movie.route.js' import movieRouter from './movie.route.js'
import theaterRouter from "./theater.route.js";
import cinemaRouter from "./cinema.route.js"; import cinemaRouter from "./cinema.route.js";
import kakaopayRouter from "./kakaopay.route.js"; import kakaopayRouter from "./kakaopay.route.js";
import emailRouter from './email.route.js' import emailRouter from './email.route.js'
import theaterRouter from './theater.route.js'
import reservationRouter from './reservation.route.js'
const router = express.Router(); const router = express.Router();
...@@ -12,5 +15,7 @@ router.use('/auth', userRouter) ...@@ -12,5 +15,7 @@ router.use('/auth', userRouter)
router.use('/kakaopay',kakaopayRouter) router.use('/kakaopay',kakaopayRouter)
router.use('/email',emailRouter) router.use('/email',emailRouter)
router.use('/info', cinemaRouter) router.use('/info', cinemaRouter)
router.use('/theater', theaterRouter)
router.use('/reservation', reservationRouter)
export default router; export default router;
\ No newline at end of file
import express from "express";
import ReservationCtrl from "../controllers/reservation.controller.js";
const router = express.Router();
router.route('/findreservation')
.post(ReservationCtrl.findReservation)
export default router;
\ No newline at end of file
import express from "express";
import theaterCtrl from "../controllers/theater.controller.js";
const router = express.Router();
router.route("/getInfo")
.post(theaterCtrl.getTheaterInfo)
router
.route("/")
.get(theaterCtrl.getAll)
.put(theaterCtrl.submit)
.delete(theaterCtrl.remove)
router
.route("/type")
.get(theaterCtrl.getTypes)
export default router;
...@@ -46,4 +46,11 @@ router ...@@ -46,4 +46,11 @@ router
.route("/:id/:token") .route("/:id/:token")
.get(userCtrl.confirmMbnum) .get(userCtrl.confirmMbnum)
// router
// .route("/:iddd")
// .get(userCtrl.getNickName)
router.route('/getuserinfo')
.post(userCtrl.getUserInfo)
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