This repository has been archived on 2020-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
e-commerce/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomerOrderController.java

39 lines
1.3 KiB
Java
Raw Normal View History

2020-04-29 22:44:16 +02:00
package org.hso.ecommerce.controller.intern.customers;
2020-04-28 22:41:29 +02:00
2020-06-01 11:31:12 +02:00
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.repos.shop.CustomerOderRepository;
import org.springframework.beans.factory.annotation.Autowired;
2020-04-28 22:41:29 +02:00
import org.springframework.stereotype.Controller;
2020-06-01 11:31:12 +02:00
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
2020-06-01 11:53:29 +02:00
import org.springframework.web.bind.annotation.PathVariable;
2020-06-01 11:31:12 +02:00
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
2020-04-28 22:41:29 +02:00
@Controller
2020-06-01 11:31:12 +02:00
@RequestMapping("intern/customerOrders")
2020-05-01 10:48:12 +02:00
public class CustomerOrderController {
2020-06-01 11:31:12 +02:00
@Autowired
private final CustomerOderRepository customerOrderRepository = null;
@GetMapping("")
public String internCustomerOrder(Model model) {
List<CustomerOrder> orders = customerOrderRepository.getAllOrders();
model.addAttribute("orders", orders);
return "intern/customerOrders/index";
}
@GetMapping("/{id}")
2020-06-01 11:53:29 +02:00
public String internCustomerOrdersId(Model model,
@PathVariable("id") String id
) {
CustomerOrder order = customerOrderRepository.findById(Long.parseLong(id)).get();
model.addAttribute("order", order);
2020-06-01 11:31:12 +02:00
return "intern/customerOrders/id";
}
2020-04-28 22:41:29 +02:00
}