- Timestamp:
- 01/06/23 21:29:06 (23 months ago)
- Branches:
- main
- Children:
- 4d67d70
- Parents:
- cab5859
- Location:
- src/main
- Files:
-
- 1 added
- 2 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"); -
src/main/resources/templates/currentOrder.html
rcab5859 r89865ae 3 3 <div th:if="${!hasError}"> 4 4 <h3 class="mt-3 mb-3"> 5 Нарачка за корисник : <span th:text="${order.getUser().getUsername()}"></span>5 Тековна нарачка за корисник : <span th:text="${order.getUser().getUsername()}"></span> 6 6 </h3> 7 7 <table class="table table-bordered"> 8 8 <thead class="thead-dark"> 9 9 <tr> 10 <th>Name</th> 11 <th>Manufacturer</th> 10 <th>Име</th> 11 <th>Производител</th> 12 <th>Количина</th> 13 <th>Вкупна цена</th> 12 14 </tr> 13 15 </thead> 14 16 <tbody> 15 17 <tr th:each="part : ${parts}"> 16 <td th:text="${part.getName()}"></td> 17 <td th:text="${part.getManufacturer().getName()}"></td> 18 <td th:text="${part.getPartName()}"></td> 19 <td th:text="${part.getManufacturerName()}"></td> 20 <td th:text="${part.getQuantity()}"></td> 21 <td th:text="${part.getPrice()}"></td> 22 18 23 </tr> 19 24 </tbody> 20 25 </table> 26 <h3>Вкупен износ : <span th:text="${total}"></span></h3> 21 27 <form th:action="@{'/part/delivery/'}"> 22 28 <button class="btn btn-primary btn-block btn-lg" type="submit">Испрати нарачка</button>
Note:
See TracChangeset
for help on using the changeset viewer.