- Timestamp:
- 01/03/23 23:03:00 (23 months ago)
- Branches:
- main
- Children:
- 6832924
- Parents:
- feffc2f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/controller/HomeController.java
rfeffc2f r60de3eb 2 2 3 3 import com.example.autopartz.model.User; 4 import com.example.autopartz.repository.PartsForCarTypeAndCategoryRepository; 5 import com.example.autopartz.service.CarService; 6 import com.example.autopartz.service.CategoryService; 4 7 import com.example.autopartz.service.LoginService; 5 8 import com.example.autopartz.service.PartService; … … 16 19 private final LoginService loginService; 17 20 private final PartService partService; 21 private final PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository; 22 private final CarService carService; 23 private final CategoryService categoryService; 18 24 19 public HomeController(LoginService loginService, PartService partService ) {25 public HomeController(LoginService loginService, PartService partService, PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository, CarService carService, CategoryService categoryService) { 20 26 this.loginService = loginService; 21 27 this.partService = partService; 28 this.partsForCarTypeAndCategoryRepository = partsForCarTypeAndCategoryRepository; 29 this.carService = carService; 30 this.categoryService = categoryService; 22 31 } 23 32 … … 25 34 public String getHomePage(Model model){ 26 35 model.addAttribute("parts",partService.findAll()); 27 return "homepage"; 36 model.addAttribute("cars",carService.findAll()); 37 model.addAttribute("categories",categoryService.findAll()); 38 model.addAttribute("bodyContent","homepage"); 39 return "master-template"; 40 } 41 @GetMapping("/filtered") 42 public String getPartsForCarTypeAndCategory(@RequestParam String cartype, @RequestParam String category, Model model){ 43 model.addAttribute("filtered", partsForCarTypeAndCategoryRepository.findAllByCartypeAndCategory(cartype,category)); 44 model.addAttribute("bodyContent","filteredParts"); 45 return "master-template"; 28 46 } 29 47 @GetMapping("/login") 30 public String getLoginPage(){ 31 return "login"; 48 public String getLoginPage(Model model){ 49 model.addAttribute("bodyContent","login"); 50 return "master-template"; 32 51 } 33 52 @GetMapping("/register") 34 public String getRegisterPage(){ 35 return "register"; 53 public String getRegisterPage(Model model){ 54 model.addAttribute("bodyContent","register"); 55 return "master-template"; 36 56 } 37 57 @PostMapping("/login") 38 58 public void handleLogin(@RequestParam String username, @RequestParam String password){ 39 59 User u = loginService.login(username,password); 60 System.out.println(u.getName_user()); 40 61 } 41 62 @PostMapping("/register")
Note:
See TracChangeset
for help on using the changeset viewer.