Ignore:
Timestamp:
01/03/23 03:14:50 (18 months ago)
Author:
andrejtodorovski <82031894+andrejtodorovski@…>
Branches:
main
Children:
eaf0f1b
Parents:
101cbe2
Message:

Added some views and tested them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/autopartz/controller/UserController.java

    r101cbe2 r23a2bc5  
    11package com.example.autopartz.controller;
    22
    3 import com.example.autopartz.model.RepairShopReviewsSummary;
    4 import com.example.autopartz.model.User;
    5 import com.example.autopartz.repository.RepairShopReviewSummaryRepository;
     3import com.example.autopartz.model.*;
     4import com.example.autopartz.repository.*;
    65import com.example.autopartz.service.UserService;
    7 import org.springframework.web.bind.annotation.GetMapping;
    8 import org.springframework.web.bind.annotation.RequestMapping;
    9 import org.springframework.web.bind.annotation.RestController;
     6import org.springframework.web.bind.annotation.*;
    107
    118import java.util.List;
     
    1512public class UserController {
    1613    private final UserService userService;
    17     private final RepairShopReviewSummaryRepository rspsr;
     14    private final RepairShopReviewSummaryRepository repairShopReviewSummaryRepository;
     15    private final PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository;
    1816
    19     public UserController(UserService userService, RepairShopReviewSummaryRepository rspsr) {
     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) {
    2021        this.userService = userService;
    21         this.rspsr = rspsr;
     22        this.repairShopReviewSummaryRepository = repairShopReviewSummaryRepository;
     23        this.partsForCarTypeAndCategoryRepository = partsForCarTypeAndCategoryRepository;
     24        this.ordersForUserRepository = ordersForUserRepository;
     25        this.repairsForUserRepository = repairsForUserRepository;
     26        this.reviewsForUserRepository = reviewsForUserRepository;
    2227    }
    2328    @GetMapping("reportTest")
    2429    public List<RepairShopReviewsSummary> getRepairShopReport(){
    25         return rspsr.findAllByRsid(2L);
     30        return repairShopReviewSummaryRepository.findAll();
    2631    }
    2732    @GetMapping("usersTest")
     
    2934        return userService.findAllUsers();
    3035    }
     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    }
    3152}
Note: See TracChangeset for help on using the changeset viewer.