- Timestamp:
- 02/13/23 14:34:36 (17 months ago)
- Branches:
- main
- Children:
- a762b3a
- Parents:
- a2060cb (diff), 04e4f54 (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. - Location:
- Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
ra2060cb r3f5e485 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; 3 10 import finki.paw5.service.PostService; 4 11 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; 5 18 6 19 @Controller … … 8 21 9 22 private final PostService postService; 23 private final PetService petService; 10 24 11 public PostController(PostService postService ) {25 public PostController(PostService postService, PetService petService) { 12 26 this.postService = postService; 27 this.petService = petService; 13 28 } 14 29 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 } 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 getid 52 this.postService.save(post); 53 54 return "redirect:/home"; 55 } 15 56 }
Note:
See TracChangeset
for help on using the changeset viewer.