Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
butter-studio
Commits
eacc9ce9
Commit
eacc9ce9
authored
Aug 07, 2021
by
한규민
Browse files
Merge branch 'master' into gyumin
parents
19251ba0
c6fcbcbe
Changes
58
Hide whitespace changes
Inline
Side-by-side
server/controllers/movie.controller.js
View file @
eacc9ce9
...
...
@@ -3,52 +3,12 @@ import { Movie } from '../db/index.js'
import
sequelize
from
'
sequelize
'
const
{
Op
}
=
sequelize
const
get
MovieByCategory
=
async
(
req
,
res
,
next
,
category
)
=>
{
const
get
ListfromDB
=
async
(
req
,
res
)
=>
{
try
{
console
.
log
(
category
)
const
TMDBmovieIds
=
[]
const
movieIds
=
[]
console
.
log
(
process
.
env
.
TMDB_APP_KEY
)
const
response
=
await
axios
.
get
(
`https://api.themoviedb.org/3/movie/
${
category
}
?api_key=
${
process
.
env
.
TMDB_APP_KEY
}
&language=ko-KR&page=1`
)
console
.
log
(
response
.
data
)
const
TMDBmovies
=
response
.
data
.
results
TMDBmovies
.
forEach
(
element
=>
{
TMDBmovieIds
.
push
(
element
.
id
)
})
console
.
log
(
TMDBmovies
)
const
responseAfterCompare
=
await
Movie
.
findAll
({
where
:
{
movieId
:
{
[
Op
.
or
]:
TMDBmovieIds
}
}
})
responseAfterCompare
.
forEach
(
el
=>
{
movieIds
.
push
(
el
.
movieId
)
})
console
.
log
(
'
movieIds=
'
,
movieIds
)
req
.
movieIds
=
movieIds
next
()
const
findAll
=
await
Movie
.
findAll
({
attributes
:
[
'
movieId
'
,
'
title
'
,
'
release_date
'
]
})
res
.
json
(
findAll
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
영화 가져오기 중 에러 발생
"
);
}
}
const
getMovieById
=
async
(
req
,
res
)
=>
{
try
{
const
movieIds
=
req
.
movieIds
console
.
log
(
movieIds
)
const
elements
=
await
Promise
.
all
(
movieIds
.
map
(
async
(
movieId
)
=>
{
const
movie
=
await
axios
.
get
(
`https://api.themoviedb.org/3/movie/
${
movieId
}
?api_key=
${
process
.
env
.
TMDB_APP_KEY
}
&language=ko-KR`
)
return
movie
.
data
})
)
console
.
log
(
elements
)
res
.
json
(
elements
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
영화 가져오기 중 에러 발생
"
);
return
res
.
status
(
500
).
send
(
error
.
message
||
"
영화 목록 가져오기 중 에러 발생
"
);
}
}
...
...
@@ -66,13 +26,14 @@ const movieforAdmin = async (req, res) => {
if
(
findDirectors
.
length
!==
0
)
{
const
name
=
findDirectors
.
reduce
((
acc
,
cur
,
idx
)
=>
{
if
(
idx
!==
0
)
return
acc
+
'
,
'
+
cur
.
name
else
return
acc
+
cur
.
name
},
''
)
else
return
acc
+
cur
.
name
},
''
)
newObj
.
name
=
name
}
else
newObj
.
name
=
"
없음
"
return
newObj
}))
findDirectorResult
.
forEach
(
element
=>
TMDBmovies
.
forEach
(
movie
=>
{
findDirectorResult
.
forEach
(
element
=>
TMDBmovies
.
forEach
(
movie
=>
{
if
(
element
.
id
===
movie
.
id
)
movie
.
director
=
element
.
name
}))
const
responseAfterCompare
=
await
Movie
.
findAll
({
...
...
@@ -104,22 +65,56 @@ const getAllMovie = async (req, res, next) => {
}
}
const
getMovieList
=
async
(
req
,
res
)
=>
{
const
getMovieList
=
async
(
req
,
res
)
=>
{
const
{
category
}
=
req
.
params
// console.log(category)
try
{
const
movieList
=
await
Movie
.
findAll
()
// console.log(movieList)
const
movieIds
=
[]
const
movieIds
=
[]
movieList
.
forEach
(
el
=>
{
movieIds
.
push
(
el
.
movieId
)
})
const
elements
=
await
Promise
.
all
(
movieIds
.
map
(
async
(
movieId
)
=>
{
const
movie
=
await
axios
.
get
(
`https://api.themoviedb.org/3/movie/
${
movieId
}
?api_key=
${
process
.
env
.
TMDB_APP_KEY
}
&language=ko-KR`
)
return
movie
.
data
const
cols
=
await
Movie
.
findOne
({
where
:
{
"
movieId
"
:
movieId
},
attributes
:
[
"
ticket_sales
"
,
"
vote_average
"
]
})
const
totalReservationRate
=
Movie
.
sum
(
'
ticket_sales
'
)
const
rate
=
await
Promise
.
all
(
cols
.
ticket_sales
/
totalReservationRate
*
100
)
return
{
...
movie
.
data
,
ticket_sales
:
rate
,
vote_average
:
cols
.
vote_average
}
})
)
if
(
category
===
"
popular
"
)
{
for
(
let
i
=
0
;
i
<
elements
.
length
;
i
++
)
{
if
(
new
Date
(
elements
[
i
].
release_date
)
>
new
Date
())
{
elements
.
splice
(
i
,
1
);
i
--
;
}
}
elements
.
sort
(
function
(
a
,
b
)
{
return
b
.
popularity
-
a
.
popularity
})
res
.
json
(
elements
)
}
else
if
(
category
===
"
upcoming
"
)
{
for
(
let
i
=
0
;
i
<
elements
.
length
;
i
++
)
{
if
(
new
Date
(
elements
[
i
].
release_date
)
<=
new
Date
())
{
elements
.
splice
(
i
,
1
);
i
--
;
}
}
elements
.
sort
(
function
(
a
,
b
)
{
return
a
.
release_date
-
b
.
release_date
})
res
.
json
(
elements
)
}
else
{
elements
.
sort
(
function
(
a
,
b
)
{
return
a
.
title
-
b
.
title
})
)
console
.
log
(
elements
)
res
.
json
(
elements
)
res
.
json
(
elements
)
}
}
catch
(
error
)
{
console
.
log
(
error
)
}
...
...
@@ -184,8 +179,7 @@ const findaboutAll = async (req, res, next) => {
}
export
default
{
getMovieByCategory
,
getMovieById
,
getListfromDB
,
getAllMovie
,
getMovieList
,
create
,
...
...
server/controllers/reservation.controller.js
View file @
eacc9ce9
import
axios
from
'
axios
'
import
{
Reservation
,
Theater
}
from
'
../db/index.js
'
import
{
Movie
,
Reservation
,
Theater
}
from
'
../db/index.js
'
import
sequelize
from
'
sequelize
'
const
{
Op
}
=
sequelize
const
findReserv
ation
=
async
(
req
,
res
)
=>
{
const
{
timetable
}
=
req
.
body
const
findReserv
edSeats
=
async
(
req
,
res
)
=>
{
const
{
timetable
}
=
req
.
body
try
{
const
reservedSeats
=
await
Reservation
.
findAll
({
where
:
{
timetable
:
timetable
timetable
:
timetable
}
})
res
.
json
(
reservedSeats
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
이미 예매되어있는 좌석을 찾는 중 오류발생
"
)
res
.
status
(
500
).
send
(
error
.
message
||
"
이미 예매되어있는 좌석을 찾는 중 오류발생
"
)
}
}
const
findReservation
=
async
(
req
,
res
)
=>
{
const
{
user
}
=
req
.
body
try
{
const
reservation
=
await
Reservation
.
findAll
({
where
:
{
user
:
user
}
})
res
.
json
(
reservation
)
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
error
.
message
||
"
예매 내역들을 찾는 중 오류발생
"
)
}
}
const
findOneReservation
=
async
(
req
,
res
)
=>
{
const
{
userType
,
user
}
=
req
.
body
try
{
const
reservation
=
await
Reservation
.
findAll
({
where
:
{
userType
:
userType
,
user
:
user
},
})
console
.
log
(
reservation
)
res
.
json
(
reservation
)
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
error
.
message
||
"
예매 내역을 찾는 중 오류 발생
"
)
}
}
const
saveReservation
=
async
(
req
,
res
)
=>
{
const
{
movieId
,
selectedTheater
,
timetable
,
payment
,
user
,
userType
}
=
req
.
body
const
rows
=
req
.
body
.
selectedSeats
.
map
(
el
=>
el
.
split
(
'
-
'
)[
0
])
const
cols
=
req
.
body
.
selectedSeats
.
map
(
el
=>
el
.
split
(
'
-
'
)[
1
])
try
{
for
(
let
index
=
0
;
index
<
rows
.
length
;
index
++
)
{
const
reservation
=
await
Reservation
.
create
({
user
:
user
,
userType
:
userType
,
movieId
:
movieId
,
theater
:
selectedTheater
,
row
:
rows
[
index
],
col
:
cols
[
index
],
timetable
:
timetable
,
payment
:
payment
})
}
const
movie
=
await
Movie
.
findOne
({
where
:
{
movieId
:
movieId
}
})
movie
.
ticket_sales
++
await
movie
.
save
();
res
.
json
({
message
:
'
200 OK
'
})
}
catch
(
error
)
{
console
.
log
(
error
)
res
.
status
(
500
).
send
(
error
.
message
||
"
예매DB에 저장 실패
"
)
}
}
export
default
{
findReservation
}
\ No newline at end of file
export
default
{
findReservedSeats
,
findReservation
,
findOneReservation
,
saveReservation
}
\ No newline at end of file
server/controllers/theater.controller.js
View file @
eacc9ce9
import
{
Theater
,
T
icketFe
e
}
from
"
../db/index.js
"
;
import
{
Theater
,
T
heaterTyp
e
}
from
"
../db/index.js
"
;
const
getTheaterInfo
=
async
(
req
,
res
)
=>
{
const
{
theaterN
um
}
=
req
.
body
const
{
theaterN
ame
}
=
req
.
body
try
{
const
theaterInfo
=
await
Theater
.
findOne
({
where
:
{
theaterN
um
:
theaterN
um
},
attributes
:
[
'
theaterN
um
'
,
'
rows
'
,
'
columns
'
,
'
theaterType
'
]
where
:
{
theaterN
ame
:
String
(
theaterN
ame
)
},
attributes
:
[
'
theaterN
ame
'
,
'
rows
'
,
'
columns
'
]
})
// console.log("theaterInfo====",theaterInfo)
return
res
.
json
(
theaterInfo
)
...
...
@@ -15,17 +15,27 @@ const getTheaterInfo = async (req, res) => {
}
const
getAll
=
async
(
req
,
res
)
=>
{
try
{
const
findList
=
await
Theater
.
findAll
({
include
:
[{
model
:
TicketFee
,
attributes
:
[
"
theaterType
"
]
}]
})
console
.
log
(
"
Ads==
"
,
findList
)
const
findList
=
await
Theater
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
},
include
:
[
TheaterType
],
order
:
[[
'
theaterName
'
]]
})
return
res
.
json
(
findList
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
}
}
const
getOne
=
async
(
req
,
res
)
=>
{
try
{
const
{
theaterId
}
=
req
.
params
const
find
=
await
Theater
.
findOne
({
where
:
{
id
:
theaterId
},
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
if
(
!
find
)
throw
new
Error
(
"
해당 정보를 찾지 못했습니다.
"
);
return
res
.
json
(
find
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
}
}
const
getTypes
=
async
(
req
,
res
)
=>
{
try
{
const
findTypes
=
await
T
icketFe
e
.
findAll
({
attributes
:
[
'
id
'
,
'
theaterType
'
]
})
const
findTypes
=
await
T
heaterTyp
e
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
return
res
.
json
(
findTypes
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
...
...
@@ -34,10 +44,17 @@ const getTypes = async (req, res) => {
const
submit
=
async
(
req
,
res
)
=>
{
try
{
const
{
id
}
=
req
.
body
const
{
id
,
theatertypeId
,
theaterName
,
rows
,
columns
}
=
req
.
body
let
response
=
null
if
(
id
)
response
=
await
Theater
.
update
({
...
req
.
body
},
{
where
:
{
id
:
id
}
})
else
response
=
await
Theater
.
create
({
...
req
.
body
})
if
(
id
)
response
=
await
Theater
.
update
({
theatertypeId
,
theaterName
,
rows
,
columns
},
{
where
:
{
id
:
id
}
})
else
{
const
result
=
await
Theater
.
findOrCreate
({
where
:
{
theaterName
:
theaterName
},
defaults
:
{
theatertypeId
,
theaterName
,
rows
,
columns
}
})
if
(
!
result
[
1
])
throw
new
Error
(
"
이미 존재하는 이름의 상영관입니다. 다시 등록해주세요.
"
);
else
response
=
result
[
0
]
}
return
res
.
json
(
response
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 저장 중 에러 발생
"
)
...
...
@@ -46,7 +63,10 @@ const submit = async (req, res) => {
const
remove
=
async
(
req
,
res
)
=>
{
try
{
const
{
theaterId
}
=
req
.
params
const
delNum
=
await
Theater
.
destroy
({
where
:
{
id
:
theaterId
}
})
if
(
delNum
)
res
.
json
(
delNum
)
else
throw
new
Error
(
"
해당 정보를 서버에서 삭제하는데 실패했습니다.
"
);
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 삭제 중 에러 발생
"
)
}
...
...
@@ -54,6 +74,7 @@ const remove = async (req, res) => {
export
default
{
getAll
,
getOne
,
getTypes
,
submit
,
remove
,
...
...
server/controllers/ticketfee.controller.js
View file @
eacc9ce9
import
{
TicketFee
}
from
"
../db/index.js
"
;
import
{
TheaterType
,
TicketFee
}
from
"
../db/index.js
"
;
const
getAll
=
async
(
req
,
res
)
=>
{
try
{
const
findAll
=
await
TicketFee
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
const
findAll
=
await
TicketFee
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
,
include
:
[
TheaterType
]
})
return
res
.
json
(
findAll
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보 가져오는 중 에러 발생
"
)
...
...
@@ -11,8 +11,9 @@ const getAll = async (req, res) => {
const
getOne
=
async
(
req
,
res
)
=>
{
try
{
const
{
theaterType
}
=
req
.
params
const
find
=
await
TicketFee
.
findOne
({
where
:
{
theaterType
:
theaterType
},
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
const
{
theaterTypeId
}
=
req
.
params
const
find
=
await
TicketFee
.
findOne
({
where
:
{
theatertypeId
:
theaterTypeId
},
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
},
include
:
[
TheaterType
]
})
find
.
dataValues
.
theaterTypeName
=
find
.
dataValues
.
theatertype
.
dataValues
.
theaterTypeName
if
(
!
find
)
throw
new
Error
(
"
해당 정보를 찾지 못했습니다.
"
);
return
res
.
json
(
find
)
}
catch
(
error
)
{
...
...
@@ -22,26 +23,29 @@ const getOne = async (req, res) => {
const
edit
=
async
(
req
,
res
)
=>
{
try
{
const
{
theater
Type
}
=
req
.
body
const
{
theater
typeId
,
theaterTypeName
,
defaultPrice
,
weekdays
,
weekend
,
morning
,
day
,
night
,
youth
,
adult
,
senior
}
=
req
.
body
let
response
=
null
const
result
=
await
T
icketFe
e
.
findOrCreate
({
where
:
{
theaterType
:
theater
T
ype
},
defaults
:
{
...
req
.
body
}
const
result
=
await
T
heaterTyp
e
.
findOrCreate
({
where
:
{
id
:
theater
t
ype
Id
},
defaults
:
{
theaterTypeName
:
theaterTypeName
}
})
if
(
!
result
[
1
])
{
const
updateData
=
await
TicketFee
.
update
({
...
req
.
body
},
{
where
:
{
theaterType
:
theaterType
}
})
response
=
updateData
}
else
response
=
result
[
0
]
if
(
result
[
1
])
{
response
=
await
TicketFee
.
create
({
theatertypeId
:
result
[
0
].
id
,
defaultPrice
,
weekdays
,
weekend
,
morning
,
day
,
night
,
youth
,
adult
,
senior
})
}
else
{
await
TheaterType
.
update
({
theaterTypeName
:
theaterTypeName
},
{
where
:
{
id
:
theatertypeId
}
})
response
=
await
TicketFee
.
update
({
defaultPrice
,
weekdays
,
weekend
,
morning
,
day
,
night
,
youth
,
adult
,
senior
},
{
where
:
{
theatertypeId
:
result
[
0
].
id
}
})
}
return
res
.
json
(
response
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보 수정 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보
추가 및
수정 중 에러 발생
"
)
}
}
const
remove
=
async
(
req
,
res
)
=>
{
try
{
const
{
theaterType
}
=
req
.
query
const
delNum
=
await
TicketFee
.
destroy
({
where
:
{
theaterType
:
theaterType
}
})
const
{
theaterTypeId
}
=
req
.
query
const
delNum
=
await
TicketFee
.
destroy
({
where
:
{
theatertypeId
:
theaterTypeId
}
})
await
TheaterType
.
destroy
({
where
:
{
id
:
theaterTypeId
}
})
if
(
delNum
)
res
.
json
(
delNum
)
else
throw
new
Error
(
"
해당 정보를 서버에서 삭제하는데 실패했습니다.
"
);
}
catch
(
error
)
{
...
...
server/controllers/timetable.controller.js
0 → 100644
View file @
eacc9ce9
import
{
TimeTable
}
from
"
../db/index.js
"
;
import
sequelize
from
'
sequelize
'
const
{
Op
}
=
sequelize
const
submit
=
async
(
req
,
res
)
=>
{
try
{
console
.
log
(
"
req.body==
"
,
req
.
body
)
const
{
theater
,
runtime
}
=
req
.
body
const
result
=
theater
.
filter
(
async
(
theater
)
=>
{
const
startDate
=
getDate
(
theater
.
start
)
const
endDate
=
getDate
(
theater
.
start
,
runtime
)
// const isTimeTable = await TimeTable.findAll({
// where: {
// [Op.and]: [
// { theater: theater.theater },
// {
// [Op.and]: [
// { start_date: { [Op.lte]: endDate } },
// { end_date: { [Op.gte]: startDate } }
// ]
// }
// ]
// }
// })
// [Op.or]: [{ [Op.and]: [{ start_date: { [Op.gt]: startDate } }, { start_date: { [Op.gt]: endDate } }] },
// { [Op.and]: [{ end_date: { [Op.lt]: startDate } }, { end_date: { [Op.lt]: endDate } }] }]
console
.
log
(
"
isTimeTable==
"
,
isTimeTable
)
return
isTimeTable
})
console
.
log
(
"
result==
"
,
result
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영시간표 저장 중 에러 발생
"
)
}
}
const
getDate
=
(
string
,
runtime
=
0
)
=>
{
const
arr
=
string
.
split
(
'
:
'
)
const
date
=
new
Date
(
0
,
0
,
0
,
Number
(
arr
[
0
]),
Number
(
arr
[
1
])
+
runtime
)
// console.log("custom==", date.toString())
return
date
}
export
default
{
submit
}
\ No newline at end of file
server/controllers/user.controller.js
View file @
eacc9ce9
import
jwt
from
"
jsonwebtoken
"
;
import
config
from
"
../config/app.config.js
"
;
import
{
User
,
Role
,
ConfirmNum
}
from
'
../db/index.js
'
;
import
{
User
,
Role
,
Guest
,
ConfirmNum
}
from
'
../db/index.js
'
;
import
fs
from
"
fs
"
;
import
CryptoJS
from
"
crypto-js
"
;
import
validator
from
"
validator
"
;
...
...
@@ -111,7 +111,8 @@ const confirmMbnum = async (req, res) => {
const
signature
=
hash
.
toString
(
CryptoJS
.
enc
.
Base64
);
const
phoneNumber
=
req
.
params
.
phone
;
console
.
log
(
uri
,
secretKey
,
accessKey
);
console
.
log
(
phoneNumber
);
//인증번호 생성
const
verifyCode
=
Math
.
floor
(
Math
.
random
()
*
(
999999
-
100000
))
+
100000
;
console
.
log
(
"
verifyCode :
"
,
verifyCode
);
...
...
@@ -412,14 +413,57 @@ const getUserInfo = async (req, res) => {
try
{
const
userInfo
=
await
User
.
findOne
({
where
:
{
id
:
id
},
attributes
:
[
"
userId
"
,
"
email
"
,
"
nickname
"
,
"
birth
"
,
"
phoneNumber
"
]
attributes
:
[
"
id
"
,
"
userId
"
,
"
email
"
,
"
nickname
"
,
"
birth
"
,
"
phoneNumber
"
]
})
console
.
log
(
userInfo
)
res
.
json
(
userInfo
)
}
catch
(
error
)
{
console
.
log
(
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
,
});
// 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
);
}
catch
(
error
)
{
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
{
getUser
,
login
,
...
...
@@ -427,10 +471,11 @@ export default {
confirmMbnum
,
confirmNum
,
signup
,
getMember
,
uploadProfile
,
getUser
,
comparePw
,
modifyUser
,
getUserInfo
saveGuestInfo
,
getMember
,
uploadProfile
,
getUserInfo
,
getGuestInfo
}
server/db/index.js
View file @
eacc9ce9
...
...
@@ -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
ConfirmNumModel
from
'
../models/confirmnum.model.js
'
import
dbConfig
from
"
../config/db.config.js
"
;
...
...
@@ -36,12 +37,13 @@ const TheaterType = TheaterTypeModel(sequelize)
const
TicketFee
=
TicketFeeModel
(
sequelize
)
const
TimeTable
=
TimeTableModel
(
sequelize
)
const
Reservation
=
ReservationModel
(
sequelize
)
const
Guest
=
GuestModel
(
sequelize
)
const
ConfirmNum
=
ConfirmNumModel
(
sequelize
)
User
.
belongsTo
(
Role
);
Role
.
hasOne
(
User
);
Theater
.
belongsTo
(
TheaterType
);
Theater
.
belongsTo
(
TheaterType
,
{
onDelete
:
'
CASCADE
'
}
);
TicketFee
.
belongsTo
(
TheaterType
,
{
onDelete
:
'
CASCADE
'
});
...
...
@@ -56,5 +58,6 @@ export {
TicketFee
,
TimeTable
,
Reservation
,
Guest
,
ConfirmNum
}
\ No newline at end of file
server/index.js
View file @
eacc9ce9
...
...
@@ -19,6 +19,7 @@ sequelize
);
const
adminRole
=
await
Role
.
findOne
({
where
:
{
name
:
"
admin
"
}
});
// console.log("adminRole : ", adminRole);
if
(
!
adminRole
)
{
await
User
.
create
({
userId
:
"
admin
"
,
...
...
server/models/guest.model.js
0 → 100644
View file @
eacc9ce9
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
server/models/reservation.model.js
View file @
eacc9ce9
...
...
@@ -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
,
}
},
{
...
...
server/models/timetable.model.js
View file @
eacc9ce9
...
...
@@ -20,11 +20,19 @@ const TimeTableModel = (sequelize) => {
title
:
{
type
:
DataTypes
.
STRING
,
},
runtime
:
{
type
:
DataTypes
.
INTEGER
,
},
release_date
:
{
type
:
DataTypes
.
STRING
},
date
:
{
type
:
DataTypes
.
STRING
,
start_date
:
{
type
:
DataTypes
.
DATE
,
defaultValue
:
new
Date
(
0
)
},
end_date
:
{
type
:
DataTypes
.
DATE
,
defaultValue
:
new
Date
(
0
)
},
time
:
{
type
:
DataTypes
.
TIME
,
...
...
server/routes/cinema.route.js
View file @
eacc9ce9
...
...
@@ -10,7 +10,7 @@ router
.
put
(
cinemaCtrl
.
edit
)
router
.
route
(
"
/ticketfee/:theaterType
"
)
.
route
(
"
/ticketfee/:theaterType
Id
"
)
.
get
(
ticketfeeCtrl
.
getOne
)
router
...
...
server/routes/index.js
View file @
eacc9ce9
...
...
@@ -2,6 +2,7 @@ import express from "express";
import
userRouter
from
'
./user.route.js
'
import
movieRouter
from
'
./movie.route.js
'
import
theaterRouter
from
"
./theater.route.js
"
;
import
timetableRouter
from
"
./timetable.route.js
"
;
import
cinemaRouter
from
"
./cinema.route.js
"
;
import
kakaopayRouter
from
"
./kakaopay.route.js
"
;
import
emailRouter
from
'
./email.route.js
'
...
...
@@ -16,5 +17,6 @@ router.use('/email',emailRouter)
router
.
use
(
'
/info
'
,
cinemaRouter
)
router
.
use
(
'
/theater
'
,
theaterRouter
)
router
.
use
(
'
/reservation
'
,
reservationRouter
)
router
.
use
(
'
/timetable
'
,
timetableRouter
)
export
default
router
;
\ No newline at end of file
server/routes/movie.route.js
View file @
eacc9ce9
...
...
@@ -5,12 +5,11 @@ const router = express.Router();
router
.
route
(
"
/
"
)
// .pos
t(movieCtrl.
comparePopularMovie
)
.
ge
t
(
movieCtrl
.
getListfromDB
)
router
.
route
(
'
/showmovies/:category
'
)
.
get
(
movieCtrl
.
getMovieById
)
router
.
route
(
'
/movielist
'
)
router
.
route
(
'
/movielist/:category
'
)
.
get
(
movieCtrl
.
getMovieList
)
router
...
...
@@ -36,6 +35,5 @@ router
.
post
(
movieCtrl
.
create
)
.
delete
(
movieCtrl
.
remove
)
router
.
param
(
'
category
'
,
movieCtrl
.
getMovieByCategory
)
export
default
router
;
\ No newline at end of file
server/routes/reservation.route.js
View file @
eacc9ce9
...
...
@@ -5,6 +5,13 @@ const router = express.Router();
router
.
route
(
'
/findreservation
'
)
.
post
(
ReservationCtrl
.
findReservation
)
.
post
(
ReservationCtrl
.
findReservedSeats
)
.
get
(
ReservationCtrl
.
findReservation
)
router
.
route
(
'
/findonereservation
'
)
.
post
(
ReservationCtrl
.
findOneReservation
)
router
.
route
(
'
/save
'
)
.
post
(
ReservationCtrl
.
saveReservation
)
export
default
router
;
\ No newline at end of file
server/routes/theater.route.js
View file @
eacc9ce9
...
...
@@ -10,10 +10,14 @@ router
.
route
(
"
/
"
)
.
get
(
theaterCtrl
.
getAll
)
.
put
(
theaterCtrl
.
submit
)
.
delete
(
theaterCtrl
.
remove
)
router
.
route
(
"
/type
"
)
.
get
(
theaterCtrl
.
getTypes
)
router
.
route
(
"
/:theaterId
"
)
.
get
(
theaterCtrl
.
getOne
)
.
delete
(
theaterCtrl
.
remove
)
export
default
router
;
server/routes/timetable.route.js
0 → 100644
View file @
eacc9ce9
import
express
from
"
express
"
;
import
timetableCtrl
from
"
../controllers/timetable.controller.js
"
;
const
router
=
express
.
Router
();
router
.
route
(
"
/
"
)
.
post
(
timetableCtrl
.
submit
)
export
default
router
;
\ No newline at end of file
server/routes/user.route.js
View file @
eacc9ce9
...
...
@@ -25,7 +25,7 @@ router
router
.
post
(
"
/profile
"
,
upload
.
single
(
"
image
"
),
userCtrl
.
uploadProfile
)
router
.
route
(
"
/modify
"
)
.
post
(
userCtrl
.
modifyUser
)
...
...
@@ -49,4 +49,14 @@ router
router
.
route
(
'
/getuserinfo
'
)
.
post
(
userCtrl
.
getUserInfo
)
router
.
route
(
'
/guest/save
'
)
.
post
(
userCtrl
.
saveGuestInfo
)
router
.
route
(
'
/guestinfo/:guestId
'
)
.
get
(
userCtrl
.
getGuestInfo
)
router
.
route
(
"
/:userId
"
)
.
get
(
userCtrl
.
compareId
)
export
default
router
;
\ No newline at end of file
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment