Ignore:
Timestamp:
01/03/23 19:29:20 (23 months ago)
Author:
andrejtodorovski <82031894+andrejtodorovski@…>
Branches:
main
Children:
60de3eb
Parents:
eaf0f1b
Message:

Added some views and functionalities

Location:
src/main/java/com/example/autopartz/controller
Files:
2 added
1 edited

Legend:

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

    reaf0f1b rfeffc2f  
    22
    33import com.example.autopartz.model.*;
     4import com.example.autopartz.model.views.*;
    45import com.example.autopartz.repository.*;
    56import com.example.autopartz.service.UserService;
     7import org.springframework.stereotype.Controller;
     8import org.springframework.ui.Model;
    69import org.springframework.web.bind.annotation.*;
    710
    811import java.util.List;
    912
    10 @RestController
     13@Controller
    1114@RequestMapping("/")
    1215public class UserController {
     
    3942    }
    4043    @GetMapping("orders/{id}")
    41     public List<OrdersForUser> getOrdersForUser(@PathVariable Long id){
    42         return ordersForUserRepository.findAllByUserid(id);
     44    public String getOrdersForUser(@PathVariable Long id, Model model){
     45        model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id));
     46        return "ordersForUser";
    4347    }
    4448    @GetMapping("repairs/{id}")
    45     public List<RepairsForUser> getRepairsForUser(@PathVariable Long id){
    46         return repairsForUserRepository.findAllByUserid(id);
     49    public String getRepairsForUser(@PathVariable Long id,Model model){
     50        model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id));
     51        return "repairsForUser";
    4752    }
    4853    @GetMapping("reviews/{id}")
    49     public List<ReviewsForUser> getReviewsForUser(@PathVariable Long id){
    50         return reviewsForUserRepository.findAllByUserid(id);
     54    public String getReviewsForUser(@PathVariable Long id, Model model){
     55        model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id));
     56        return "reviewsForUser";
    5157    }
    5258}
Note: See TracChangeset for help on using the changeset viewer.