Changeset ae042f4 for src/main/java/com/example/autopartz/controller
- Timestamp:
- 01/04/23 02:49:26 (23 months ago)
- Branches:
- main
- Children:
- ab952ab
- Parents:
- 6832924
- Location:
- src/main/java/com/example/autopartz/controller
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/controller/HomeController.java
r6832924 rae042f4 14 14 import org.springframework.web.bind.annotation.RequestMapping; 15 15 import org.springframework.web.bind.annotation.RequestParam; 16 17 import javax.servlet.http.HttpServletRequest; 16 18 17 19 @Controller … … 35 37 36 38 @GetMapping() 37 public String getHomePage(Model model ){39 public String getHomePage(Model model, HttpServletRequest request){ 38 40 model.addAttribute("bodyContent","home"); 41 model.addAttribute("user",request.getRemoteUser()); 39 42 return "master-template"; 40 43 } -
src/main/java/com/example/autopartz/controller/PartController.java
r6832924 rae042f4 5 5 import com.example.autopartz.service.PriceService; 6 6 import com.example.autopartz.service.RepairShopService; 7 import jakarta.servlet.http.HttpServletResponse;8 7 import org.springframework.stereotype.Controller; 9 8 import org.springframework.ui.Model; 10 9 import org.springframework.web.bind.annotation.*; 11 10 11 import javax.servlet.http.HttpServletResponse; 12 12 import java.io.IOException; 13 13 … … 24 24 } 25 25 @GetMapping("/{id}") 26 public String getPartPage(@PathVariable Longid, Model model){26 public String getPartPage(@PathVariable Integer id, Model model){ 27 27 Part temp = partService.findById(id); 28 28 Integer amount = priceService.findPriceForPart(temp).stream().findFirst().orElseThrow(RuntimeException::new).getAmount(); … … 33 33 } 34 34 @GetMapping("/delivery/{id}") 35 public String getDeliveryPage(@PathVariable Longid, Model model){35 public String getDeliveryPage(@PathVariable Integer id, Model model){ 36 36 model.addAttribute("repairShops",repairShopService.findAll()); 37 37 model.addAttribute("partId",id); -
src/main/java/com/example/autopartz/controller/UserController.java
r6832924 rae042f4 1 1 package com.example.autopartz.controller; 2 2 3 import com.example.autopartz.model.*; 4 import com.example.autopartz.model.views.*; 5 import com.example.autopartz.repository.*; 6 import com.example.autopartz.service.UserService; 3 import com.example.autopartz.repository.OrdersForUserRepository; 4 import com.example.autopartz.repository.RepairsForUserRepository; 5 import com.example.autopartz.repository.ReviewsForUserRepository; 7 6 import org.springframework.stereotype.Controller; 8 7 import org.springframework.ui.Model; 9 import org.springframework.web.bind.annotation. *;10 11 import java.util.List;8 import org.springframework.web.bind.annotation.GetMapping; 9 import org.springframework.web.bind.annotation.PathVariable; 10 import org.springframework.web.bind.annotation.RequestMapping; 12 11 13 12 @Controller 14 13 @RequestMapping("/") 15 14 public class UserController { 16 private final UserService userService;17 15 private final OrdersForUserRepository ordersForUserRepository; 18 16 private final RepairsForUserRepository repairsForUserRepository; 19 17 private final ReviewsForUserRepository reviewsForUserRepository; 20 public UserController(UserService userService, OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) { 21 this.userService = userService; 18 public UserController(OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) { 22 19 this.ordersForUserRepository = ordersForUserRepository; 23 20 this.repairsForUserRepository = repairsForUserRepository; 24 21 this.reviewsForUserRepository = reviewsForUserRepository; 25 22 } 26 @GetMapping("usersTest")27 public List<User> getAllUsers(){28 return userService.findAllUsers();29 }30 23 @GetMapping("orders/{id}") 31 public String getOrdersForUser(@PathVariable Longid, Model model){24 public String getOrdersForUser(@PathVariable Integer id, Model model){ 32 25 model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id)); 33 26 model.addAttribute("bodyContent","ordersForUser"); … … 35 28 } 36 29 @GetMapping("repairs/{id}") 37 public String getRepairsForUser(@PathVariable Longid,Model model){30 public String getRepairsForUser(@PathVariable Integer id,Model model){ 38 31 model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id)); 39 32 model.addAttribute("bodyContent","repairsForUser"); … … 41 34 } 42 35 @GetMapping("reviews/{id}") 43 public String getReviewsForUser(@PathVariable Longid, Model model){36 public String getReviewsForUser(@PathVariable Integer id, Model model){ 44 37 model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id)); 45 38 model.addAttribute("bodyContent","reviewsForUser");
Note:
See TracChangeset
for help on using the changeset viewer.