Changes in / [8b7dd7f:f194b4e]


Ignore:
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  
    55
    66import java.time.LocalDate;
     7import java.util.Date;
    78
    89@Data
     
    2627
    2728    @Column(name = "id_adopter", nullable = false)
    28     private Integer adopterId;
     29    private int adopterId;
    2930
    30     public Adoption(LocalDate startDate, LocalDate endDateFoster, boolean approved, Integer adopterId) {
     31    public Adoption(LocalDate startDate, LocalDate endDateFoster, boolean approved, int adopterId) {
    3132        this.startDate = startDate;
    3233        this.endDateFoster = endDateFoster;
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/PersonalProfile.java

    r8b7dd7f rf194b4e  
    3232    private GroomingNeed groomingNeed;
    3333
    34     public PersonalProfile(Integer id, 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) {
    3535        this.id = id;
    3636        this.friendlyToKids = friendlyToKids;
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/PostService.java

    r8b7dd7f rf194b4e  
    22
    33import finki.paw5.model.entities.Post;
    4 import java.util.List;
    5 import java.util.Optional;
    64
    75public interface PostService {
     
    97    void save (Post post);
    108
    11     List<Post> findAll();
    12 
    13     Optional<Post> findById(Integer id);
    149}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/ShelterService.java

    r8b7dd7f rf194b4e  
    44
    55import java.util.List;
    6 import java.util.Optional;
    76
    87public interface ShelterService {
    9     Optional<Shelter> findById(Integer id);
    108    List<Shelter> listShelters();
    119}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PetServiceImplementation.java

    r8b7dd7f rf194b4e  
    2222    }
    2323
     24    @Override
    2425    public List<Pet> listpets() {return this.petRepository.findAll();}
    2526
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PostServiceImplementation.java

    r8b7dd7f rf194b4e  
    55import finki.paw5.service.PostService;
    66import org.springframework.stereotype.Service;
    7 
    8 import java.util.List;
    9 import java.util.Optional;
    107
    118@Service
     
    2320    }
    2421
    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     }
    3422}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/ShelterServiceImplementation.java

    r8b7dd7f rf194b4e  
    77
    88import java.util.List;
    9 import java.util.Optional;
    109
    1110@Service
    1211public class ShelterServiceImplementation implements ShelterService {
    13 
    1412    private final ShelterRepository shelterRepository;
    1513
     
    1816    }
    1917
    20     @Override
    21     public Optional<Shelter> findById(Integer id) {
    22         return this.shelterRepository.findById(id);
    23     }
    2418
    2519    @Override
     
    2721        return shelterRepository.findAll();
    2822    }
    29 
    30 
    3123}
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PetController.java

    r8b7dd7f rf194b4e  
    11package finki.paw5.web.controllers;
    22
    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;
    83import finki.paw5.service.PetService;
    9 import jakarta.servlet.http.HttpServletRequest;
    104import 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;
    155
    166@Controller
     
    188
    199    private final PetService petService;
    20     private final AdoptionService adoptionService;
    2110
    22     public PetController(PetService petService, AdoptionService adoptionService) {
     11    public PetController(PetService petService) {
    2312        this.petService = petService;
    24         this.adoptionService = adoptionService;
    2513    }
    2614
    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     }
    4215}
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java

    r8b7dd7f rf194b4e  
    11package finki.paw5.web.controllers;
     2
     3import finki.paw5.model.entities.Employee;
    24import finki.paw5.model.entities.Pet;
    35import finki.paw5.model.entities.Post;
    4 import finki.paw5.model.entities.Employee;
     6import finki.paw5.model.entities.User;
    57import finki.paw5.model.enumerations.AgeGroup;
    68import finki.paw5.model.enumerations.Gender;
    79import finki.paw5.model.enumerations.Size;
    810import finki.paw5.model.enumerations.Species;
    9 import finki.paw5.service.PersonalProfileService;
    1011import finki.paw5.service.PetService;
    1112import finki.paw5.service.PostService;
    12 import 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;
    17 import org.springframework.web.bind.annotation.PathVariable;
    1817import org.springframework.web.bind.annotation.PostMapping;
    1918import org.springframework.web.bind.annotation.RequestParam;
    2019
    2120import java.time.LocalDate;
    22 import java.util.List;
    2321
    2422@Controller
     
    2725    private final PostService postService;
    2826    private final PetService petService;
    29     private final PersonalProfileService personalProfileService;
    3027
    31     public PostController(PostService postService, PetService petService, PersonalProfileService personalProfileService, ShelterService shelterService) {
     28    public PostController(PostService postService, PetService petService) {
    3229        this.postService = postService;
    3330        this.petService = petService;
    34         this.personalProfileService = personalProfileService;
    3531    }
    3632
     
    7571        return "redirect:/home";
    7672    }
    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     }
    10173}
  • Prototype Application/Paw5/src/main/resources/templates/aboutUs.html

    r8b7dd7f rf194b4e  
    4040    <h5 class="text-center text-danger">
    4141        You successfully logged in
    42         <th:block  th:text="${session.user?.getId()}"></th:block>
     42        <th:block  th:text="${session.user.getId()}"></th:block>
    4343    </h5>
    4444</div>
  • Prototype Application/Paw5/src/main/resources/templates/home.html

    r8b7dd7f rf194b4e  
    3636</header>
    3737<div>
    38   <h1>Welcome to Paw 5</h1>
    39   <h3>Let's get started
    40     <th:block  th:text="${session.user?.getName()}"></th:block>
    41   </h3>
    42 </div>
    43 <div>
    4438  <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>
    4840  </form>
    4941</div>
    5042<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>
    5647</div>
     48
    5749</body>
    5850</html>
Note: See TracChangeset for help on using the changeset viewer.