Ignore:
Timestamp:
01/04/23 02:49:26 (23 months ago)
Author:
andrejtodorovski <82031894+andrejtodorovski@…>
Branches:
main
Children:
ab952ab
Parents:
6832924
Message:

Configured spring security, changed spring version

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  
    1414import org.springframework.web.bind.annotation.RequestMapping;
    1515import org.springframework.web.bind.annotation.RequestParam;
     16
     17import javax.servlet.http.HttpServletRequest;
    1618
    1719@Controller
     
    3537
    3638    @GetMapping()
    37     public String getHomePage(Model model){
     39    public String getHomePage(Model model, HttpServletRequest request){
    3840        model.addAttribute("bodyContent","home");
     41        model.addAttribute("user",request.getRemoteUser());
    3942        return "master-template";
    4043    }
  • src/main/java/com/example/autopartz/controller/PartController.java

    r6832924 rae042f4  
    55import com.example.autopartz.service.PriceService;
    66import com.example.autopartz.service.RepairShopService;
    7 import jakarta.servlet.http.HttpServletResponse;
    87import org.springframework.stereotype.Controller;
    98import org.springframework.ui.Model;
    109import org.springframework.web.bind.annotation.*;
    1110
     11import javax.servlet.http.HttpServletResponse;
    1212import java.io.IOException;
    1313
     
    2424    }
    2525    @GetMapping("/{id}")
    26     public String getPartPage(@PathVariable Long id, Model model){
     26    public String getPartPage(@PathVariable Integer id, Model model){
    2727        Part temp = partService.findById(id);
    2828        Integer amount = priceService.findPriceForPart(temp).stream().findFirst().orElseThrow(RuntimeException::new).getAmount();
     
    3333    }
    3434    @GetMapping("/delivery/{id}")
    35     public String getDeliveryPage(@PathVariable Long id, Model model){
     35    public String getDeliveryPage(@PathVariable Integer id, Model model){
    3636        model.addAttribute("repairShops",repairShopService.findAll());
    3737        model.addAttribute("partId",id);
  • src/main/java/com/example/autopartz/controller/UserController.java

    r6832924 rae042f4  
    11package com.example.autopartz.controller;
    22
    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;
     3import com.example.autopartz.repository.OrdersForUserRepository;
     4import com.example.autopartz.repository.RepairsForUserRepository;
     5import com.example.autopartz.repository.ReviewsForUserRepository;
    76import org.springframework.stereotype.Controller;
    87import org.springframework.ui.Model;
    9 import org.springframework.web.bind.annotation.*;
    10 
    11 import java.util.List;
     8import org.springframework.web.bind.annotation.GetMapping;
     9import org.springframework.web.bind.annotation.PathVariable;
     10import org.springframework.web.bind.annotation.RequestMapping;
    1211
    1312@Controller
    1413@RequestMapping("/")
    1514public class UserController {
    16     private final UserService userService;
    1715    private final OrdersForUserRepository ordersForUserRepository;
    1816    private final RepairsForUserRepository repairsForUserRepository;
    1917    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) {
    2219        this.ordersForUserRepository = ordersForUserRepository;
    2320        this.repairsForUserRepository = repairsForUserRepository;
    2421        this.reviewsForUserRepository = reviewsForUserRepository;
    2522    }
    26     @GetMapping("usersTest")
    27     public List<User> getAllUsers(){
    28         return userService.findAllUsers();
    29     }
    3023    @GetMapping("orders/{id}")
    31     public String getOrdersForUser(@PathVariable Long id, Model model){
     24    public String getOrdersForUser(@PathVariable Integer id, Model model){
    3225        model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id));
    3326        model.addAttribute("bodyContent","ordersForUser");
     
    3528    }
    3629    @GetMapping("repairs/{id}")
    37     public String getRepairsForUser(@PathVariable Long id,Model model){
     30    public String getRepairsForUser(@PathVariable Integer id,Model model){
    3831        model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id));
    3932        model.addAttribute("bodyContent","repairsForUser");
     
    4134    }
    4235    @GetMapping("reviews/{id}")
    43     public String getReviewsForUser(@PathVariable Long id, Model model){
     36    public String getReviewsForUser(@PathVariable Integer id, Model model){
    4437        model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id));
    4538        model.addAttribute("bodyContent","reviewsForUser");
Note: See TracChangeset for help on using the changeset viewer.