Ignore:
Timestamp:
03/05/23 18:01:28 (16 months ago)
Author:
GitHub <noreply@…>
Branches:
main
Children:
c3278ac, fdd7961
Parents:
f194b4e (diff), 5f53114 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Filip Chorbeski <86695898+FilipChorbeski@…> (03/05/23 18:01:28)
git-committer:
GitHub <noreply@…> (03/05/23 18:01:28)
Message:

Merge pull request #8 from SazdovaEkaterina/adopting-a-pet

Adopting a Pet

File:
1 edited

Legend:

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

    rf194b4e r8b7dd7f  
    11package finki.paw5.web.controllers;
    2 
    3 import finki.paw5.model.entities.Employee;
    42import finki.paw5.model.entities.Pet;
    53import finki.paw5.model.entities.Post;
    6 import finki.paw5.model.entities.User;
     4import finki.paw5.model.entities.Employee;
    75import finki.paw5.model.enumerations.AgeGroup;
    86import finki.paw5.model.enumerations.Gender;
    97import finki.paw5.model.enumerations.Size;
    108import finki.paw5.model.enumerations.Species;
     9import finki.paw5.service.PersonalProfileService;
    1110import finki.paw5.service.PetService;
    1211import finki.paw5.service.PostService;
     12import 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;
     17import org.springframework.web.bind.annotation.PathVariable;
    1718import org.springframework.web.bind.annotation.PostMapping;
    1819import org.springframework.web.bind.annotation.RequestParam;
    1920
    2021import java.time.LocalDate;
     22import java.util.List;
    2123
    2224@Controller
     
    2527    private final PostService postService;
    2628    private final PetService petService;
     29    private final PersonalProfileService personalProfileService;
    2730
    28     public PostController(PostService postService, PetService petService) {
     31    public PostController(PostService postService, PetService petService, PersonalProfileService personalProfileService, ShelterService shelterService) {
    2932        this.postService = postService;
    3033        this.petService = petService;
     34        this.personalProfileService = personalProfileService;
    3135    }
    3236
     
    7175        return "redirect:/home";
    7276    }
     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    }
    73101}
Note: See TracChangeset for help on using the changeset viewer.