diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomerOrderController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomerOrderController.java index 621d906..af9b692 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomerOrderController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomerOrderController.java @@ -1,22 +1,17 @@ package org.hso.ecommerce.controller.intern.customers; import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import org.hso.ecommerce.api.RestServiceForDelivery; import org.hso.ecommerce.entities.shop.CustomerOrder; - import org.hso.ecommerce.repos.shop.CustomerOrderRepository; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.format.datetime.DateFormatterRegistrar; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import javax.transaction.Transaction; import java.sql.Timestamp; -import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -78,7 +73,8 @@ public class CustomerOrderController { e.printStackTrace(); } - customerOrderRepository.updateUserDeliveredAt(customerOrder.id, new Timestamp(calendar.getTimeInMillis())); + customerOrder.deliveredAt = new Timestamp(calendar.getTimeInMillis()); + customerOrderRepository.save(customerOrder); } return deliveryData; diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/warehouse/TodoController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/warehouse/TodoController.java index 4bed5cd..c8fb54f 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/warehouse/TodoController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/warehouse/TodoController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.client.ResourceAccessException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -75,7 +76,14 @@ public class TodoController { // Update Delivery Date if (booking.get().reason.customerOrder != null) { - EnableTrackingAction.addTrackingInfo(booking.get().reason.customerOrder); + try{ + EnableTrackingAction.addTrackingInfo(booking.get().reason.customerOrder); + } + catch(ResourceAccessException e) + { + return "error/500"; + } + } warehouseBookingRepository.save(booking.get()); diff --git a/prototype/src/main/java/org/hso/ecommerce/repos/shop/CustomerOrderRepository.java b/prototype/src/main/java/org/hso/ecommerce/repos/shop/CustomerOrderRepository.java index 653cd08..184831b 100644 --- a/prototype/src/main/java/org/hso/ecommerce/repos/shop/CustomerOrderRepository.java +++ b/prototype/src/main/java/org/hso/ecommerce/repos/shop/CustomerOrderRepository.java @@ -22,12 +22,6 @@ public interface CustomerOrderRepository extends JpaRepository getAllOrders(); - @Transactional - @Modifying(clearAutomatically = true) - @Query("UPDATE CustomerOrder co SET co.deliveredAt = :newDeliveredAt WHERE co.id = :customerOrderID") - int updateUserDeliveredAt(long customerOrderID, java.sql.Timestamp newDeliveredAt); - - @Query("SELECT co FROM CustomerOrder co WHERE co.customer.id = :userId ORDER BY co.id DESC") List getOrdersByUserId(long userId);