-
Notifications
You must be signed in to change notification settings - Fork 248
[π μ¬μ΄ν΄2 - λ―Έμ (μμ½ λ³κ²½/μ·¨μμ μλ¬ μ²λ¦¬)] 보μ λ―Έμ μ μΆν©λλ€. #445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[π μ¬μ΄ν΄2 - λ―Έμ (μμ½ λ³κ²½/μ·¨μμ μλ¬ μ²λ¦¬)] 보μ λ―Έμ μ μΆν©λλ€. #445
Changes from 41 commits
7dd3764
c884f2d
ccdd2de
96c1806
853acd8
a3a8fac
75541fa
55b2aa8
5a9b56e
a1bc6ec
58a4e85
ea28c0e
f7f3535
30bbe9c
ca09e57
af36d71
248db1c
22eb9e0
33bfaaa
07f4ed3
fc2b64d
b199646
62c27a9
e84bd8a
54adb7b
991c108
71f01e8
88d4f62
3cb6be4
d823f2d
0bf7829
45a9695
4fe8125
c574b71
82f6ff4
c799ec4
de703ac
3b1c672
5d2ff24
f0af145
877355c
c0697ab
4f236dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package roomescape.config; | ||
|
|
||
| import java.time.Clock; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| @Configuration | ||
| public class TimeConfig { | ||
|
|
||
| @Bean | ||
| public Clock clock() { | ||
| return Clock.systemDefaultZone(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,63 @@ | ||
| package roomescape.domain.reservation; | ||
|
|
||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import java.util.List; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PatchMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import roomescape.support.auth.AdminRequestValidator; | ||
| import roomescape.domain.reservation.dto.CreateReservationRequest; | ||
| import roomescape.domain.reservation.dto.CreateReservationResponse; | ||
| import roomescape.domain.reservation.dto.ReservationResponse; | ||
| import roomescape.domain.reservation.dto.UpdateReservationRequest; | ||
| import roomescape.domain.reservation.dto.UserReservationResponse; | ||
|
|
||
| @Validated | ||
| @RestController | ||
| @RequiredArgsConstructor | ||
| public class ReservationController { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μλΉμ€ ν μ€νΈμ κ²½μ°μλ μ μμ±ν΄μ£Όμ ¨λλ° Controller νΉμ e2e ν μ€νΈλ λ°λ‘ μ보μ΄λ€μ? λΉμ§λμ€ λ‘μ§μ΄ μ΄μ°¨νΌ μλΉμ€μμ ν μ€νΈκ° λλ€κ³ μκ°νμ€ μ λ μλλ°, κ°κ°μ κ΄μ¬μ¬μ λμμ΄ μ‘°κΈμ λ€λ₯΄λ€κ³ μκ°ν©λλ€. μ΄λ€ ν μ€νΈ μΌμ΄μ€λ€μ΄ μμ μ μμκΉμ? |
||
|
|
||
| private final ReservationService reservationService; | ||
| private final AdminRequestValidator validator; | ||
|
|
||
| @GetMapping("/admin/reservations") | ||
| public ResponseEntity<List<ReservationResponse>> getAllReservation(HttpServletRequest request) { | ||
| if (validator.isUnauthorized(request)) { | ||
| return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); | ||
| } | ||
| List<ReservationResponse> response = reservationService.getAllReservations(); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @PostMapping("/reservations") | ||
| public ResponseEntity<CreateReservationResponse> createReservation(@RequestBody CreateReservationRequest request) { | ||
| request.validate(); | ||
| public ResponseEntity<CreateReservationResponse> createReservation( | ||
| @Valid @RequestBody CreateReservationRequest request | ||
| ) { | ||
| CreateReservationResponse response = reservationService.createReservation(request); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body(response); | ||
| } | ||
|
|
||
| @DeleteMapping("/admin/reservations/{id}") | ||
| public ResponseEntity<Void> deleteReservation(HttpServletRequest request, @PathVariable Long id) { | ||
| if (validator.isUnauthorized(request)) { | ||
| return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); | ||
| } | ||
| reservationService.deleteReservation(id); | ||
| @GetMapping("/reservations") | ||
| public ResponseEntity<UserReservationResponse> getUserReservations( | ||
| @RequestParam | ||
| @NotBlank(message = "μμ½μ μ΄λ¦μ νμ μ λ ₯κ° μ λλ€.") | ||
| String name | ||
| ) { | ||
| UserReservationResponse response = reservationService.getUserReservations(name); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @DeleteMapping("/reservations/{id}") | ||
| public ResponseEntity<Void> deleteUserReservation( | ||
| @PathVariable Long id | ||
| ) { | ||
| reservationService.cancelUserReservation(id); | ||
| return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
| } | ||
|
|
||
| @PatchMapping("/reservations/{id}") | ||
| public ResponseEntity<Void> updateReservation( | ||
| @PathVariable Long id, | ||
| @RequestBody UpdateReservationRequest request | ||
| ) { | ||
| reservationService.updateReservation(id, request); | ||
| return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ λ©μλ λͺ¨λ μ‘΄μ¬ μ¬λΆλ§ νλ¨νλλ° μΏΌλ¦¬λ countλ₯Ό μ°λ€μ? EXISTS μΏΌλ¦¬κ° μλμ λ λ§μ§ μμκΉμ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
κ·Έλ¬λ€μ..!! existλ‘ λ³κ²½νκ³ , 쿼리문 λ€μ΄λ°λ μλλ₯Ό λ μ λνλ΄λλ‘ EXISTλ‘ λ³κ²½ν΄μ€¬μ΅λλ€.