Changes in / [3f5e485:a2060cb]
- Location:
- Prototype Application/Paw5/src/main
- Files:
-
- 10 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Pet.java
r3f5e485 ra2060cb 43 43 44 44 @Column(name = "id_adoption") 45 private IntegeradoptionId;45 private int adoptionId; 46 46 47 47 @Column(name = "id_shelter") 48 private IntegershelterId;48 private int shelterId; 49 49 50 public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, String name, Species species, Gender gender, boolean canBeFostered, Integer adoptionId, IntegershelterId) {50 public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, String name, Species species, Gender gender, boolean canBeFostered, int adoptionId, int shelterId) { 51 51 this.imageUrl = imageUrl; 52 52 this.ageGroup = ageGroup; -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Post.java
r3f5e485 ra2060cb 5 5 6 6 import java.time.LocalDate; 7 import java.util.Date; 7 8 8 9 @Data … … 23 24 24 25 @Column(name="id_pet", nullable = false) 25 private IntegerpetId;26 private int petId; 26 27 27 28 @Column(name="id_surendee") 28 private IntegersurendeeId;29 private int surendeeId; 29 30 30 31 @Column(name="id_employee") 31 private IntegeremployeeId;32 private int employeeId; 32 33 33 public Post(LocalDate dateCreated, String thumbnailUrl, Integer petId, Integer surendeeId, IntegeremployeeId) {34 public Post(LocalDate dateCreated, String thumbnailUrl, int petId, int surendeeId, int employeeId) { 34 35 this.dateCreated = dateCreated; 35 36 this.thumbnailUrl = thumbnailUrl; -
Prototype Application/Paw5/src/main/java/finki/paw5/repository/UserRepository.java
r3f5e485 ra2060cb 5 5 import org.springframework.stereotype.Repository; 6 6 7 8 7 @Repository 9 8 public interface UserRepository extends JpaRepository<User, Integer> { 10 User findByEmailAndPassword(String email, String password);11 User findByEmail(String email);12 9 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/PetService.java
r3f5e485 ra2060cb 1 1 package finki.paw5.service; 2 2 3 import finki.paw5.model.entities.Pet;4 5 3 public interface PetService { 6 7 void save (Pet pet);8 4 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/PostService.java
r3f5e485 ra2060cb 1 1 package finki.paw5.service; 2 2 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 9 3 public interface PostService { 10 11 void save (Post post);12 13 4 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PetServiceImplementation.java
r3f5e485 ra2060cb 1 1 package finki.paw5.service.implementation; 2 2 3 import finki.paw5.model.entities.Pet;4 3 import finki.paw5.repository.PetRepository; 5 4 import finki.paw5.service.PetService; … … 15 14 } 16 15 17 @Override18 public void save(Pet pet) {19 this.petRepository.save(pet);20 }21 16 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PostServiceImplementation.java
r3f5e485 ra2060cb 1 1 package finki.paw5.service.implementation; 2 2 3 import finki.paw5.model.entities.Post;4 3 import finki.paw5.repository.PostRepository; 5 4 import finki.paw5.service.PostService; … … 15 14 } 16 15 17 @Override18 public void save(Post post) {19 this.postRepository.save(post);20 }21 22 16 } -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
r3f5e485 ra2060cb 1 1 package finki.paw5.web.controllers; 2 2 3 import finki.paw5.model.entities.Pet;4 import finki.paw5.model.entities.Post;5 import finki.paw5.model.enumerations.AgeGroup;6 import finki.paw5.model.enumerations.Gender;7 import finki.paw5.model.enumerations.Size;8 import finki.paw5.model.enumerations.Species;9 import finki.paw5.service.PetService;10 3 import finki.paw5.service.PostService; 11 4 import org.springframework.stereotype.Controller; 12 import org.springframework.ui.Model;13 import org.springframework.web.bind.annotation.GetMapping;14 import org.springframework.web.bind.annotation.PostMapping;15 import org.springframework.web.bind.annotation.RequestParam;16 17 import java.time.LocalDate;18 5 19 6 @Controller … … 21 8 22 9 private final PostService postService; 23 private final PetService petService;24 10 25 public PostController(PostService postService , PetService petService) {11 public PostController(PostService postService) { 26 12 this.postService = postService; 27 this.petService = petService;28 13 } 29 14 30 @GetMapping("create-post")31 public String get(Model model) {32 //TODO: vakvo ama za lista so pets33 // List<Manufacturer> manufacturers = this.manufacturerService.findAll();34 // model.addAttribute("manufacturers", manufacturers);35 return "create-post";36 }37 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(required = false) 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);//TODO: employee id da se zeme preku session user getid52 this.postService.save(post);53 54 return "redirect:/home";55 }56 15 }
Note:
See TracChangeset
for help on using the changeset viewer.