Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
students
butter-studio
Commits
72bd94dc
You need to sign in or sign up before continuing.
Commit
72bd94dc
authored
Aug 02, 2021
by
Kim, Subin
Browse files
theaterCtrl submit 기능 수정 완료
parent
4397ad6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/controllers/theater.controller.js
View file @
72bd94dc
...
@@ -2,7 +2,7 @@ import { Theater, TheaterType } from "../db/index.js";
...
@@ -2,7 +2,7 @@ import { Theater, TheaterType } from "../db/index.js";
const
getAll
=
async
(
req
,
res
)
=>
{
const
getAll
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
findList
=
await
Theater
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
},
include
:
[
TheaterType
],
order
:
[[
'
theaterName
'
]]
})
const
findList
=
await
Theater
.
findAll
({
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
},
include
:
[
TheaterType
],
order
:
[[
'
theaterName
'
]]
})
return
res
.
json
(
findList
)
return
res
.
json
(
findList
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 가져오는 중 에러 발생
"
)
...
@@ -12,7 +12,7 @@ const getAll = async (req, res) => {
...
@@ -12,7 +12,7 @@ const getAll = async (req, res) => {
const
getOne
=
async
(
req
,
res
)
=>
{
const
getOne
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
{
theaterId
}
=
req
.
params
const
{
theaterId
}
=
req
.
params
const
find
=
await
Theater
.
findOne
({
where
:
{
id
:
theaterId
}
,
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
const
find
=
await
Theater
.
findOne
({
where
:
{
id
:
theaterId
},
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
if
(
!
find
)
throw
new
Error
(
"
해당 정보를 찾지 못했습니다.
"
);
if
(
!
find
)
throw
new
Error
(
"
해당 정보를 찾지 못했습니다.
"
);
return
res
.
json
(
find
)
return
res
.
json
(
find
)
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -34,7 +34,14 @@ const submit = async (req, res) => {
...
@@ -34,7 +34,14 @@ const submit = async (req, res) => {
const
{
id
,
theatertypeId
,
theaterName
,
rows
,
columns
}
=
req
.
body
const
{
id
,
theatertypeId
,
theaterName
,
rows
,
columns
}
=
req
.
body
let
response
=
null
let
response
=
null
if
(
id
)
response
=
await
Theater
.
update
({
theatertypeId
,
theaterName
,
rows
,
columns
},
{
where
:
{
id
:
id
}
})
if
(
id
)
response
=
await
Theater
.
update
({
theatertypeId
,
theaterName
,
rows
,
columns
},
{
where
:
{
id
:
id
}
})
else
response
=
await
Theater
.
create
({
theatertypeId
,
theaterName
,
rows
,
columns
})
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
)
return
res
.
json
(
response
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 저장 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
상영관 정보 저장 중 에러 발생
"
)
...
...
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