Changes in Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java [4103eaa:5f53114]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
r4103eaa r5f53114 1 1 package finki.paw5.web.controllers; 2 3 import finki.paw5.model.entities.Employee;4 2 import finki.paw5.model.entities.Pet; 5 3 import finki.paw5.model.entities.Post; 6 import finki.paw5.model.entities. User;4 import finki.paw5.model.entities.Employee; 7 5 import finki.paw5.model.enumerations.AgeGroup; 8 6 import finki.paw5.model.enumerations.Gender; 9 7 import finki.paw5.model.enumerations.Size; 10 8 import finki.paw5.model.enumerations.Species; 9 import finki.paw5.service.PersonalProfileService; 11 10 import finki.paw5.service.PetService; 12 11 import finki.paw5.service.PostService; 12 import finki.paw5.service.ShelterService; 13 13 import jakarta.servlet.http.HttpServletRequest; 14 14 import org.springframework.stereotype.Controller; 15 15 import org.springframework.ui.Model; 16 16 import org.springframework.web.bind.annotation.GetMapping; 17 import org.springframework.web.bind.annotation.PathVariable; 17 18 import org.springframework.web.bind.annotation.PostMapping; 18 19 import org.springframework.web.bind.annotation.RequestParam; 19 20 20 21 import java.time.LocalDate; 22 import java.util.List; 21 23 22 24 @Controller … … 25 27 private final PostService postService; 26 28 private final PetService petService; 29 private final PersonalProfileService personalProfileService; 27 30 28 public PostController(PostService postService, PetService petService ) {31 public PostController(PostService postService, PetService petService, PersonalProfileService personalProfileService, ShelterService shelterService) { 29 32 this.postService = postService; 30 33 this.petService = petService; 34 this.personalProfileService = personalProfileService; 31 35 } 32 36 … … 71 75 return "redirect:/home"; 72 76 } 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 } 73 101 }
Note:
See TracChangeset
for help on using the changeset viewer.