- Timestamp:
- 01/04/23 02:49:26 (23 months ago)
- Branches:
- main
- Children:
- ab952ab
- Parents:
- 6832924
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.