Changeset a762b3a for Prototype Application/Paw5
- Timestamp:
- 02/14/23 20:45:37 (21 months ago)
- Branches:
- main
- Children:
- 59a8941
- Parents:
- 3f5e485
- Location:
- Prototype Application/Paw5/src/main
- Files:
-
- 6 added
- 3 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/PersonalProfile.java
r3f5e485 ra762b3a 32 32 private GroomingNeed groomingNeed; 33 33 34 public PersonalProfile( intid, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) {34 public PersonalProfile(Integer id, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) { 35 35 this.id = id; 36 36 this.friendlyToKids = friendlyToKids; -
Prototype Application/Paw5/src/main/java/finki/paw5/service/PetService.java
r3f5e485 ra762b3a 2 2 3 3 import finki.paw5.model.entities.Pet; 4 import finki.paw5.web.controllers.PostController; 5 6 import java.util.List; 7 import java.util.Optional; 4 8 5 9 public interface PetService { 6 10 7 11 void save (Pet pet); 12 13 List<Pet> findAll(); 14 15 Optional<Pet> findById(Integer petId); 8 16 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/PostService.java
r3f5e485 ra762b3a 2 2 3 3 import finki.paw5.model.entities.Post; 4 import finki.paw5.model.enumerations.AgeGroup; 5 import finki.paw5.model.enumerations.Gender; 6 import finki.paw5.model.enumerations.Size; 7 import finki.paw5.model.enumerations.Species; 4 5 import java.util.List; 6 import java.util.Optional; 8 7 9 8 public interface PostService { … … 11 10 void save (Post post); 12 11 12 List<Post> findAll(); 13 14 Optional<Post> findById(Integer id); 13 15 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PetServiceImplementation.java
r3f5e485 ra762b3a 5 5 import finki.paw5.service.PetService; 6 6 import org.springframework.stereotype.Service; 7 8 import java.util.List; 9 import java.util.Optional; 7 10 8 11 @Service … … 19 22 this.petRepository.save(pet); 20 23 } 24 25 @Override 26 public List<Pet> findAll() { 27 return this.petRepository.findAll(); 28 } 29 30 @Override 31 public Optional<Pet> findById(Integer petId) { 32 return this.petRepository.findById(petId); 33 } 21 34 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PostServiceImplementation.java
r3f5e485 ra762b3a 5 5 import finki.paw5.service.PostService; 6 6 import org.springframework.stereotype.Service; 7 8 import java.util.List; 9 import java.util.Optional; 7 10 8 11 @Service … … 20 23 } 21 24 25 @Override 26 public List<Post> findAll() { 27 return this.postRepository.findAll(); 28 } 29 30 @Override 31 public Optional<Post> findById(Integer id) { 32 return this.postRepository.findById(id); 33 } 22 34 } -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
r3f5e485 ra762b3a 1 1 package finki.paw5.web.controllers; 2 2 3 import finki.paw5.model.entities.PersonalProfile; 3 4 import finki.paw5.model.entities.Pet; 4 5 import finki.paw5.model.entities.Post; 6 import finki.paw5.model.entities.Shelter; 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; 11 import finki.paw5.service.PersonalProfileService; 9 12 import finki.paw5.service.PetService; 10 13 import finki.paw5.service.PostService; 14 import finki.paw5.service.ShelterService; 15 import jakarta.servlet.http.HttpServletRequest; 11 16 import org.springframework.stereotype.Controller; 12 17 import org.springframework.ui.Model; 13 18 import org.springframework.web.bind.annotation.GetMapping; 19 import org.springframework.web.bind.annotation.PathVariable; 14 20 import org.springframework.web.bind.annotation.PostMapping; 15 21 import org.springframework.web.bind.annotation.RequestParam; 16 22 17 23 import java.time.LocalDate; 24 import java.util.List; 18 25 19 26 @Controller … … 22 29 private final PostService postService; 23 30 private final PetService petService; 31 private final PersonalProfileService personalProfileService; 24 32 25 public PostController(PostService postService, PetService petService ) {33 public PostController(PostService postService, PetService petService, PersonalProfileService personalProfileService, ShelterService shelterService) { 26 34 this.postService = postService; 27 35 this.petService = petService; 36 this.personalProfileService = personalProfileService; 28 37 } 29 38 … … 54 63 return "redirect:/home"; 55 64 } 65 66 @GetMapping("/adoption-posts") 67 public String getAdoptionPosts(Model model, HttpServletRequest request){ 68 69 List<Post> posts = this.postService.findAll(); 70 List<Pet> pets = this.petService.findAll(); 71 //model.addAttribute("posts", posts); 72 //model.addAttribute("pets",pets); 73 request.getSession().setAttribute("posts",posts);//temp 74 request.getSession().setAttribute("pets",pets);//temp 75 76 return "list-posts-adoption"; 77 } 78 79 @GetMapping("/pet-details-{id}") 80 public String getPostDetails(@PathVariable Integer id, Model model, HttpServletRequest request){ 81 82 Post post = this.postService.findById(id).get(); 83 Pet pet = this.petService.findById(post.getPetId()).get(); 84 85 //model.addAttribute("pet", pet); 86 //model.addAttribute("post", post); 87 request.getSession().setAttribute("post", post);//temp 88 request.getSession().setAttribute("pet", pet);//temp 89 90 return "pet-details"; 91 } 56 92 }
Note:
See TracChangeset
for help on using the changeset viewer.