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
6e545498
Commit
6e545498
authored
Jul 26, 2021
by
Kim, Subin
Browse files
ticketfee controller
parent
dc8b9516
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/controllers/ticketfee.controller.js
0 → 100644
View file @
6e545498
import
{
TicketFee
}
from
"
../db/index.js
"
;
const
getAll
=
async
(
req
,
res
)
=>
{
try
{
const
findAll
=
await
TicketFee
.
findAll
()
console
.
log
(
"
find==
"
,
findAll
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보 가져오는 중 에러 발생
"
)
}
}
const
getOne
=
async
(
req
,
res
)
=>
{
try
{
const
{
theaterType
}
=
req
.
params
const
find
=
await
TicketFee
.
findOne
({
where
:
{
theaterType
:
theaterType
},
attributes
:
{
exclude
:
[
'
createdAt
'
,
'
updatedAt
'
]
}
})
if
(
!
find
)
throw
new
Error
(
"
해당 정보를 찾지 못했습니다.
"
);
return
res
.
json
(
find
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보 가져오는 중 에러 발생
"
)
}
}
const
edit
=
async
(
req
,
res
)
=>
{
try
{
const
{
theaterType
}
=
req
.
body
let
response
=
null
const
result
=
await
TicketFee
.
findOrCreate
({
where
:
{
theaterType
:
theaterType
},
defaults
:
{
...
req
.
body
}
})
if
(
!
result
[
1
])
{
const
updateData
=
await
TicketFee
.
update
({
...
req
.
body
},
{
where
:
{
theaterType
:
theaterType
}
})
response
=
updateData
}
else
response
=
result
[
0
]
return
res
.
json
(
response
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보 수정 중 에러 발생
"
)
}
}
const
remove
=
async
(
req
,
res
)
=>
{
try
{
const
{
theaterType
}
=
req
.
query
const
delTicketFee
=
await
TicketFee
.
destroy
({
where
:
{
theaterType
:
theaterType
}
})
console
.
log
(
"
del==
"
,
delTicketFee
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
관람료 정보 삭제 중 에러 발생
"
)
}
}
export
default
{
getAll
,
getOne
,
edit
,
remove
}
\ 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