Changeset 60de3eb for src/main/java/com/example/autopartz
- Timestamp:
- 01/03/23 23:03:00 (23 months ago)
- Branches:
- main
- Children:
- 6832924
- Parents:
- feffc2f
- Location:
- src/main/java/com/example/autopartz
- Files:
-
- 6 added
- 6 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") -
src/main/java/com/example/autopartz/controller/PartController.java
rfeffc2f r60de3eb 29 29 model.addAttribute("part",temp); 30 30 model.addAttribute("amount",amount); 31 return "partinfo"; 31 model.addAttribute("bodyContent","partinfo"); 32 return "master-template"; 32 33 } 33 34 @GetMapping("/delivery/{id}") … … 35 36 model.addAttribute("repairShops",repairShopService.findAll()); 36 37 model.addAttribute("partId",id); 37 return "deliveryForPart"; 38 model.addAttribute("bodyContent","deliveryForPart"); 39 return "master-template"; 38 40 } 39 41 @PostMapping("/repairshopdelivery") -
src/main/java/com/example/autopartz/controller/UserController.java
rfeffc2f r60de3eb 16 16 private final UserService userService; 17 17 private final RepairShopReviewSummaryRepository repairShopReviewSummaryRepository; 18 private final PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository;19 18 20 19 private final OrdersForUserRepository ordersForUserRepository; 21 20 private final RepairsForUserRepository repairsForUserRepository; 22 21 private final ReviewsForUserRepository reviewsForUserRepository; 23 public UserController(UserService userService, RepairShopReviewSummaryRepository repairShopReviewSummaryRepository, PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository,OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) {22 public UserController(UserService userService, RepairShopReviewSummaryRepository repairShopReviewSummaryRepository, OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) { 24 23 this.userService = userService; 25 24 this.repairShopReviewSummaryRepository = repairShopReviewSummaryRepository; 26 this.partsForCarTypeAndCategoryRepository = partsForCarTypeAndCategoryRepository;27 25 this.ordersForUserRepository = ordersForUserRepository; 28 26 this.repairsForUserRepository = repairsForUserRepository; … … 37 35 return userService.findAllUsers(); 38 36 } 39 @GetMapping("parts")40 public List<PartsForCarTypeAndCategory> getPartsForCarTypeAndCategory(@RequestParam String cartype, @RequestParam String category){41 return partsForCarTypeAndCategoryRepository.findAllByCartypeAndCategory(cartype,category);42 }43 37 @GetMapping("orders/{id}") 44 38 public String getOrdersForUser(@PathVariable Long id, Model model){ 45 39 model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id)); 46 return "ordersForUser"; 40 model.addAttribute("bodyContent","ordersForUser"); 41 return "master-template"; 47 42 } 48 43 @GetMapping("repairs/{id}") 49 44 public String getRepairsForUser(@PathVariable Long id,Model model){ 50 45 model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id)); 51 return "repairsForUser"; 46 model.addAttribute("bodyContent","repairsForUser"); 47 return "master-template"; 52 48 } 53 49 @GetMapping("reviews/{id}") 54 50 public String getReviewsForUser(@PathVariable Long id, Model model){ 55 51 model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id)); 56 return "reviewsForUser"; 52 model.addAttribute("bodyContent","reviewsForUser"); 53 return "master-template"; 57 54 } 58 55 } -
src/main/java/com/example/autopartz/model/Car.java
rfeffc2f r60de3eb 18 18 Integer in_production_since; 19 19 Integer in_production_till; 20 String car_type; 20 @Column(name = "car_type") 21 String cartype; 21 22 @ManyToOne 22 23 @JoinColumn(name = "id_car_manufacturer") -
src/main/java/com/example/autopartz/model/Category.java
rfeffc2f r60de3eb 1 1 package com.example.autopartz.model; 2 2 3 import jakarta.persistence.Entity; 4 import jakarta.persistence.Id; 5 import jakarta.persistence.JoinColumn; 6 import jakarta.persistence.ManyToOne; 3 import jakarta.persistence.*; 7 4 import lombok.*; 8 5 import org.hibernate.Hibernate; … … 18 15 @Id 19 16 Long ID_category; 20 String category_name; 17 @Column(name = "category_name") 18 String cname; 21 19 @ManyToOne 22 20 @JoinColumn(name = "id_parent_category") -
src/main/java/com/example/autopartz/model/views/PartsForCarTypeAndCategory.java
rfeffc2f r60de3eb 25 25 String cartype; 26 26 String category; 27 String pmname; 27 28 }
Note:
See TracChangeset
for help on using the changeset viewer.