diff --git a/src/main/java/org/springframework/cheapy/repository/ClientRepository.java b/src/main/java/org/springframework/cheapy/repository/ClientRepository.java index ac016a82c..a796b3e0a 100644 --- a/src/main/java/org/springframework/cheapy/repository/ClientRepository.java +++ b/src/main/java/org/springframework/cheapy/repository/ClientRepository.java @@ -1,23 +1,30 @@ package org.springframework.cheapy.repository; + +import java.util.Optional; import java.util.List; + 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 { +public interface ClientRepository extends CrudRepository { @Query("SELECT client FROM Client client WHERE username =:username") @Transactional(readOnly = true) Client findByUsername(String username); + + Optional findById(Integer id); + +// void save(Client client); + @Query("SELECT client FROM Client client") @Transactional(readOnly = true) List findAllClient(); - void save(Client client); - -} +} \ No newline at end of file diff --git a/src/main/java/org/springframework/cheapy/web/ClientController.java b/src/main/java/org/springframework/cheapy/web/ClientController.java index 3cc9138b3..fef9d999e 100644 --- a/src/main/java/org/springframework/cheapy/web/ClientController.java +++ b/src/main/java/org/springframework/cheapy/web/ClientController.java @@ -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"; + } } diff --git a/src/main/webapp/WEB-INF/jsp/clients/restaurantShow.jsp b/src/main/webapp/WEB-INF/jsp/clients/restaurantShow.jsp new file mode 100644 index 000000000..150a738bc --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/clients/restaurantShow.jsp @@ -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" %> + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + +
diff --git a/src/main/webapp/WEB-INF/jsp/offers/offersList.jsp b/src/main/webapp/WEB-INF/jsp/offers/offersList.jsp index 9be34211d..5373e4e7f 100644 --- a/src/main/webapp/WEB-INF/jsp/offers/offersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/offers/offersList.jsp @@ -11,111 +11,115 @@

-

No hay ninguna oferta por plato específico activa.

+

No hay ninguna oferta por plato específico activa.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- -
-
-
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+
+
+

-

No hay ninguna oferta por número de comensales activa.

+

No hay ninguna oferta por número de comensales activa.

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- -
-
-
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+
+
+

@@ -123,6 +127,7 @@

No hay ninguna oferta por tiempo empleado en comer activa.

+
@@ -141,7 +146,7 @@
- + @@ -171,6 +176,7 @@
+

@@ -178,6 +184,7 @@

No hay ninguna oferta por franja horaria activa.

+
@@ -195,7 +202,7 @@
- + @@ -224,7 +231,7 @@
-
+