Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"com.nowait.applicationadmin",
"com.nowait.infraaws",
"com.nowait.adminsecurity",
"com.nowait.config"
"com.nowait.config",
"com.nowait.reservation"
})
@EntityScan(basePackages = {
"com.nowait.menu.entity",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import com.nowait.applicationadmin.reservation.dto.ReservationGetResponseDto;
import com.nowait.applicationadmin.reservation.dto.ReservationStatusSummaryDto;
import com.nowait.applicationadmin.reservation.dto.ReservationStatusUpdateRequestDto;
import com.nowait.common.enums.ReservationStatus;
import com.nowait.reservation.entity.Reservation;
import com.nowait.reservation.exception.ReservationNotFoundException;
import com.nowait.reservation.repository.ReservationRepository;
import com.nowait.common.enums.ReservationStatus;

import lombok.RequiredArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.nowait.applicationuser.exception;

import static com.nowait.common.exception.ErrorMessage.*;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.HttpStatus.UNAUTHORIZED;
import static org.springframework.http.HttpStatus.*;

import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -17,17 +17,17 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MultipartException;

import com.nowait.applicationuser.reservation.exception.ReservationNotFoundException;
import com.nowait.bookmark.exception.BookmarkOwnerMismatchException;
import com.nowait.bookmark.exception.DuplicateBookmarkException;
import com.nowait.common.exception.ErrorMessage;
import com.nowait.common.exception.ErrorResponse;
import com.nowait.frontsecurity.exception.ResourceNotFoundException;
import com.nowait.frontsecurity.exception.UnauthorizedException;
import com.nowait.order.exception.DepositorNameTooLongException;
import com.nowait.order.exception.DuplicateOrderException;
import com.nowait.order.exception.OrderItemsEmptyException;
import com.nowait.order.exception.OrderParameterEmptyException;
import com.nowait.reservation.exception.ReservationNotFoundException;
import com.nowait.token.exception.BusinessException;
import com.nowait.user.exception.UserNotFoundException;

Expand Down Expand Up @@ -140,6 +140,13 @@ public ErrorResponse orderItemsEmptyException(OrderItemsEmptyException e) {
return new ErrorResponse(e.getMessage(), ORDER_ITEMS_EMPTY.getCode());
}

@ResponseStatus(value = BAD_REQUEST)
@ExceptionHandler(DepositorNameTooLongException.class)
public ErrorResponse depositorNameTooLongException(DepositorNameTooLongException e) {
log.error("depositorNameTooLongException", e);
return new ErrorResponse(e.getMessage(), DEPOSITOR_NAME_TOO_LONG.getCode());
}

@ResponseStatus(value = BAD_REQUEST)
@ExceptionHandler(DuplicateOrderException.class)
public ErrorResponse duplicateOrderException(DuplicateOrderException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.List;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -10,6 +12,9 @@
@AllArgsConstructor
@Builder
public class OrderCreateRequestDto {
private final String depositorName; // 예약자 이름
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Bean Validation 어노테이션 추가를 고려해보세요.

depositorName 필드에 유효성 검증을 위한 Bean Validation 어노테이션을 추가하는 것을 권장합니다. 이를 통해 컨트롤러 레벨에서 자동으로 검증할 수 있습니다.

+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Size;

 @Getter
 @AllArgsConstructor
 @Builder
 public class OrderCreateRequestDto {
-	private final String depositorName; // 예약자 이름
+	@NotBlank(message = "예약자 이름은 필수입니다")
+	@Size(max = 100, message = "예약자 이름은 100자 이하여야 합니다")
+	private final String depositorName; // 예약자 이름
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private final String depositorName; // 예약자 이름
// --- at the top of OrderCreateRequestDto.java ---
package com.nowait.applicationuser.order.dto;
import lombok.Getter;
import lombok.AllArgsConstructor;
import lombok.Builder;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Size;
@Getter
@AllArgsConstructor
@Builder
public class OrderCreateRequestDto {
+ @NotBlank(message = "예약자 이름은 필수입니다")
+ @Size(max = 100, message = "예약자 이름은 100자 이하여야 합니다")
private final String depositorName; // 예약자 이름
// ... other fields and methods ...
}
🤖 Prompt for AI Agents
In
application-user/src/main/java/com/nowait/applicationuser/order/dto/OrderCreateRequestDto.java
at line 13, the depositorName field lacks Bean Validation annotations. Add
appropriate validation annotations such as @NotBlank or @NotNull to this field
to enable automatic validation at the controller level, ensuring the
depositorName is properly validated when requests are received.

@NotBlank(message = "주문자 이름은 필수입니다")
@Size(max = 100, message = "주문자 이름은 10자 이하여야 합니다")
private final List<CartItemDto> items; // 장바구니 항목 리스트

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class OrderCreateResponseDto {
private Long storeId; // 상점 ID
private String storeName; // 상점 이름
private String sessionId;
private String depositorName;
private List<OrderItemResponseDTO> orderItems; // 주문 항목 목록

public static OrderCreateResponseDto fromEntity(UserOrder order) {
Expand All @@ -24,6 +25,7 @@ public static OrderCreateResponseDto fromEntity(UserOrder order) {
.storeId(order.getStore().getStoreId())
.storeName(order.getStore().getName())
.sessionId(order.getSessionId())
.depositorName(order.getDepositorName())
.orderItems(List.of())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public OrderCreateResponseDto createOrder(Long storeId, Long tableId,
.store(store)
.signature(signature) // signature 저장
.sessionId(sessionId) // sessionId 저장
.depositorName(orderCreateRequestDto.getDepositorName())
.build();
UserOrder savedOrder = orderRepository.save(order);

Expand Down Expand Up @@ -102,10 +103,16 @@ public List<OrderItemListGetResponseDto> getOrderItems(Long storeId, Long tableI

private static void parameterValidation(Long storeId, Long tableId, OrderCreateRequestDto orderCreateRequestDto) {
if (storeId == null || tableId == null || orderCreateRequestDto == null) {
throw new OrderParameterEmptyException();
throw new OrderParameterEmptyException();
}
if (orderCreateRequestDto.getItems() == null || orderCreateRequestDto.getItems().isEmpty()) {
throw new OrderItemsEmptyException();
throw new OrderItemsEmptyException();
}
if (orderCreateRequestDto.getDepositorName() == null || orderCreateRequestDto.getDepositorName().trim().isEmpty()) {
throw new OrderParameterEmptyException();
}
if (orderCreateRequestDto.getDepositorName().length() > 20) {
throw new IllegalArgumentException("Depositor name is too long");
}
}
private String generateOrderSignature(Long storeId, Long tableId, List<CartItemDto> items) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum ErrorMessage {
ORDER_PARAMETER_EMPTY("주문 생성 시 파라미터 정보가 없습니다.", "order001"),
ORDER_ITEMS_EMPTY("주문 항목이 없습니다.", "order002"),
DUPLICATE_ORDER("동일한 주문이 접수되었습니다.", "order003"),
DEPOSITOR_NAME_TOO_LONG("주문자명은 10자 이내 글자열입니다.", "order004"),

//reservation
NOTFOUND_RESERVATION("저장된 예약 정보가 없습니다.", "reservation001"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ public class UserOrder extends BaseTimeEntity {
private List<OrderItem> orderItems = new ArrayList<>();

private String sessionId;
@Column(length = 10) // 예약자 이름 길이 제한
private String depositorName;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

데이터베이스 제약사항 추가를 고려해보세요.

depositorName 필드에 적절한 데이터베이스 제약사항을 추가하는 것을 권장합니다. 다른 String 필드(signature)와의 일관성을 위해 길이 제한을 설정하고, 개인정보 보호 관점에서도 적절한 제약을 두는 것이 좋겠습니다.

-	private String depositorName;
+	@Column(length = 100) // 예약자 이름 길이 제한
+	private String depositorName;

또한 필드 순서를 고려하여 sessionId 다음에 배치하는 것도 고려해보세요:

 	private String sessionId;
 
+	@Column(length = 100)
 	private String depositorName;
-
-	private String depositorName;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private String depositorName;
private String sessionId;
@Column(length = 100) // 예약자 이름 길이 제한
private String depositorName;
🤖 Prompt for AI Agents
In domain-order/src/main/java/com/nowait/order/entity/UserOrder.java at line 50,
add appropriate database constraints to the depositorName field by specifying a
length limit consistent with other String fields like signature to ensure data
integrity and privacy. Also, reorder the depositorName field to be declared
immediately after the sessionId field to maintain logical grouping of related
fields.


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nowait.order.exception;

import com.nowait.common.exception.ErrorMessage;

public class DepositorNameTooLongException extends RuntimeException {
public DepositorNameTooLongException() {
super(ErrorMessage.DEPOSITOR_NAME_TOO_LONG.getMessage());
}
}