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

Merge branch 'master' into gyumin

parents dca77d17 44b5a715
import nodemailer from "nodemailer"
const SendMail = async (req,res) => {
// console.log(req.body)
const {email} = req.body
console.log(email)
const sendMail = async (email) => {
const {email, title, cinema,selectedTheater, time, nickname} = req.body
const selectedSeats = req.body.selectedSeats
const sendMail = async (email,title, cinema,selectedTheater, time, nickname, selectedSeats) => {
// 메일을 전달해줄 객체
const transporter = nodemailer.createTransport({
// service: "gmail",
host: 'smtp.gmail.com',
port: 465,
secure: true,
......@@ -16,7 +14,6 @@ const SendMail = async (req,res) => {
user: "angelayoon99@gmail.com",
clientId: process.env.GMAIL_CLIENTID,
clientSecret: process.env.GMAIL_CLIENTSECRET,
accessToken: process.env.GMAIL_ACCESS_TOKEN,
refreshToken: process.env.GMAIL_REFRESH_TOKEN,
},
tls: {
......@@ -26,10 +23,10 @@ const SendMail = async (req,res) => {
// 메일 옵션
const mailOptions = {
from: `윤지원 <angelayoon99@gmail.com>`,
to: "jiwon5393@naver.com",
subject: "사용자 계정 확인용 메일.",
text: "Test Mail from Test Server.",
from: `${cinema} <angelayoon99@gmail.com>`,
to: `${email}`,
subject: `${cinema} 예매확인내역: ${title}`,
text: `${nickname}님의 예매: ${title} / ${cinema} / ${selectedTheater}관 / 일시: ${time} / ${selectedSeats} /`,
};
// 메일 전송
......@@ -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 config from "../config/app.config.js";
import { User, Role } from '../db/index.js';
<<<<<<< HEAD
import fs from "fs";
=======
<<<<<<< HEAD
>>>>>>> master
const getUser = async (req, res) => {
try {
......@@ -17,6 +21,9 @@ const getUser = async (req, res) => {
return res.status(500).send("유저를 가져오지 못했습니다.");
}
}
=======
// import Twilio from "twilio";
>>>>>>> jiwon
const login = async (req, res) => {
try {
......@@ -92,8 +99,8 @@ const compareId = async (req, res) => {
}
const confirmMbnum = async (req, res) => {
const id = req.params.id;
const token = req.params.token;
// const id = req.params.id;
// const token = req.params.token;
// const client = Twilio(id, token);
// // console.log(client);
......@@ -206,6 +213,7 @@ const comparePw = async (req, res) => {
}
}
<<<<<<< HEAD
const overlap = async (decoded, dataType, data) => {
try {
let overlap = await User.findOne({ where: { id: decoded.id } });
......@@ -226,6 +234,9 @@ const overlap = async (decoded, dataType, data) => {
}
}
=======
<<<<<<< HEAD
>>>>>>> master
const modifyUser = async (req, res) => {
try {
const token = req.cookies.butterStudio;
......@@ -256,6 +267,21 @@ const modifyUser = async (req, res) => {
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 {
getUser,
......@@ -264,8 +290,16 @@ export default {
compareId,
confirmMbnum,
signup,
<<<<<<< HEAD
getMember,
uploadProfile,
=======
getNickName,
<<<<<<< HEAD
>>>>>>> master
comparePw,
modifyUser
=======
getUserInfo
>>>>>>> jiwon
}
......@@ -4,6 +4,7 @@ import RoleModel from "../models/role.model.js";
import MovieModel from "../models/movie.model.js";
import CinemaModel from "../models/cinema.model.js";
import TheaterModel from "../models/theater.model.js";
import TheaterTypeModel from "../models/theatertype.model.js";
import TicketFeeModel from "../models/ticketfee.model.js";
import TimeTableModel from '../models/role.model.js';
import ReservationModel from '../models/reservation.model.js';
......@@ -30,6 +31,7 @@ const Role = RoleModel(sequelize)
const Movie = MovieModel(sequelize)
const Cinema = CinemaModel(sequelize)
const Theater = TheaterModel(sequelize)
const TheaterType = TheaterTypeModel(sequelize)
const TicketFee = TicketFeeModel(sequelize)
const TimeTable = TimeTableModel(sequelize)
const Reservation = ReservationModel(sequelize)
......@@ -37,7 +39,9 @@ const Reservation = ReservationModel(sequelize)
User.belongsTo(Role);
Role.hasOne(User);
TicketFee.hasOne(Theater, { foreignKey: "theaterType", targetKey: "theaterType", onDelete : "Cascade" });
Theater.belongsTo(TheaterType);
TicketFee.belongsTo(TheaterType, { onDelete: 'CASCADE' });
export {
sequelize,
......@@ -46,6 +50,7 @@ export {
Movie,
Cinema,
Theater,
TheaterType,
TicketFee,
TimeTable,
Reservation
......
......@@ -29,8 +29,8 @@ sequelize
password: "admin!",
roleId: adminRole?.id,
});
}else{}
} else { }
app.listen(appConfig.port, () => {
console.log(`Server is running on port ${appConfig.port}`);
});
......@@ -39,4 +39,4 @@ sequelize
console.log(err);
});
export default {}
\ No newline at end of file
export default {}
\ No newline at end of file
......@@ -18,7 +18,7 @@ const ReservationModel = (sequelize) => {
type: DataTypes.INTEGER,
},
row: {
type: DataTypes.STRING,
type: DataTypes.INTEGER,
},
col: {
type: DataTypes.INTEGER,
......
......@@ -6,12 +6,16 @@ const TheaterModel = (sequelize) => {
const Theater = sequelize.define(
"theater",
{
theaterNum: {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
theaterName: {
type: DataTypes.STRING
},
rows: {
type: DataTypes.STRING,
type: DataTypes.INTEGER,
},
columns: {
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) => {
primaryKey: true,
autoIncrement: true,
},
theaterType: {
type: DataTypes.STRING
},
weekdays: {
type: DataTypes.INTEGER
},
......
import express from "express";
import userRouter from './user.route.js'
import movieRouter from './movie.route.js'
import theaterRouter from "./theater.route.js";
import cinemaRouter from "./cinema.route.js";
import kakaopayRouter from "./kakaopay.route.js";
import emailRouter from './email.route.js'
import theaterRouter from './theater.route.js'
import reservationRouter from './reservation.route.js'
const router = express.Router();
......@@ -12,5 +15,7 @@ router.use('/auth', userRouter)
router.use('/kakaopay',kakaopayRouter)
router.use('/email',emailRouter)
router.use('/info', cinemaRouter)
router.use('/theater', theaterRouter)
router.use('/reservation', reservationRouter)
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;
......@@ -43,7 +43,14 @@ router
.get(userCtrl.compareId)
router
.route("/:id/:token")
.route("/:id/:token")
.get(userCtrl.confirmMbnum)
// router
// .route("/:iddd")
// .get(userCtrl.getNickName)
router.route('/getuserinfo')
.post(userCtrl.getUserInfo)
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