[2e46f06] | 1 | package com.example.autopartz.controller;
|
---|
| 2 |
|
---|
[23a2bc5] | 3 | import com.example.autopartz.model.*;
|
---|
| 4 | import com.example.autopartz.repository.*;
|
---|
[2e46f06] | 5 | import com.example.autopartz.service.UserService;
|
---|
[23a2bc5] | 6 | import org.springframework.web.bind.annotation.*;
|
---|
[2e46f06] | 7 |
|
---|
| 8 | import java.util.List;
|
---|
| 9 |
|
---|
| 10 | @RestController
|
---|
| 11 | @RequestMapping("/")
|
---|
| 12 | public class UserController {
|
---|
| 13 | private final UserService userService;
|
---|
[23a2bc5] | 14 | private final RepairShopReviewSummaryRepository repairShopReviewSummaryRepository;
|
---|
| 15 | private final PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository;
|
---|
[2e46f06] | 16 |
|
---|
[23a2bc5] | 17 | private final OrdersForUserRepository ordersForUserRepository;
|
---|
| 18 | private final RepairsForUserRepository repairsForUserRepository;
|
---|
| 19 | private final ReviewsForUserRepository reviewsForUserRepository;
|
---|
| 20 | public UserController(UserService userService, RepairShopReviewSummaryRepository repairShopReviewSummaryRepository, PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository, OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) {
|
---|
[2e46f06] | 21 | this.userService = userService;
|
---|
[23a2bc5] | 22 | this.repairShopReviewSummaryRepository = repairShopReviewSummaryRepository;
|
---|
| 23 | this.partsForCarTypeAndCategoryRepository = partsForCarTypeAndCategoryRepository;
|
---|
| 24 | this.ordersForUserRepository = ordersForUserRepository;
|
---|
| 25 | this.repairsForUserRepository = repairsForUserRepository;
|
---|
| 26 | this.reviewsForUserRepository = reviewsForUserRepository;
|
---|
[2e46f06] | 27 | }
|
---|
| 28 | @GetMapping("reportTest")
|
---|
| 29 | public List<RepairShopReviewsSummary> getRepairShopReport(){
|
---|
[23a2bc5] | 30 | return repairShopReviewSummaryRepository.findAll();
|
---|
[2e46f06] | 31 | }
|
---|
| 32 | @GetMapping("usersTest")
|
---|
| 33 | public List<User> getAllUsers(){
|
---|
| 34 | return userService.findAllUsers();
|
---|
| 35 | }
|
---|
[23a2bc5] | 36 | @GetMapping("parts")
|
---|
| 37 | public List<PartsForCarTypeAndCategory> getPartsForCarTypeAndCategory(@RequestParam String cartype, @RequestParam String category){
|
---|
| 38 | return partsForCarTypeAndCategoryRepository.findAllByCartypeAndCategory(cartype,category);
|
---|
| 39 | }
|
---|
| 40 | @GetMapping("orders/{id}")
|
---|
| 41 | public List<OrdersForUser> getOrdersForUser(@PathVariable Long id){
|
---|
| 42 | return ordersForUserRepository.findAllByUserid(id);
|
---|
| 43 | }
|
---|
| 44 | @GetMapping("repairs/{id}")
|
---|
| 45 | public List<RepairsForUser> getRepairsForUser(@PathVariable Long id){
|
---|
| 46 | return repairsForUserRepository.findAllByUserid(id);
|
---|
| 47 | }
|
---|
| 48 | @GetMapping("reviews/{id}")
|
---|
| 49 | public List<ReviewsForUser> getReviewsForUser(@PathVariable Long id){
|
---|
| 50 | return reviewsForUserRepository.findAllByUserid(id);
|
---|
| 51 | }
|
---|
[2e46f06] | 52 | }
|
---|