Changeset 4103eaa for Prototype Application/Paw5/src/main/java/finki/paw5
- Timestamp:
- 03/04/23 19:29:36 (16 months ago)
- Branches:
- main
- Children:
- f194b4e
- Parents:
- 8f1a362
- Location:
- Prototype Application/Paw5/src/main/java/finki/paw5
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/service/PetService.java
r8f1a362 r4103eaa 10 10 11 11 List<Pet> listpets(); 12 13 Pet findById(Integer id); 12 14 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PetServiceImplementation.java
r8f1a362 r4103eaa 24 24 @Override 25 25 public List<Pet> listpets() {return this.petRepository.findAll();} 26 27 @Override 28 public Pet findById(Integer id) { 29 return this.petRepository.findById(id).get(); 30 } 26 31 } -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
r8f1a362 r4103eaa 38 38 39 39 @PostMapping("/submit-post") 40 public String savePost(@RequestParam(required = false) String name, 41 @RequestParam String gender, 42 @RequestParam String ageGroup, 43 @RequestParam String size, 44 @RequestParam String species, 40 public String savePost(@RequestParam(required = false) Integer petId, 41 @RequestParam(required = false) boolean newPetCheckbox, 42 @RequestParam(required = false) String name, 43 @RequestParam(required = false) String gender, 44 @RequestParam(required = false) String ageGroup, 45 @RequestParam(required = false) String size, 46 @RequestParam(required = false) String species, 45 47 @RequestParam(required = false) String breed, 46 48 @RequestParam(required = false) String imageUrl, … … 50 52 Employee employee = (Employee) request.getSession().getAttribute("user"); 51 53 52 Pet pet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, employee.getShelterId()); 53 this.petService.save(pet); 54 if(newPetCheckbox == true){ 54 55 55 Post post = new Post(LocalDate.now(), imageUrl, pet.getId(), null, employee.getId()); 56 this.postService.save(post); 56 Pet newPet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, employee.getShelterId()); 57 this.petService.save(newPet); 58 59 Post post = new Post(LocalDate.now(), imageUrl, newPet.getId(), null, employee.getId()); 60 this.postService.save(post); 61 62 } else{ 63 64 Pet selectedPet = this.petService.findById(petId); 65 66 Post post = new Post(LocalDate.now(), imageUrl, selectedPet.getId(), null, employee.getId()); 67 this.postService.save(post); 68 69 } 57 70 58 71 return "redirect:/home";
Note:
See TracChangeset
for help on using the changeset viewer.