Skip to content

Commit 3ef6ea5

Browse files
committed
refactor(Order): 당일 주문만 조회할 수 있도록 날짜 필터링 추가
1 parent 11053b5 commit 3ef6ea5

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/order/controller/OrderController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class OrderController {
3535

3636
@GetMapping("/{storeId}")
3737
@Operation(summary = "주점별 주문리스트 조회", description = "특정 주점에 대한 예약리스트 조회")
38-
@ApiResponse(responseCode = "200", description = "주리스트 조회")
38+
@ApiResponse(responseCode = "200", description = "주문 리스트 조회")
3939
public ResponseEntity<?> getOrderListByStoreId(@PathVariable Long storeId,
4040
@AuthenticationPrincipal MemberDetails memberDetails) {
4141
List<OrderResponseDto> response = orderService.findAllOrders(storeId, memberDetails);

nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/order/service/OrderService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.nowait.applicationadmin.order.service;
22

33
import java.time.LocalDate;
4+
import java.time.LocalDateTime;
5+
import java.time.ZoneId;
46
import java.util.List;
57
import java.util.stream.Collectors;
68

@@ -46,7 +48,11 @@ public List<OrderResponseDto> findAllOrders(Long storeId, MemberDetails memberDe
4648
if (!Role.SUPER_ADMIN.equals(user.getRole()) && !user.getStoreId().equals(storeId)) {
4749
throw new OrderViewUnauthorizedException();
4850
}
49-
return orderRepository.findAllByStore_StoreId(storeId)
51+
52+
LocalDate today = LocalDate.now(ZoneId.of("Asia/Seoul"));
53+
LocalDateTime startDateTime = today.atStartOfDay();
54+
LocalDateTime endDateTime = today.plusDays(1).atStartOfDay();
55+
return orderRepository.findAllByStore_StoreIdAndCreatedAtBetween(storeId, startDateTime, endDateTime)
5056
.stream()
5157
.map(OrderResponseDto::fromEntity)
5258
.collect(Collectors.toList());

nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/order/repository/OrderRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ public interface OrderRepository extends JpaRepository<UserOrder, Long> {
1616
List<UserOrder> findByStore_StoreIdAndTableIdAndSessionId(Long storeId, Long tableId, String sessionId);
1717

1818
@EntityGraph(attributePaths = {"orderItems", "orderItems.menu"})
19-
List<UserOrder> findAllByStore_StoreId(Long storeId);
19+
List<UserOrder> findAllByStore_StoreIdAndCreatedAtBetween(Long storeId, LocalDateTime startDateTime, LocalDateTime endDateTime);
2020
}

0 commit comments

Comments
 (0)