del update query and impl error for trackigID
This commit is contained in:
		@ -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;
 | 
			
		||||
 | 
			
		||||
@ -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());
 | 
			
		||||
 | 
			
		||||
@ -22,12 +22,6 @@ public interface CustomerOrderRepository extends JpaRepository<CustomerOrder, Lo
 | 
			
		||||
    @Query("SELECT co FROM CustomerOrder co ORDER BY co.created DESC")
 | 
			
		||||
    List<CustomerOrder> 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<CustomerOrder> getOrdersByUserId(long userId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user