Changeset 7aa3382 for Prototype Application
- Timestamp:
- 03/10/23 22:17:37 (20 months ago)
- Branches:
- main
- Children:
- 4ab3aae
- Parents:
- 56a6233
- Location:
- Prototype Application/Paw5/src/main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/service/AdopterService.java
r56a6233 r7aa3382 7 7 public interface AdopterService { 8 8 List<Adopter> findAllThatNeedApproval(); 9 10 Adopter findById(Integer id); 11 12 void save(Adopter adopter); 9 13 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/AdopterServiceImplementation.java
r56a6233 r7aa3382 24 24 .collect(Collectors.toList()); 25 25 } 26 27 @Override 28 public Adopter findById(Integer id) { 29 return this.adopterRepository.findById(id).get(); 30 } 31 32 @Override 33 public void save(Adopter adopter) { 34 this.adopterRepository.save(adopter); 35 } 26 36 } -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/EmployeeController.java
r56a6233 r7aa3382 1 1 package finki.paw5.web.controllers; 2 2 3 import finki.paw5.model.entities.Adopter; 4 import finki.paw5.model.entities.Employee; 3 5 import finki.paw5.service.AdopterService; 6 import finki.paw5.service.EmployeeService; 7 import jakarta.servlet.http.HttpServletRequest; 4 8 import org.springframework.stereotype.Controller; 5 9 import org.springframework.ui.Model; 6 10 import org.springframework.web.bind.annotation.GetMapping; 11 import org.springframework.web.bind.annotation.PathVariable; 12 import org.springframework.web.bind.annotation.PostMapping; 7 13 import org.springframework.web.bind.annotation.RequestMapping; 8 14 … … 10 16 @RequestMapping("/") 11 17 public class EmployeeController { 18 12 19 private final AdopterService adopterService; 20 private final EmployeeService employeeService; 13 21 14 public EmployeeController(AdopterService adopterService ) {22 public EmployeeController(AdopterService adopterService, EmployeeService employeeService) { 15 23 this.adopterService = adopterService; 24 this.employeeService = employeeService; 16 25 } 17 26 18 19 27 @GetMapping("/approve-adopters") 20 public String get HomePage(Model model){28 public String getApprovalPage(Model model){ 21 29 model.addAttribute("needApproval", this.adopterService.findAllThatNeedApproval()); 22 30 return "/approve-adopters"; 23 31 } 32 33 @PostMapping("/submit-approval-{id}") 34 public String approveAdopter(@PathVariable Integer id, HttpServletRequest request){ 35 36 Employee employeeVerificator = (Employee) request.getSession().getAttribute("user"); 37 38 Adopter adopter = this.adopterService.findById(id); 39 40 adopter.setVerified(true); 41 adopter.setEmployeeVerificator(employeeVerificator); 42 43 this.adopterService.save(adopter); 44 45 return "redirect:/approve-adopters"; 46 } 24 47 } -
Prototype Application/Paw5/src/main/resources/templates/approve-adopters.html
r56a6233 r7aa3382 50 50 <div> 51 51 <h2>Adopters who are waiting for your approval</h2> 52 <ul> 53 <li 54 th:each="adopter : ${needApproval}" 55 th:text="${adopter.getName()}"> 56 <!--napravi tabela--> 57 </li> 58 </ul> 52 <table> 53 <tr> 54 <td>Name</td> 55 <td>Email Address</td> 56 <td>Telephone Number</td> 57 <td></td> 58 </tr> 59 <tr th:each="adopter : ${needApproval}"> 60 <td th:text="${adopter.getName()}"></td> 61 <td th:text="${adopter.getEmail()}"></td> 62 <td th:text="${adopter.getTelephone()}"></td> 63 <td> 64 <form method="POST" 65 th:action="@{'/submit-approval-{id}' (id=${adopter.getId()})}"> 66 <button id="submit" 67 type="submit" 68 class="btn">Approve</button> 69 </form> 70 </td> 71 </tr> 72 </table> 59 73 </div> 60 74 </body>
Note:
See TracChangeset
for help on using the changeset viewer.