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