Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Resolve Conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdtn0219 committed Nov 28, 2023
2 parents f1c31d6 + 08619ea commit 3b52f59
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 53 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mini-project
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public record CartCreateRequest(

@Positive
Long roomTypeId,
@Positive
Long roomTypeId,

@FutureOrPresent
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
LocalDate checkIn,
@FutureOrPresent
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
LocalDate checkIn,

@FutureOrPresent
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
LocalDate checkOut,
@FutureOrPresent
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
LocalDate checkOut,

@Positive
Integer guestNumber,
@Positive
Integer guestNumber,

@Positive
Long accommodationId,
@Positive
Long accommodationId,

@NotBlank
String keyword,
@NotBlank
String keyword,

@NotNull
AreaCode areaCode
@NotNull
AreaCode areaCode
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public CartCreateResponse createCart(Long userId, CartCreateRequest cartCreateRe

@Transactional(readOnly = true)
public List<CartGetResponse> getMyCarts(Long userId) {
return cartRepository.findALLByMemberId(userId).stream()
.map((Cart cart) -> CartGetResponse.fromEntity(
cart, cart.getRoom(), cart.getRoom().getAccommodation())
).toList();
return cartRepository.findALLByMemberId(userId).stream()
.map((Cart cart) -> CartGetResponse.fromEntity(
cart, cart.getRoom(), cart.getRoom().getAccommodation())
).toList();
}

@Transactional
Expand Down Expand Up @@ -109,4 +109,4 @@ private Accommodation getOrSaveAccommodation(Accommodation accommodation) {
.orElseGet(() -> accommodationRepository.save(accommodation));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.List;

import static ybe.mini.travelserver.global.security.Role.HAS_ROLE_USER;
import static ybe.mini.travelserver.global.security.Role.ROLE_USER;

@Slf4j
Expand All @@ -27,7 +28,7 @@ public class ReservationController {

private final ReservationService reservationService;

@PreAuthorize("hasRole('ROLE_USER')")
@PreAuthorize(HAS_ROLE_USER)
@PostMapping
public ResponseDto<ReservationCreateResponse> tryReservation (
@RequestBody ReservationCreateRequest createRequest,
Expand All @@ -39,7 +40,7 @@ public ResponseDto<ReservationCreateResponse> tryReservation (
);
}

@PreAuthorize("hasRole('ROLE_USER')")
@PreAuthorize(HAS_ROLE_USER)
@PostMapping("/from-cart")
public ResponseDto<ReservationCreateResponse> tryReservationFromCart (
@RequestBody @Valid ReservationCreateFromCartRequest createRequest,
Expand All @@ -51,7 +52,7 @@ public ResponseDto<ReservationCreateResponse> tryReservationFromCart (
);
}

@PreAuthorize("hasRole('ROLE_USER')")
@PreAuthorize(HAS_ROLE_USER)
@GetMapping
public ResponseDto<List<ReservationGetResponse>> getMyReservations (
@AuthenticationPrincipal PrincipalDetails principalDetails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
@AllArgsConstructor
public enum ReservationErrorMessage implements ErrorMessage {

HTTP_MESSAGE_NOT_READABLE(BAD_REQUEST, "DTO 양식이 맞지 않습니다."),
RESERVATION_NOT_FOUND(BAD_REQUEST, "해당 ID의 예약 정보가 없습니다.")
;
private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.http.ProblemDetail;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import ybe.mini.travelserver.global.exception.ProblemDetailCreator;

import static ybe.mini.travelserver.domain.reservation.exception.ReservationErrorMessage.HTTP_MESSAGE_NOT_READABLE;
import static ybe.mini.travelserver.domain.reservation.exception.ReservationErrorMessage.RESERVATION_NOT_FOUND;

@RestControllerAdvice
Expand All @@ -17,11 +15,6 @@ protected ReservationExceptionHandler() {
super("예약 처리 실패");
}

@ExceptionHandler(HttpMessageNotReadableException.class)
public ProblemDetail handleHttpMessageNotReadableException(HttpServletRequest request) {
return createProblemDetail(HTTP_MESSAGE_NOT_READABLE, request); //todo : Global로 분리할지 논의
}

@ExceptionHandler(ReservationNotFoundException.class)
public ProblemDetail handleReservationNotFoundException(HttpServletRequest request) {
return createProblemDetail(RESERVATION_NOT_FOUND, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import java.util.List;

import static ybe.mini.travelserver.global.security.Role.HAS_ROLE_USER;

@Slf4j
@RequestMapping("/reservation-rooms")
@RestController
Expand All @@ -19,7 +21,7 @@ public class ReservationRoomController {

private final ReservationRoomService reservationRoomService;

@PreAuthorize("hasRole('ROLE_USER')")
@PreAuthorize(HAS_ROLE_USER)
@GetMapping("/{reservationId}")
public ResponseDto<List<ReservationRoomGetResponse>> getReservationRoomsByReserveId(
@PathVariable Long reservationId
Expand All @@ -31,7 +33,7 @@ public ResponseDto<List<ReservationRoomGetResponse>> getReservationRoomsByReserv
);
}

@PreAuthorize("hasRole('ROLE_USER')")
@PreAuthorize(HAS_ROLE_USER)
@DeleteMapping
public ResponseDto<Long> deleteReservationRoom(
@RequestParam Long reservationId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package ybe.mini.travelserver.domain.reservation_room.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.*;
import jakarta.validation.constraints.FutureOrPresent;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import org.springframework.format.annotation.DateTimeFormat;
import ybe.mini.travelserver.domain.accommodation.entity.AreaCode;

import java.io.Serializable;
Expand All @@ -15,21 +18,18 @@ public record ReservationRoomCreateRequest(
Long accommodationId,
@NotBlank(message = "accommodationName 에 빈 값이 입력되었습니다.")
String accommodationName,
// @NotNull(message = "areaCode 양식이 잘못 입력되었습니다.")
@NotNull(message = "areaCode 양식이 잘못 입력되었습니다.")
AreaCode areaCode,
// @NotNull(message = "areaCode 양식이 잘못 입력되었습니다.")
// String areaCode,
@NotNull(message = "roomTypeId 양식이 잘못 입력되었습니다.")
Long roomTypeId,

@NotNull

@FutureOrPresent
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
@DateTimeFormat(pattern = "yyyy-MM-dd")
LocalDateTime checkIn,

@NotNull
@FutureOrPresent
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
@DateTimeFormat(pattern = "yyyy-MM-dd")
LocalDateTime checkOut,
@NotNull
@Min(value = 1, message = "숙박 인원은 최소 1명 이어야 합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class TourAPIProperties {
public static final String KEY_DECODED = "0ON3kBtDxd0KYGW5spO8inNljADd/IqfnS/l3nMWq3EkARl20N3MmZVYlSvH3Y8V5fEAo7Seucd5pR7Ebm2Phg==";
public static final String KEY_ENCODED = "0ON3kBtDxd0KYGW5spO8inNljADd%2FIqfnS%2Fl3nMWq3EkARl20N3MmZVYlSvH3Y8V5fEAo7Seucd5pR7Ebm2Phg%3D%3D";
public static final String KEY_DECODED = "1Wkp7yq9dkbxF4oNKeJQQJdUd55hQvujedMr43Rne5vvK7bkirS+1GRzd9rkerYmlitxxeoP8O86VsxM8WTz6A==";
public static final String KEY_ENCODED = "1Wkp7yq9dkbxF4oNKeJQQJdUd55hQvujedMr43Rne5vvK7bkirS%2B1GRzd9rkerYmlitxxeoP8O86VsxM8WTz6A%3D%3D";

public static final String BASE_URL = "https://apis.data.go.kr/B551011/KorService1/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@AllArgsConstructor
public enum DTOErrorMessage implements ErrorMessage {
METHOD_ARGUMENT_NOT_VALID(BAD_REQUEST, "DTO 값이 유효하지 않습니다"),
DATETIME_PARSE(BAD_REQUEST, "날짜 형식이 유효하지 않습니다"),
;

private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import org.springframework.web.bind.annotation.RestControllerAdvice;
import ybe.mini.travelserver.global.exception.ProblemDetailCreator;

import java.time.format.DateTimeParseException;
import java.util.Objects;

import static ybe.mini.travelserver.global.exception.dto.DTOErrorMessage.DATETIME_PARSE;
import static ybe.mini.travelserver.global.exception.dto.DTOErrorMessage.METHOD_ARGUMENT_NOT_VALID;

@RestControllerAdvice
Expand All @@ -26,4 +28,10 @@ public ProblemDetail handleMethodArgumentNotValidException(
return createProblemDetail(errorMessage, METHOD_ARGUMENT_NOT_VALID.getStatus().value(), request);
}

@ExceptionHandler(DateTimeParseException.class)
public ProblemDetail handleDateTimeParseException(
HttpServletRequest request
) {
return createProblemDetail(DATETIME_PARSE, request);
}
}
7 changes: 3 additions & 4 deletions src/test/http/cart.http
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWF0I

### 생성
POST http://localhost:8080/carts
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzAxMTEzNTU0LCJleHAiOjE3MDExMTUzNTQsImVtYWlsIjoib2tqYWVvb2s5OEBnbWFpbC5jb20iLCJwYXNzd29yZCI6IntiY3J5cHR9JDJhJDEwJERBdjM5S1c2RFVSVzN1djh4eEFQR2U3MEliUkJPLmg2QkNtWkk0TEw5RTd5WFhubjFMYS9XIiwibmFtZSI6Im9ramFlb29rIn0.EAJUoy5hMcM9FtUUb7tZoFKzjXAgO-xNyHuvPCWp9QQ
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzAxMTE2MTk4LCJleHAiOjE3MDExMTc5OTgsImVtYWlsIjoib2tqYWVvb2s5OEBnbWFpbC5jb20iLCJwYXNzd29yZCI6IntiY3J5cHR9JDJhJDEwJGRWc3JDenZCWVdWdU5XWm5WN3d3QWVra3E5RUJWZ0t1anpxT28ucmZBU05FZEswZkd5QzVlIiwibmFtZSI6Im9ramFlb29rIn0.PUhHIiJF_XQ1vCcZW1LVXQLLJGkx_HAYKTYinAtH84c
Content-Type: application/json

{
"roomTypeId": 11430,
"accommodationId": 142785,
"guestNumber": 1,
"checkIn": "2024-11-20",
"checkOut": "2024-11-21",
"areaCode": "SEOUL"
"checkIn": "2023-11-20",
"checkOut": "2023-11-21"
}
8 changes: 4 additions & 4 deletions src/test/http/reservation.http
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### 예약 생성
POST http://localhost:8080/reservations
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzAxMTEzNTU0LCJleHAiOjE3MDExMTUzNTQsImVtYWlsIjoib2tqYWVvb2s5OEBnbWFpbC5jb20iLCJwYXNzd29yZCI6IntiY3J5cHR9JDJhJDEwJERBdjM5S1c2RFVSVzN1djh4eEFQR2U3MEliUkJPLmg2QkNtWkk0TEw5RTd5WFhubjFMYS9XIiwibmFtZSI6Im9ramFlb29rIn0.EAJUoy5hMcM9FtUUb7tZoFKzjXAgO-xNyHuvPCWp9QQ
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzAxMTU2NTc2LCJleHAiOjE3MDExNTgzNzYsImVtYWlsIjoib2tqYWVvb2s5OEBnbWFpbC5jb20iLCJwYXNzd29yZCI6IntiY3J5cHR9JDJhJDEwJFNCbjZSQ3ZQdFQ2WW1vSVM0ZzU1dE8xTFBwRDJkSjJLbDBKcDRXT3k5RmhuNzNxdnNJQS51IiwibmFtZSI6Im9ramFlb29rIn0.HCiMHNhtW45GEFH2tbkihaeiqADBmehLfg2iGlIDuCE

{
"paymentType": "CARD",
Expand All @@ -11,8 +11,8 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWF0I
"accommodationName": "가락관광호텔",
"areaCode": "SEOUL",
"roomTypeId": 11430,
"checkIn": "2024-01-01 14:00",
"checkOut": "2024-01-02 11:00",
"checkIn": "2024-01-01T00:00",
"checkOut": "2024-01-03T00:00",
"guestNumber": 2
}
]
Expand All @@ -21,7 +21,7 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWF0I
### 예약 생성 장바구니
POST http://localhost:8080/reservations/from-cart
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzAxMTExNjg1LCJleHAiOjE3MDExMTM0ODUsImVtYWlsIjoib2tqYWVvb2s5OEBnbWFpbC5jb20iLCJwYXNzd29yZCI6IntiY3J5cHR9JDJhJDEwJERBdjM5S1c2RFVSVzN1djh4eEFQR2U3MEliUkJPLmg2QkNtWkk0TEw5RTd5WFhubjFMYS9XIiwibmFtZSI6Im9ramFlb29rIn0.ZlI9RVIpiEWw3IPhht0sKtSTdv63zX-W0BxBiYJqs2Q
Authorization: Bearer yJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzAxMTE1OTk2LCJleHAiOjE3MDExMTc3OTYsImVtYWlsIjoib2tqYWVvb2s5OEBnbWFpbC5jb20iLCJwYXNzd29yZCI6IntiY3J5cHR9JDJhJDEwJHdpZjd6bWlYUGY3TkNUQ3ZvNlM4ZC5NdG5VMHZNenJRUVBjN1piblpZN2IvN3FQaVo4T1BpIiwibmFtZSI6Im9ramFlb29rIn0.G9xn5RFjHQZSnmTLfLtzmygz_HlUGxPyugnzpC06fQg

{
"paymentType": "CARD",
Expand Down

0 comments on commit 3b52f59

Please sign in to comment.