Changes in / [8b7dd7f:f194b4e]
- Location:
- Prototype Application/Paw5/src/main
- Files:
-
- 7 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Adoption.java
r8b7dd7f rf194b4e 5 5 6 6 import java.time.LocalDate; 7 import java.util.Date; 7 8 8 9 @Data … … 26 27 27 28 @Column(name = "id_adopter", nullable = false) 28 private IntegeradopterId;29 private int adopterId; 29 30 30 public Adoption(LocalDate startDate, LocalDate endDateFoster, boolean approved, IntegeradopterId) {31 public Adoption(LocalDate startDate, LocalDate endDateFoster, boolean approved, int adopterId) { 31 32 this.startDate = startDate; 32 33 this.endDateFoster = endDateFoster; -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/PersonalProfile.java
r8b7dd7f rf194b4e 32 32 private GroomingNeed groomingNeed; 33 33 34 public PersonalProfile( Integerid, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) {34 public PersonalProfile(int 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/PostService.java
r8b7dd7f rf194b4e 2 2 3 3 import finki.paw5.model.entities.Post; 4 import java.util.List;5 import java.util.Optional;6 4 7 5 public interface PostService { … … 9 7 void save (Post post); 10 8 11 List<Post> findAll();12 13 Optional<Post> findById(Integer id);14 9 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/ShelterService.java
r8b7dd7f rf194b4e 4 4 5 5 import java.util.List; 6 import java.util.Optional;7 6 8 7 public interface ShelterService { 9 Optional<Shelter> findById(Integer id);10 8 List<Shelter> listShelters(); 11 9 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PetServiceImplementation.java
r8b7dd7f rf194b4e 22 22 } 23 23 24 @Override 24 25 public List<Pet> listpets() {return this.petRepository.findAll();} 25 26 -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PostServiceImplementation.java
r8b7dd7f rf194b4e 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;10 7 11 8 @Service … … 23 20 } 24 21 25 @Override26 public List<Post> findAll() {27 return this.postRepository.findAll();28 }29 30 @Override31 public Optional<Post> findById(Integer id) {32 return this.postRepository.findById(id);33 }34 22 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/ShelterServiceImplementation.java
r8b7dd7f rf194b4e 7 7 8 8 import java.util.List; 9 import java.util.Optional;10 9 11 10 @Service 12 11 public class ShelterServiceImplementation implements ShelterService { 13 14 12 private final ShelterRepository shelterRepository; 15 13 … … 18 16 } 19 17 20 @Override21 public Optional<Shelter> findById(Integer id) {22 return this.shelterRepository.findById(id);23 }24 18 25 19 @Override … … 27 21 return shelterRepository.findAll(); 28 22 } 29 30 31 23 } -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PetController.java
r8b7dd7f rf194b4e 1 1 package finki.paw5.web.controllers; 2 2 3 import finki.paw5.model.entities.Adoption;4 import finki.paw5.model.entities.Pet;5 import finki.paw5.model.entities.User;6 import finki.paw5.model.exceptions.InvalidPetIdException;7 import finki.paw5.service.AdoptionService;8 3 import finki.paw5.service.PetService; 9 import jakarta.servlet.http.HttpServletRequest;10 4 import org.springframework.stereotype.Controller; 11 import org.springframework.web.bind.annotation.PathVariable;12 import org.springframework.web.bind.annotation.PostMapping;13 14 import java.time.LocalDate;15 5 16 6 @Controller … … 18 8 19 9 private final PetService petService; 20 private final AdoptionService adoptionService;21 10 22 public PetController(PetService petService , AdoptionService adoptionService) {11 public PetController(PetService petService) { 23 12 this.petService = petService; 24 this.adoptionService = adoptionService;25 13 } 26 14 27 @PostMapping("/submit-adopton-{id}")28 public String saveAdoption(@PathVariable Integer id, HttpServletRequest request) {29 30 Pet pet = this.petService.findById(id);31 32 User user = (User) request.getSession().getAttribute("user");33 34 Adoption adoption = new Adoption(LocalDate.now(), null, false, user.getId());35 this.adoptionService.save(adoption);36 37 pet.setAdoptionId(adoption.getId());38 this.petService.save(pet);39 40 return "redirect:/home";41 }42 15 } -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
r8b7dd7f rf194b4e 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 } -
Prototype Application/Paw5/src/main/resources/templates/aboutUs.html
r8b7dd7f rf194b4e 40 40 <h5 class="text-center text-danger"> 41 41 You successfully logged in 42 <th:block th:text="${session.user ?.getId()}"></th:block>42 <th:block th:text="${session.user.getId()}"></th:block> 43 43 </h5> 44 44 </div> -
Prototype Application/Paw5/src/main/resources/templates/home.html
r8b7dd7f rf194b4e 36 36 </header> 37 37 <div> 38 <h1>Welcome to Paw 5</h1>39 <h3>Let's get started40 <th:block th:text="${session.user?.getName()}"></th:block>41 </h3>42 </div>43 <div>44 38 <form method="get" th:action="@{'/create-post'}"> 45 <button id="createPost" 46 type="submit" 47 class="btn">Create an Adoption Post</button> 39 <button id="submit" type="submit">Create an Adoption Post</button> 48 40 </form> 49 41 </div> 50 42 <div> 51 <form method="get" th:action="@{'/adoption-posts'}"> 52 <button id="submit" 53 type="submit" 54 class="btn">View Pet Posts</button> 55 </form> 43 <h1>Welcome to Paw 5</h1> 44 <h3>Let's get started 45 <th:block th:text="${session.user.getName()}"></th:block> 46 </h3> 56 47 </div> 48 57 49 </body> 58 50 </html>
Note:
See TracChangeset
for help on using the changeset viewer.