Changeset 7e3f2f7 for Prototype Application/Paw5/src
- Timestamp:
- 02/16/23 16:09:52 (21 months ago)
- Branches:
- main
- Children:
- d7eaf88
- Parents:
- 6941fac
- Location:
- Prototype Application/Paw5/src/main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/service/PetService.java
r6941fac r7e3f2f7 3 3 import finki.paw5.model.entities.Pet; 4 4 5 import java.util.List; 6 5 7 public interface PetService { 6 8 7 9 void save (Pet pet); 10 11 List<Pet> listpets(); 8 12 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/PostService.java
r6941fac r7e3f2f7 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 9 5 public interface PostService { -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PetServiceImplementation.java
r6941fac r7e3f2f7 5 5 import finki.paw5.service.PetService; 6 6 import org.springframework.stereotype.Service; 7 8 import java.util.List; 7 9 8 10 @Service … … 19 21 this.petRepository.save(pet); 20 22 } 23 24 @Override 25 public List<Pet> listpets() {return this.petRepository.findAll();} 21 26 } -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
r6941fac r7e3f2f7 1 1 package finki.paw5.web.controllers; 2 2 3 import finki.paw5.model.entities.Employee; 3 4 import finki.paw5.model.entities.Pet; 4 5 import finki.paw5.model.entities.Post; 6 import finki.paw5.model.entities.User; 5 7 import finki.paw5.model.enumerations.AgeGroup; 6 8 import finki.paw5.model.enumerations.Gender; … … 9 11 import finki.paw5.service.PetService; 10 12 import finki.paw5.service.PostService; 13 import jakarta.servlet.http.HttpServletRequest; 11 14 import org.springframework.stereotype.Controller; 12 15 import org.springframework.ui.Model; … … 30 33 @GetMapping("/create-post") 31 34 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 model.addAttribute("pets", this.petService.listpets()); 35 36 return "create-post"; 36 37 } … … 44 45 @RequestParam(required = false) String breed, 45 46 @RequestParam(required = false) String imageUrl, 46 @RequestParam(required = false) boolean canBeFostered) { 47 @RequestParam(required = false) boolean canBeFostered, 48 HttpServletRequest request) { 47 49 48 Pet pet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, 1); 50 Employee employee = (Employee) request.getSession().getAttribute("employee"); 51 52 Pet pet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, employee.getShelterId()); 49 53 this.petService.save(pet); 50 54 51 Post post = new Post(LocalDate.now(), imageUrl, pet.getId() , null, 10);//TODO: employee id da se zeme preku session user getid55 Post post = new Post(LocalDate.now(), imageUrl, pet.getId() , null, employee.getId() ); 52 56 this.postService.save(post); 53 57 -
Prototype Application/Paw5/src/main/resources/templates/create-post.html
r6941fac r7e3f2f7 44 44 <label for="pet">Selet pet:</label> 45 45 <select id="pet"> 46 <option 47 th:each="pet :${pets}" 48 th:text="${pet.getName()}"> 49 </option> 46 50 </select> 47 51 </div>
Note:
See TracChangeset
for help on using the changeset viewer.