Changeset 468b7b6
- Timestamp:
- 02/12/23 22:54:47 (21 months ago)
- Branches:
- main
- Children:
- 325a55d
- Parents:
- 988f3fa
- Location:
- Prototype Application/Paw5/src/main
- Files:
-
- 1 added
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Pet.java
r988f3fa r468b7b6 43 43 44 44 @Column(name = "id_adoption") 45 private intadoptionId;45 private Integer adoptionId; 46 46 47 47 @Column(name = "id_shelter") 48 private intshelterId;48 private Integer shelterId; 49 49 50 public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, String name, Species species, Gender gender, boolean canBeFostered, int adoptionId, intshelterId) {50 public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, String name, Species species, Gender gender, boolean canBeFostered, Integer adoptionId, Integer shelterId) { 51 51 this.imageUrl = imageUrl; 52 52 this.ageGroup = ageGroup; -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Post.java
r988f3fa r468b7b6 5 5 6 6 import java.time.LocalDate; 7 import java.util.Date;8 7 9 8 @Data … … 24 23 25 24 @Column(name="id_pet", nullable = false) 26 private intpetId;25 private Integer petId; 27 26 28 27 @Column(name="id_surendee") 29 private intsurendeeId;28 private Integer surendeeId; 30 29 31 30 @Column(name="id_employee") 32 private intemployeeId;31 private Integer employeeId; 33 32 34 public Post(LocalDate dateCreated, String thumbnailUrl, int petId, int surendeeId, intemployeeId) {33 public Post(LocalDate dateCreated, String thumbnailUrl, Integer petId, Integer surendeeId, Integer employeeId) { 35 34 this.dateCreated = dateCreated; 36 35 this.thumbnailUrl = thumbnailUrl; -
Prototype Application/Paw5/src/main/java/finki/paw5/service/PetService.java
r988f3fa r468b7b6 1 1 package finki.paw5.service; 2 2 3 import finki.paw5.model.entities.Pet; 4 3 5 public interface PetService { 6 7 void save (Pet pet); 4 8 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/PostService.java
r988f3fa r468b7b6 9 9 public interface PostService { 10 10 11 Post submit (String pet_name, Gender gender, AgeGroup ageGroup, Size size, Species species, String breed, String urlimage);11 void save (Post post); 12 12 13 13 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PetServiceImplementation.java
r988f3fa r468b7b6 1 1 package finki.paw5.service.implementation; 2 2 3 import finki.paw5.model.entities.Pet; 3 4 import finki.paw5.repository.PetRepository; 4 5 import finki.paw5.service.PetService; … … 14 15 } 15 16 17 @Override 18 public void save(Pet pet) { 19 this.petRepository.save(pet); 20 } 16 21 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PostServiceImplementation.java
r988f3fa r468b7b6 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;8 4 import finki.paw5.repository.PostRepository; 9 5 import finki.paw5.service.PostService; … … 20 16 21 17 @Override 22 public Post submit(String name, Gender gender, AgeGroup ageGroup, Size size, Species species, String breed, String urlimage) { 23 //Post post = new Post(name, gender, ageGroup, size, species, breed, urlimage); 24 return null; 18 public void save(Post post) { 19 this.postRepository.save(post); 25 20 } 26 21 -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
r988f3fa r468b7b6 1 1 package finki.paw5.web.controllers; 2 2 3 import finki.paw5.model.entities.Pet; 4 import finki.paw5.model.entities.Post; 3 5 import finki.paw5.model.enumerations.AgeGroup; 4 6 import finki.paw5.model.enumerations.Gender; 5 7 import finki.paw5.model.enumerations.Size; 6 8 import finki.paw5.model.enumerations.Species; 9 import finki.paw5.service.PetService; 7 10 import finki.paw5.service.PostService; 8 11 import org.springframework.stereotype.Controller; 12 import org.springframework.ui.Model; 13 import org.springframework.web.bind.annotation.GetMapping; 9 14 import org.springframework.web.bind.annotation.PostMapping; 10 import org.springframework.web.bind.annotation.RequestMapping;11 15 import org.springframework.web.bind.annotation.RequestParam; 12 16 17 import java.time.LocalDate; 18 13 19 @Controller 14 @RequestMapping("/CreatePost")15 20 public class PostController { 16 21 17 22 private final PostService postService; 23 private final PetService petService; 18 24 19 public PostController(PostService postService ) {25 public PostController(PostService postService, PetService petService) { 20 26 this.postService = postService; 27 this.petService = petService; 21 28 } 22 29 23 @PostMapping 24 public String submit(@RequestParam String name, 25 @RequestParam Gender gender, 26 @RequestParam AgeGroup ageGroup, 27 @RequestParam Size size, 28 @RequestParam Species species, 29 @RequestParam String breed, 30 @RequestParam String urlimage) { 30 @GetMapping("create-post") 31 public String get(Model model) { 32 //TODO: vakvo ama za lista so pets 33 // List<Manufacturer> manufacturers = this.manufacturerService.findAll(); 34 // model.addAttribute("manufacturers", manufacturers); 35 return "create-post"; 36 } 31 37 32 this.postService.submit(name, gender, ageGroup, size, species, breed, urlimage); 38 @PostMapping("submit-post") 39 public String savePost(@RequestParam(required = false) String name, 40 @RequestParam String gender, 41 @RequestParam String ageGroup, 42 @RequestParam String size, 43 @RequestParam String species, 44 @RequestParam(required = false) String breed, 45 @RequestParam(required = false) String imageUrl, 46 @RequestParam boolean canBeFostered) { 47 48 Pet pet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, 1); 49 this.petService.save(pet); 50 51 Post post = new Post(LocalDate.now(), imageUrl, pet.getId(), null, 10); 52 this.postService.save(post); 33 53 34 54 return null;
Note:
See TracChangeset
for help on using the changeset viewer.