Commit 05ec1de9 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

reservation/moviechart/moviecomming

parent 4517a35f
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, Guest } from '../db/index.js'; import { User, Role, Guest, Reservation } from '../db/index.js';
import fs from "fs"; import fs from "fs";
import CryptoJS from "crypto-js"; import CryptoJS from "crypto-js";
import axios from "axios"; import axios from "axios";
...@@ -135,11 +135,11 @@ const confirmMbnum = async (req, res) => { ...@@ -135,11 +135,11 @@ const confirmMbnum = async (req, res) => {
try { try {
const phoneNumber = req.params.phone; const phoneNumber = req.params.phone;
console.log(phoneNumber); console.log(phoneNumber);
//인증번호 생성 //인증번호 생성
const verifyCode = Math.floor(Math.random() * (999999 - 100000)) + 100000; const verifyCode = Math.floor(Math.random() * (999999 - 100000)) + 100000;
console.log("verifyCode : ",verifyCode); console.log("verifyCode : ", verifyCode);
let result = await axios({ let result = await axios({
method: method, method: method,
json: true, json: true,
...@@ -185,12 +185,12 @@ const confirmNum = async (req, res) => { ...@@ -185,12 +185,12 @@ const confirmNum = async (req, res) => {
try { try {
const verifyCode = inherentNum; const verifyCode = inherentNum;
const confirmNum = req.params.num; const confirmNum = req.params.num;
if(!verifyCode){ if (!verifyCode) {
res.send("재전송") res.send("재전송")
}else{ } else {
if (confirmNum !== verifyCode) { if (confirmNum !== verifyCode) {
res.send("실패"); res.send("실패");
}else { } else {
res.send("성공"); res.send("성공");
} }
} }
...@@ -222,7 +222,7 @@ const signup = async (req, res) => { ...@@ -222,7 +222,7 @@ const signup = async (req, res) => {
birth: userBirthday, birth: userBirthday,
phoneNumber: userMbnum, phoneNumber: userMbnum,
password: userPassword, password: userPassword,
img:"", img: "",
roleId: role.id roleId: role.id
}); });
res.json(newUser); res.json(newUser);
...@@ -359,7 +359,7 @@ const getUserInfo = async (req, res) => { ...@@ -359,7 +359,7 @@ const getUserInfo = async (req, res) => {
try { try {
const userInfo = await User.findOne({ const userInfo = await User.findOne({
where: { id: id }, where: { id: id },
attributes: ["id","userId", "email", "nickname", "birth", "phoneNumber"] attributes: ["id", "userId", "email", "nickname", "birth", "phoneNumber"]
}) })
console.log(userInfo) console.log(userInfo)
res.json(userInfo) res.json(userInfo)
...@@ -378,14 +378,38 @@ const saveGuestInfo = async (req, res) => { ...@@ -378,14 +378,38 @@ const saveGuestInfo = async (req, res) => {
phoneNumber: phoneNumber, phoneNumber: phoneNumber,
password: password, password: password,
}); });
// console.log(newGuest)
res.clearCookie(config.cookieName);
const token = jwt.sign({id: newGuest.id, role: "user"}, config.jwtSecret, {
expiresIn: config.jwtExpires,
});
res.cookie(config.cookieName,token , {
maxAge: config.cookieMaxAge,
path: "/",
httpOnly: config.env === "production",
secure: config.env === "production",
})
res.json(newGuest); res.json(newGuest);
} catch (error) { } catch (error) {
console.log(error)
res.status(500).send("비회원정보 등록 실패"); res.status(500).send("비회원정보 등록 실패");
} }
} }
const getGuestInfo = async (req,res) => {
const {guestId} = req.params
// console.log(req.body)
try {
const guestInfo = await Guest.findOne({
where: {
id:guestId
}
})
// console.log("guestInfo====", guestInfo)
res.json(guestInfo)
} catch (error) {
res.status(500).send("비회원정보 불러오기 실패");
}
}
export default { export default {
getUser, getUser,
login, login,
...@@ -399,5 +423,6 @@ export default { ...@@ -399,5 +423,6 @@ export default {
saveGuestInfo, saveGuestInfo,
getMember, getMember,
uploadProfile, uploadProfile,
getUserInfo getUserInfo,
getGuestInfo
} }
...@@ -7,12 +7,9 @@ router ...@@ -7,12 +7,9 @@ router
.route("/") .route("/")
.get(movieCtrl.getListfromDB) .get(movieCtrl.getListfromDB)
router
.route('/showmovies/:category')
.get(movieCtrl.getMovieById)
router router
.route('/movielist') .route('/movielist/:category')
.get(movieCtrl.getMovieList) .get(movieCtrl.getMovieList)
router router
...@@ -38,6 +35,5 @@ router ...@@ -38,6 +35,5 @@ router
.post(movieCtrl.create) .post(movieCtrl.create)
.delete(movieCtrl.remove) .delete(movieCtrl.remove)
router.param('category', movieCtrl.getMovieByCategory)
export default router; export default router;
\ No newline at end of file
...@@ -5,9 +5,13 @@ const router = express.Router(); ...@@ -5,9 +5,13 @@ const router = express.Router();
router.route('/findreservation') router.route('/findreservation')
.post(ReservationCtrl.findReservation) .post(ReservationCtrl.findReservedSeats)
.get(ReservationCtrl.findReservation)
router.route('/findonereservation')
.post(ReservationCtrl.findOneReservation)
router.route('/save') router.route('/save')
.post(ReservationCtrl.saveReservation) .post(ReservationCtrl.saveReservation)
export default router; export default router;
\ No newline at end of file
...@@ -25,7 +25,7 @@ router ...@@ -25,7 +25,7 @@ router
router router
.post("/profile", upload.single("image"), userCtrl.uploadProfile) .post("/profile", upload.single("image"), userCtrl.uploadProfile)
router router
.route("/modify") .route("/modify")
.post(userCtrl.modifyUser) .post(userCtrl.modifyUser)
...@@ -38,9 +38,6 @@ router ...@@ -38,9 +38,6 @@ router
.route("/pw/:pw") .route("/pw/:pw")
.get(userCtrl.comparePw) .get(userCtrl.comparePw)
router
.route("/:userId")
.get(userCtrl.compareId)
router router
.route("/phone/:phone") .route("/phone/:phone")
...@@ -56,4 +53,11 @@ router.route('/getuserinfo') ...@@ -56,4 +53,11 @@ router.route('/getuserinfo')
router.route('/guest/save') router.route('/guest/save')
.post(userCtrl.saveGuestInfo) .post(userCtrl.saveGuestInfo)
router.route('/guestinfo/:guestId')
.get(userCtrl.getGuestInfo)
router
.route("/:userId")
.get(userCtrl.compareId)
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