Commit 26e786c6 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

Merge branch 'jiwon'

parents dd1c9aee 54b1ec39
import { Theater, TheaterType } from "../db/index.js"; import { Theater, TheaterType } from "../db/index.js";
const getTheaterInfo = async (req, res) => { const getTheaterInfo = async (req, res) => {
const { theaterNum } = req.body const { theaterName } = req.body
try { try {
const theaterInfo = await Theater.findOne({ const theaterInfo = await Theater.findOne({
where: { theaterNum: theaterNum }, where: { theaterName: String(theaterName) },
attributes: ['theaterNum', 'rows', 'columns', 'theaterType'] attributes: ['theaterName', 'rows', 'columns']
}) })
// console.log("theaterInfo====",theaterInfo) // console.log("theaterInfo====",theaterInfo)
return res.json(theaterInfo) return res.json(theaterInfo)
......
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, Guest } from '../db/index.js';
<<<<<<< HEAD
const getUser = async (req, res) => { const getUser = async (req, res) => {
try { try {
if (req.cookies) { if (req.cookies.butterStudio) {
const token = req.cookies.butterStudio; const token = req.cookies.butterStudio;
const decoded = jwt.verify(token, config.jwtSecret); const decoded = jwt.verify(token, config.jwtSecret);
res.json(decoded); res.json(decoded);
...@@ -17,9 +16,6 @@ const getUser = async (req, res) => { ...@@ -17,9 +16,6 @@ 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 {
...@@ -175,7 +171,6 @@ const comparePw = async (req, res) => { ...@@ -175,7 +171,6 @@ const comparePw = async (req, res) => {
} }
} }
<<<<<<< HEAD
const modifyUser = async (req, res) => { const modifyUser = async (req, res) => {
try { try {
const token = req.cookies.butterStudio; const token = req.cookies.butterStudio;
...@@ -189,10 +184,10 @@ const modifyUser = async (req, res) => { ...@@ -189,10 +184,10 @@ const modifyUser = async (req, res) => {
if (decoded) { if (decoded) {
let user = await User.findOne({ where: { id: decoded.id } }); let user = await User.findOne({ where: { id: decoded.id } });
await user.update({ await user.update({
email : userEmail, email: userEmail,
nickname : userNickName, nickname: userNickName,
phoneNumber : userMbnum, phoneNumber: userMbnum,
password : userPassword, password: userPassword,
}); });
res.json(user); res.json(user);
} }
...@@ -202,21 +197,37 @@ const modifyUser = async (req, res) => { ...@@ -202,21 +197,37 @@ const modifyUser = async (req, res) => {
res.status(500).send("수정 에러. 나중에 다시 시도 해주세요"); res.status(500).send("수정 에러. 나중에 다시 시도 해주세요");
} }
}; };
======= const getUserInfo = async (req, res) => {
const getUserInfo = async (req,res)=>{ const { id } = req.body
const {id} = req.body
console.log(id) console.log(id)
try { try {
const userInfo = await User.findOne({ const userInfo = await User.findOne({
where:{id:id}, where: { id: id },
attributes:["userId","email","nickname","birth","phoneNumber"] attributes: ["id","userId", "email", "nickname", "birth", "phoneNumber"]
}) })
res.json(userInfo) res.json(userInfo)
} catch (error) {
res.status(500).send("회원정보 불러오기 실패");
}
}
const saveGuestInfo = async (req, res) => {
const { name, email, birth, phoneNumber, password } = req.body
try {
const newGuest = await Guest.create({
name: name,
email: email,
birth: birth,
phoneNumber: phoneNumber,
password: password,
});
res.json(newGuest);
} catch (error) { } catch (error) {
console.log(error) console.log(error)
res.status(500).send("비회원정보 등록 실패");
} }
} }
>>>>>>> jiwon
export default { export default {
getUser, getUser,
...@@ -226,10 +237,8 @@ export default { ...@@ -226,10 +237,8 @@ export default {
confirmMbnum, confirmMbnum,
signup, signup,
getNickName, getNickName,
<<<<<<< HEAD
comparePw, comparePw,
modifyUser modifyUser,
======= getUserInfo,
getUserInfo saveGuestInfo
>>>>>>> jiwon
} }
...@@ -8,6 +8,7 @@ import TheaterTypeModel from "../models/theatertype.model.js"; ...@@ -8,6 +8,7 @@ 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';
import GuestModel from '../models/guest.model.js'
import dbConfig from "../config/db.config.js"; import dbConfig from "../config/db.config.js";
const sequelize = new Sequelize( const sequelize = new Sequelize(
...@@ -35,6 +36,7 @@ const TheaterType = TheaterTypeModel(sequelize) ...@@ -35,6 +36,7 @@ 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)
const Guest = GuestModel(sequelize)
User.belongsTo(Role); User.belongsTo(Role);
Role.hasOne(User); Role.hasOne(User);
...@@ -53,5 +55,6 @@ export { ...@@ -53,5 +55,6 @@ export {
TheaterType, TheaterType,
TicketFee, TicketFee,
TimeTable, TimeTable,
Reservation Reservation,
Guest
} }
\ No newline at end of file
...@@ -19,7 +19,7 @@ sequelize ...@@ -19,7 +19,7 @@ sequelize
); );
const adminRole = await Role.findOne({ where: { name: "admin" } }); const adminRole = await Role.findOne({ where: { name: "admin" } });
console.log("adminRole : ", adminRole); // console.log("adminRole : ", adminRole);
if (!adminRole) { if (!adminRole) {
await User.create({ await User.create({
userId: "admin", userId: "admin",
......
import Sequelize from "sequelize";
const { DataTypes } = Sequelize;
const GuestModel = (sequelize) => {
const Guest = sequelize.define(
"guest",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: DataTypes.STRING,
},
email: {
type: DataTypes.STRING,
},
birth: {
type: DataTypes.STRING,
},
phoneNumber: {
type: DataTypes.STRING
},
password: {
type: DataTypes.STRING,
},
},
{
timestamps: true,
freezeTableName: true,
tableName: "guests",
}
);
return Guest
};
export default GuestModel
\ No newline at end of file
...@@ -26,11 +26,14 @@ const ReservationModel = (sequelize) => { ...@@ -26,11 +26,14 @@ const ReservationModel = (sequelize) => {
timetable:{ timetable:{
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
}, },
userType:{
type: DataTypes.STRING,
},
user:{ user:{
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
}, },
payment:{ payment:{
type: DataTypes.INTEGER, type: DataTypes.STRING,
} }
}, },
{ {
......
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'
......
...@@ -7,4 +7,7 @@ const router = express.Router(); ...@@ -7,4 +7,7 @@ const router = express.Router();
router.route('/findreservation') router.route('/findreservation')
.post(ReservationCtrl.findReservation) .post(ReservationCtrl.findReservation)
router.route('/save')
.post(ReservationCtrl.saveReservation)
export default router; export default router;
\ No newline at end of file
...@@ -40,11 +40,10 @@ router ...@@ -40,11 +40,10 @@ router
.route("/:id/:token") .route("/:id/:token")
.get(userCtrl.confirmMbnum) .get(userCtrl.confirmMbnum)
// router
// .route("/:iddd")
// .get(userCtrl.getNickName)
router.route('/getuserinfo') router.route('/getuserinfo')
.post(userCtrl.getUserInfo) .post(userCtrl.getUserInfo)
router.route('/guest/save')
.post(userCtrl.saveGuestInfo)
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