mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Vista de restaurante
Se ha añadido todo lo necesario para que cualquiera pueda ver información general de los restaurantes/bares
This commit is contained in:
parent
fc39e9aa2f
commit
765190b811
4 changed files with 85 additions and 7 deletions
|
@ -1,16 +1,21 @@
|
|||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface ClientRepository extends Repository<Client, String> {
|
||||
public interface ClientRepository extends CrudRepository<Client, String> {
|
||||
|
||||
@Query("SELECT client FROM Client client WHERE username =:username")
|
||||
@Transactional(readOnly = true)
|
||||
Client findByUsername(String username);
|
||||
|
||||
Optional<Client> findById(Integer id);
|
||||
|
||||
void save(Client client);
|
||||
// void save(Client client);
|
||||
|
||||
}
|
||||
}
|
|
@ -7,14 +7,17 @@ import java.util.Map;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import javax.websocket.server.PathParam;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.repository.ClientRepository;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.FoodOfferService;
|
||||
import org.springframework.cheapy.service.NuOfferService;
|
||||
|
@ -24,6 +27,7 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@Controller
|
||||
|
@ -41,6 +45,9 @@ public class ClientController {
|
|||
|
||||
private final TimeOfferService timeOfferService;
|
||||
|
||||
@Autowired
|
||||
private ClientRepository clientRepo;
|
||||
|
||||
|
||||
public ClientController(final ClientService clientService, FoodOfferService foodOfferService,
|
||||
SpeedOfferService speedOfferService, NuOfferService nuOfferService, TimeOfferService timeOfferService) {
|
||||
|
@ -141,4 +148,12 @@ public class ClientController {
|
|||
return "redirect:/login";
|
||||
|
||||
}
|
||||
@GetMapping(value = "/restaurant/{clientId}")
|
||||
public String showRestaurant(final ModelMap model, @PathVariable("clientId") Integer id) {
|
||||
|
||||
Client client = this.clientRepo.findById(id).get();
|
||||
System.out.println(client.getDescription());
|
||||
model.put("client", client);
|
||||
return "clients/restaurantShow";
|
||||
}
|
||||
}
|
||||
|
|
58
src/main/webapp/WEB-INF/jsp/clients/restaurantShow.jsp
Normal file
58
src/main/webapp/WEB-INF/jsp/clients/restaurantShow.jsp
Normal file
|
@ -0,0 +1,58 @@
|
|||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="client">
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="client"/></h2>
|
||||
|
||||
|
||||
|
||||
<table class="table table-striped" id="clientTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><fmt:message key="clientInit"/></th>
|
||||
<td><c:out value="${client.init}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="clientFinish"/></th>
|
||||
<td><c:out value="${client.finish}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="nameClient"/></th>
|
||||
<td><c:out value="${client.name}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="emailClient"/></th>
|
||||
<td><c:out value="${client.email}%"/> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><fmt:message key="addressClient"/></th>
|
||||
<td><c:out value="${client.address}%"/> </td>
|
||||
</tr><tr>
|
||||
<th><fmt:message key="telephoneClient"/></th>
|
||||
<td><c:out value="${client.telephone}%"/> </td>
|
||||
</tr><tr>
|
||||
<th><fmt:message key="descriptionClient"/></th>
|
||||
<td><c:out value="${client.description}%"/> </td>
|
||||
</tr><tr>
|
||||
<th><fmt:message key="foodClient"/></th>
|
||||
<td><c:out value="${client.food}%"/> </td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
<div class="btn-menu">
|
||||
</div>
|
||||
|
||||
|
||||
</cheapy:layout>
|
|
@ -31,7 +31,7 @@
|
|||
<c:forEach items="${foodOfferLs}" var="foodOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<c:out value="${foodOffer.client.name}"/>
|
||||
<a href="/restaurant/${foodOffer.client.id}"><c:out value="${foodOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${foodOffer.food}"/>
|
||||
|
@ -84,7 +84,7 @@
|
|||
<c:forEach items="${nuOfferLs}" var="nuOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<c:out value="${nuOffer.client.name}"/>
|
||||
<a href="/restaurant/${nuOffer.client.id}"><c:out value="${nuOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(nuOffer.start)}"/>
|
||||
|
@ -136,7 +136,7 @@
|
|||
<c:forEach items="${speedOfferLs}" var="speedOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<c:out value="${speedOffer.client.name}"/>
|
||||
<a href="/restaurant/${speedOffer.client.id}"><c:out value="${speedOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(speedOffer.start)}"/>
|
||||
|
@ -188,7 +188,7 @@
|
|||
<c:forEach items="${timeOfferLs}" var="timeOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<c:out value="${timeOffer.client.name}"/>
|
||||
<a href="/restaurant/${timeOffer.client.id}"><c:out value="${timeOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(timeOffer.start)}"/>
|
||||
|
|
Loading…
Reference in a new issue