Skip to content

Commit

Permalink
Merge pull request #387 from josdem/feature/376
Browse files Browse the repository at this point in the history
[small]Feature/376
  • Loading branch information
josdem authored Oct 11, 2024
2 parents 19e5ce4 + ce3035c commit 456b383
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/com/josdem/vetlog/controller/VetController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.josdem.vetlog.command.UsernameCommand;
import com.josdem.vetlog.service.PetService;
import com.josdem.vetlog.service.UserService;
import com.josdem.vetlog.service.VaccinationService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -37,6 +38,7 @@ public class VetController {

private final UserService userService;
private final PetService petService;
private final VaccinationService vaccinationService;

@Value("${gcpUrl}")
private String gcpUrl;
Expand All @@ -61,6 +63,7 @@ ModelAndView search(@Valid UsernameCommand command) {
var modelAndView = new ModelAndView("vet/list");
var user = userService.getByUsername(command.getUsername());
var pets = petService.getPetsByUser(user);
pets.forEach(pet -> pet.setVaccines(vaccinationService.getVaccinationsByPet(pet)));
modelAndView.addObject("pets", pets);
modelAndView.addObject("gcpImageUrl", gcpUrl + imageBucket + "/");
modelAndView.addObject("defaultImage", defaultImage);
Expand Down
16 changes: 15 additions & 1 deletion src/main/resources/templates/vet/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,22 @@ <h3 th:text="${pet.name}"></h3>
<li th:text="${pet.dewormed}? #{pet.dewormed} : #{pet.not.dewormed}"/>
<li th:text="${pet.sterilized}? #{pet.sterilized} : #{pet.not.sterilized}"/>
<li th:text="${pet.vaccinated}? #{pet.vaccinated} : #{pet.not.vaccinated}"/>
<br/>
<table th:if="${!pet.vaccines.isEmpty()}">
<thead>
<tr>
<th th:text="#{pet.table.header.vaccines}"></th>
<th th:text="#{pet.table.header.status}"></th>
</tr>
</thead>
<tbody>
<tr th:each="vaccination : ${pet.vaccines}">
<td th:text="${vaccination.name}"></td>
<td th:text="${vaccination.status}"></td>
</tr>
</tbody>
</table>
</ul>
</p>
<br/>
<center>
<a th:href="@{/petlog/list(uuid=${pet.uuid})}" class="btn btn-success">
Expand Down

0 comments on commit 456b383

Please sign in to comment.