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";
const getTheaterInfo = async (req, res) => {
const { theaterNum } = req.body
const { theaterName } = req.body
try {
const theaterInfo = await Theater.findOne({
where: { theaterNum: theaterNum },
attributes: ['theaterNum', 'rows', 'columns', 'theaterType']
where: { theaterName: String(theaterName) },
attributes: ['theaterName', 'rows', 'columns']
})
// console.log("theaterInfo====",theaterInfo)
return res.json(theaterInfo)
......
import jwt from "jsonwebtoken";
import config from "../config/app.config.js";
import { User, Role } from '../db/index.js';
<<<<<<< HEAD
import { User, Role, Guest } from '../db/index.js';
const getUser = async (req, res) => {
try {
if (req.cookies) {
if (req.cookies.butterStudio) {
const token = req.cookies.butterStudio;
const decoded = jwt.verify(token, config.jwtSecret);
res.json(decoded);
......@@ -17,9 +16,6 @@ const getUser = async (req, res) => {
return res.status(500).send("유저를 가져오지 못했습니다.");
}
}
=======
// import Twilio from "twilio";
>>>>>>> jiwon
const login = async (req, res) => {
try {
......@@ -175,24 +171,23 @@ const comparePw = async (req, res) => {
}
}
<<<<<<< HEAD
const modifyUser = async (req, res) => {
try {
const token = req.cookies.butterStudio;
const decoded = jwt.verify(token, config.jwtSecret);
const { userEmail, userNickName, userMbnum, userPassword } = req.body;
const emailOverlap = await User.findOne({ where: { email: userEmail } });
if (emailOverlap) {
return res.status(422).send(`이미 있는 이메일입니다.`);
} else {
if (decoded) {
let user = await User.findOne({ where: { id: decoded.id } });
await user.update({
email : userEmail,
nickname : userNickName,
phoneNumber : userMbnum,
password : userPassword,
email: userEmail,
nickname: userNickName,
phoneNumber: userMbnum,
password: userPassword,
});
res.json(user);
}
......@@ -202,21 +197,37 @@ const modifyUser = async (req, res) => {
res.status(500).send("수정 에러. 나중에 다시 시도 해주세요");
}
};
=======
const getUserInfo = async (req,res)=>{
const {id} = req.body
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"]
where: { id: id },
attributes: ["id","userId", "email", "nickname", "birth", "phoneNumber"]
})
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) {
console.log(error)
res.status(500).send("비회원정보 등록 실패");
}
}
>>>>>>> jiwon
export default {
getUser,
......@@ -226,10 +237,8 @@ export default {
confirmMbnum,
signup,
getNickName,
<<<<<<< HEAD
comparePw,
modifyUser
=======
getUserInfo
>>>>>>> jiwon
modifyUser,
getUserInfo,
saveGuestInfo
}
......@@ -8,6 +8,7 @@ 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';
import GuestModel from '../models/guest.model.js'
import dbConfig from "../config/db.config.js";
const sequelize = new Sequelize(
......@@ -35,6 +36,7 @@ const TheaterType = TheaterTypeModel(sequelize)
const TicketFee = TicketFeeModel(sequelize)
const TimeTable = TimeTableModel(sequelize)
const Reservation = ReservationModel(sequelize)
const Guest = GuestModel(sequelize)
User.belongsTo(Role);
Role.hasOne(User);
......@@ -53,5 +55,6 @@ export {
TheaterType,
TicketFee,
TimeTable,
Reservation
Reservation,
Guest
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ sequelize
);
const adminRole = await Role.findOne({ where: { name: "admin" } });
console.log("adminRole : ", adminRole);
// console.log("adminRole : ", adminRole);
if (!adminRole) {
await User.create({
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) => {
timetable:{
type: DataTypes.INTEGER,
},
userType:{
type: DataTypes.STRING,
},
user:{
type: DataTypes.INTEGER,
},
payment:{
type: DataTypes.INTEGER,
type: DataTypes.STRING,
}
},
{
......
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'
......
......@@ -7,4 +7,7 @@ const router = express.Router();
router.route('/findreservation')
.post(ReservationCtrl.findReservation)
router.route('/save')
.post(ReservationCtrl.saveReservation)
export default router;
\ No newline at end of file
......@@ -19,7 +19,7 @@ router
.route("/signup")
.post(userCtrl.signup)
router
.route("/modify")
.post(userCtrl.modifyUser)
......@@ -40,11 +40,10 @@ router
.route("/:id/:token")
.get(userCtrl.confirmMbnum)
// router
// .route("/:iddd")
// .get(userCtrl.getNickName)
router.route('/getuserinfo')
.post(userCtrl.getUserInfo)
router.route('/guest/save')
.post(userCtrl.saveGuestInfo)
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