Changeset 89865ae for src/main/java/com
- Timestamp:
- 01/06/23 21:29:06 (23 months ago)
- Branches:
- main
- Children:
- 4d67d70
- Parents:
- cab5859
- Location:
- src/main/java/com/example/autopartz
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/controller/HomeController.java
rcab5859 r89865ae 2 2 3 3 import com.example.autopartz.model.*; 4 import com.example.autopartz.model.DTO.CurrentOrderDTO; 4 5 import com.example.autopartz.model.DTO.OrderInfo; 5 6 import com.example.autopartz.model.manytomany.OrderContainsPart; … … 40 41 private final PartManufacturersReportRepository partManufacturersReportRepository; 41 42 private final MostPurchasedPartRepository mostPurchasedPartRepository; 43 private final PriceService priceService; 42 44 public HomeController(LoginService loginService, PartService partService, PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository, CarService carService, CategoryService categoryService, RepairShopReviewSummaryRepository repairShopReviewSummaryRepository, WarehouseRepository warehouseRepository, 43 OrderContainsPartRepository orderContainsPartRepository, OrderService orderService, UserService userService, DeliveriesInProgressRepository deliveriesInProgressRepository, DeliveryService deliveryService, PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository, CarCategoryReportRepository carCategoryReportRepository, PartManufacturersReportRepository partManufacturersReportRepository, MostPurchasedPartRepository mostPurchasedPartRepository ) {45 OrderContainsPartRepository orderContainsPartRepository, OrderService orderService, UserService userService, DeliveriesInProgressRepository deliveriesInProgressRepository, DeliveryService deliveryService, PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository, CarCategoryReportRepository carCategoryReportRepository, PartManufacturersReportRepository partManufacturersReportRepository, MostPurchasedPartRepository mostPurchasedPartRepository, PriceService priceService) { 44 46 this.loginService = loginService; 45 47 this.partService = partService; … … 58 60 this.partManufacturersReportRepository = partManufacturersReportRepository; 59 61 this.mostPurchasedPartRepository = mostPurchasedPartRepository; 62 this.priceService = priceService; 60 63 } 61 64 … … 90 93 model.addAttribute("hasError",false); 91 94 model.addAttribute("order",o); 92 model.addAttribute("parts",orderService.findById(o.getOrderid()).getPartList()); 95 List<CurrentOrderDTO> list = new ArrayList<>(); 96 int total = 0; 97 List<OrderContainsPart> qList = orderContainsPartRepository.findAllByOrderid(o.getOrderid()); 98 for (int i = 0; i < qList.size(); i++) { 99 int pr = qList.get(i).getQuantity_order()* 100 priceService.findPriceForPart(partService.findById(qList.get(i).getPartid())).stream().findFirst().get().getAmount(); 101 CurrentOrderDTO temp = new CurrentOrderDTO( 102 partService.findById(qList.get(i).getPartid()).getName(), 103 partService.findById(qList.get(i).getPartid()).getManufacturer().getName(), 104 qList.get(i).getQuantity_order(), 105 pr); 106 list.add(temp); 107 total+=pr; 108 } 109 model.addAttribute("total",total); 110 model.addAttribute("parts",list); 93 111 } 94 112 model.addAttribute("bodyContent","currentOrder");
Note:
See TracChangeset
for help on using the changeset viewer.