Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java

    r5f53114 r4103eaa  
    11package finki.paw5.web.controllers;
     2
     3import finki.paw5.model.entities.Employee;
    24import finki.paw5.model.entities.Pet;
    35import finki.paw5.model.entities.Post;
    4 import finki.paw5.model.entities.Employee;
     6import finki.paw5.model.entities.User;
    57import finki.paw5.model.enumerations.AgeGroup;
    68import finki.paw5.model.enumerations.Gender;
    79import finki.paw5.model.enumerations.Size;
    810import finki.paw5.model.enumerations.Species;
    9 import finki.paw5.service.PersonalProfileService;
    1011import finki.paw5.service.PetService;
    1112import finki.paw5.service.PostService;
    12 import finki.paw5.service.ShelterService;
    1313import jakarta.servlet.http.HttpServletRequest;
    1414import org.springframework.stereotype.Controller;
    1515import org.springframework.ui.Model;
    1616import org.springframework.web.bind.annotation.GetMapping;
    17 import org.springframework.web.bind.annotation.PathVariable;
    1817import org.springframework.web.bind.annotation.PostMapping;
    1918import org.springframework.web.bind.annotation.RequestParam;
    2019
    2120import java.time.LocalDate;
    22 import java.util.List;
    2321
    2422@Controller
     
    2725    private final PostService postService;
    2826    private final PetService petService;
    29     private final PersonalProfileService personalProfileService;
    3027
    31     public PostController(PostService postService, PetService petService, PersonalProfileService personalProfileService, ShelterService shelterService) {
     28    public PostController(PostService postService, PetService petService) {
    3229        this.postService = postService;
    3330        this.petService = petService;
    34         this.personalProfileService = personalProfileService;
    3531    }
    3632
     
    7571        return "redirect:/home";
    7672    }
    77 
    78     @GetMapping("/adoption-posts")
    79     public String getAdoptionPosts(Model model){
    80 
    81         List<Post> posts = this.postService.findAll();
    82         List<Pet> pets = this.petService.listpets();
    83         model.addAttribute("posts", posts);
    84         model.addAttribute("pets",pets);
    85 
    86         return "list-posts-adoption";
    87     }
    88 
    89     @GetMapping("/pet-details-{id}")
    90     public String getPostDetails(@PathVariable Integer id,
    91                                  Model model){
    92 
    93         Post post = this.postService.findById(id).get();
    94         Pet pet = this.petService.findById(post.getPetId());
    95 
    96         model.addAttribute("pet", pet);
    97         model.addAttribute("post", post);
    98 
    99         return "pet-details";
    100     }
    10173}
Note: See TracChangeset for help on using the changeset viewer.