Skip to content

Commit

Permalink
feat: 요리 완료 상태로 변경하는 service 메서드 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
choi5798 committed Sep 15, 2023
1 parent 7294ac0 commit cae350f
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.ray.pominowner.orders.domain.OrderStatus;
import com.ray.pominowner.orders.repository.OrderRepository;
import com.ray.pominowner.payment.service.PaymentService;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalTime;
import java.util.List;
Expand Down Expand Up @@ -34,6 +34,7 @@ public Order approve(Long orderId) {
OrderStatus.COOKING,
generator.incrementAndGet(),
LocalTime.now().plusMinutes(15));

orderRepository.save(approvedOrder);

return approvedOrder;
Expand All @@ -53,6 +54,17 @@ public Order reject(Long orderId) {
return rejectedOrder;
}

public Order finishCooking(Long orderId) {
Order order = orderRepository.findById(orderId).orElseThrow(
() -> new IllegalArgumentException("해당하는 주문이 없습니다"));

Order readyOrder = Order.of(order, OrderStatus.READY);

orderRepository.save(readyOrder);

return readyOrder;
}

public List<Order> getTodayOrders(Long storeId) {
List<Order> storeOrders = orderRepository.findAllByStoreId(storeId);

Expand Down

0 comments on commit cae350f

Please sign in to comment.