- Timestamp:
- 01/05/23 12:40:07 (23 months ago)
- Branches:
- main
- Children:
- f484b14
- Parents:
- 676144b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/controller/HomeController.java
r676144b r1bd8d1e 1 1 package com.example.autopartz.controller; 2 2 3 import com.example.autopartz.model.Order; 4 import com.example.autopartz.model.User; 5 import com.example.autopartz.model.Warehouse; 6 import com.example.autopartz.repository.OrderContainsPartRepository; 7 import com.example.autopartz.repository.PartsForCarTypeAndCategoryRepository; 8 import com.example.autopartz.repository.RepairShopReviewSummaryRepository; 9 import com.example.autopartz.repository.WarehouseRepository; 3 import com.example.autopartz.model.*; 4 import com.example.autopartz.model.manytomany.PartIsInStockInWarehouse; 5 import com.example.autopartz.repository.*; 10 6 import com.example.autopartz.service.*; 11 7 import org.springframework.stereotype.Controller; … … 20 16 import javax.servlet.http.HttpSession; 21 17 import java.io.IOException; 18 import java.util.List; 22 19 import java.util.Objects; 23 20 … … 34 31 private final OrderContainsPartRepository orderContainsPartRepository; 35 32 private final OrderService orderService; 36 33 private final UserService userService; 34 private final DeliveryService deliveryService; 35 private final PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository; 37 36 public HomeController(LoginService loginService, PartService partService, PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository, CarService carService, CategoryService categoryService, RepairShopReviewSummaryRepository repairShopReviewSummaryRepository, WarehouseRepository warehouseRepository, 38 OrderContainsPartRepository orderContainsPartRepository, OrderService orderService ) {37 OrderContainsPartRepository orderContainsPartRepository, OrderService orderService, UserService userService, DeliveryService deliveryService, PartIsInStockInWarehouseRepository partIsInStockInWarehouseRepository) { 39 38 this.loginService = loginService; 40 39 this.partService = partService; … … 46 45 this.orderContainsPartRepository = orderContainsPartRepository; 47 46 this.orderService = orderService; 47 this.userService = userService; 48 this.deliveryService = deliveryService; 49 this.partIsInStockInWarehouseRepository = partIsInStockInWarehouseRepository; 48 50 } 49 51 … … 78 80 model.addAttribute("hasError",false); 79 81 model.addAttribute("order",o); 80 model.addAttribute("parts",orderService.findById(o.get ID_order()).getPartList());82 model.addAttribute("parts",orderService.findById(o.getOrderid()).getPartList()); 81 83 } 82 84 model.addAttribute("bodyContent","currentOrder"); … … 154 156 } 155 157 } 158 @GetMapping("/access_denied") 159 public String accessDenied(Model model){ 160 model.addAttribute("bodyContent","access_denied"); 161 return "master-template"; 162 } 163 @GetMapping("/myWarehouse") 164 public String myWarehouse(Model model, HttpServletRequest request){ 165 Warehouseman whm = (Warehouseman) userService.findByUsername(request.getRemoteUser()); 166 Warehouse warehouse = whm.getWarehouse(); 167 List<PartIsInStockInWarehouse> partIsInStockInWarehouseList = partIsInStockInWarehouseRepository.findAllByWarehouseid(warehouse.getID_warehouse()); 168 model.addAttribute("bodyContent","myWarehouse"); 169 model.addAttribute("warehouse",warehouse); 170 model.addAttribute("parts", partIsInStockInWarehouseList); 171 return "master-template"; 172 } 173 @GetMapping("myDeliveries") 174 public String myDeliveries(Model model, HttpServletRequest request){ 175 Deliveryman dm = (Deliveryman) userService.findByUsername(request.getRemoteUser()); 176 List<Delivery> deliveries = deliveryService.findAllByDeliverer(dm); 177 model.addAttribute("bodyContent","myDeliveries"); 178 model.addAttribute("deliveries",deliveries); 179 return "master-template"; 180 } 156 181 }
Note:
See TracChangeset
for help on using the changeset viewer.