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
4397ad6f
Commit
4397ad6f
authored
Aug 02, 2021
by
Kim, Subin
Browse files
timetable Api 및 서버쪽 기능 구현 중
parent
28bba9d9
Changes
5
Show whitespace changes
Inline
Side-by-side
client/src/apis/timetable.api.js
0 → 100644
View file @
4397ad6f
import
axios
from
"
axios
"
;
import
{
baseUrl
}
from
"
../utils/baseUrl.js
"
;
const
submit
=
async
(
sendData
)
=>
{
const
{
data
}
=
await
axios
.
post
(
`
${
baseUrl
}
/api/timetable`
,
sendData
)
return
data
}
const
timetableApi
=
{
submit
}
export
default
timetableApi
\ No newline at end of file
server/controllers/timetable.controller.js
0 → 100644
View file @
4397ad6f
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/models/timetable.model.js
View file @
4397ad6f
...
...
@@ -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/index.js
View file @
4397ad6f
...
...
@@ -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
'
...
...
@@ -14,5 +15,6 @@ router.use('/kakaopay',kakaopayRouter)
router
.
use
(
'
/email
'
,
emailRouter
)
router
.
use
(
'
/info
'
,
cinemaRouter
)
router
.
use
(
'
/theater
'
,
theaterRouter
)
router
.
use
(
'
/timetable
'
,
timetableRouter
)
export
default
router
;
\ No newline at end of file
server/routes/timetable.route.js
0 → 100644
View file @
4397ad6f
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
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