- Timestamp:
- 01/04/23 02:56:41 (23 months ago)
- Branches:
- main
- Children:
- 7d43957
- Parents:
- ae042f4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/controller/UserController.java
rae042f4 rab952ab 4 4 import com.example.autopartz.repository.RepairsForUserRepository; 5 5 import com.example.autopartz.repository.ReviewsForUserRepository; 6 import com.example.autopartz.service.UserService; 6 7 import org.springframework.stereotype.Controller; 7 8 import org.springframework.ui.Model; … … 9 10 import org.springframework.web.bind.annotation.PathVariable; 10 11 import org.springframework.web.bind.annotation.RequestMapping; 12 13 import javax.servlet.http.HttpServletRequest; 11 14 12 15 @Controller … … 16 19 private final RepairsForUserRepository repairsForUserRepository; 17 20 private final ReviewsForUserRepository reviewsForUserRepository; 18 public UserController(OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) { 21 private final UserService userService; 22 public UserController(OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository, UserService userService) { 19 23 this.ordersForUserRepository = ordersForUserRepository; 20 24 this.repairsForUserRepository = repairsForUserRepository; 21 25 this.reviewsForUserRepository = reviewsForUserRepository; 26 this.userService = userService; 22 27 } 23 @GetMapping("orders/{id}") 24 public String getOrdersForUser(@PathVariable Integer id, Model model){ 28 @GetMapping("orders") 29 public String getOrdersForUser(Model model, HttpServletRequest request){ 30 Integer id = userService.findByUsername(request.getRemoteUser()).getID_user(); 25 31 model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id)); 26 32 model.addAttribute("bodyContent","ordersForUser"); 27 33 return "master-template"; 28 34 } 29 @GetMapping("repairs/{id}") 30 public String getRepairsForUser(@PathVariable Integer id,Model model){ 35 @GetMapping("repairs") 36 public String getRepairsForUser(Model model, HttpServletRequest request){ 37 Integer id = userService.findByUsername(request.getRemoteUser()).getID_user(); 31 38 model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id)); 32 39 model.addAttribute("bodyContent","repairsForUser"); 33 40 return "master-template"; 34 41 } 35 @GetMapping("reviews/{id}") 36 public String getReviewsForUser(@PathVariable Integer id, Model model){ 42 @GetMapping("reviews") 43 public String getReviewsForUser(Model model,HttpServletRequest request){ 44 Integer id = userService.findByUsername(request.getRemoteUser()).getID_user(); 37 45 model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id)); 38 46 model.addAttribute("bodyContent","reviewsForUser");
Note:
See TracChangeset
for help on using the changeset viewer.