From 88b304f72abb0f9b9a610a6f9740cb07dd1ccb45 Mon Sep 17 00:00:00 2001 From: Antonio Vidal Date: Thu, 25 Mar 2021 18:00:19 +0100 Subject: [PATCH] Los shows funcionan pero hay un error con las TimeOffer, parece que los jsp no reconocen el tipo LocalTime --- .../cheapy/web/FoodOfferController.java | 67 +++++++++++++++++++ .../cheapy/web/TimeOfferController.java | 54 +++++++++++++++ .../WEB-INF/jsp/foodOffers/foodOffersShow.jsp | 44 ++++++++++++ .../WEB-INF/jsp/nuOffers/nuOffersShow.jsp | 2 +- .../WEB-INF/jsp/timeOffers/timeOffersShow.jsp | 31 +++++++++ 5 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/springframework/cheapy/web/FoodOfferController.java create mode 100644 src/main/java/org/springframework/cheapy/web/TimeOfferController.java create mode 100644 src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersShow.jsp create mode 100644 src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersShow.jsp diff --git a/src/main/java/org/springframework/cheapy/web/FoodOfferController.java b/src/main/java/org/springframework/cheapy/web/FoodOfferController.java new file mode 100644 index 000000000..06afaed26 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/web/FoodOfferController.java @@ -0,0 +1,67 @@ +/* + * Copyright 2012-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.cheapy.web; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.springframework.cheapy.model.FoodOffer; +import org.springframework.cheapy.model.NuOffer; +import org.springframework.cheapy.model.SpeedOffer; +import org.springframework.cheapy.model.TimeOffer; +import org.springframework.cheapy.service.FoodOfferService; +import org.springframework.cheapy.service.NuOfferService; +import org.springframework.cheapy.service.SpeedOfferService; +import org.springframework.cheapy.service.TimeOfferService; +import org.springframework.stereotype.Controller; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + + +/** + * @author Juergen Hoeller + * @author Ken Krebs + * @author Arjen Poutsma + * @author Michael Isvy + */ +@Controller +public class FoodOfferController { + + //private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm"; + + private final FoodOfferService foodOfferService; + + + + public FoodOfferController(final FoodOfferService foodOfferService) { + this.foodOfferService = foodOfferService; + + } + + @GetMapping("/offers/food/{foodOfferId}") + public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map model) { + + FoodOffer foodOffer=this.foodOfferService.findFoodOfferById(foodOfferId); + + model.put("foodOffer", foodOffer); + + return "foodOffers/foodOffersShow"; + + } + +} diff --git a/src/main/java/org/springframework/cheapy/web/TimeOfferController.java b/src/main/java/org/springframework/cheapy/web/TimeOfferController.java new file mode 100644 index 000000000..703b2b846 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/web/TimeOfferController.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.cheapy.web; + +import java.util.Map; + +import org.springframework.cheapy.model.TimeOffer; +import org.springframework.cheapy.service.TimeOfferService; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + + +/** + * @author Juergen Hoeller + * @author Ken Krebs + * @author Arjen Poutsma + * @author Michael Isvy + */ +@Controller +public class TimeOfferController { + + //private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm"; + private final TimeOfferService timeOfferService; + + public TimeOfferController(final TimeOfferService timeOfferService) { + this.timeOfferService = timeOfferService; + + } + + @GetMapping("/offers/time/{timeOfferId}") + public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map model) { + + TimeOffer timeOffer=this.timeOfferService.findTimeOfferById(timeOfferId); + + model.put("timeOffer", timeOffer); + + return "timeOffers/timeOffersShow"; + + } +} diff --git a/src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersShow.jsp new file mode 100644 index 000000000..0b7c8785a --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersShow.jsp @@ -0,0 +1,44 @@ +<%@ page session="false" trimDirectiveWhitespaces="true" %> +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> + + + +

Oferta por plato específico

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Inicio de la oferta
Fin de la oferta
Plato en oferta
Descuento
Cantidad
Codigo de la oferta
+ + <%-- + + + Edit Owner --%> + +
diff --git a/src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersShow.jsp index 9c4eca9f3..431d2a4d6 100644 --- a/src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersShow.jsp +++ b/src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersShow.jsp @@ -4,7 +4,7 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> - +

Oferta por número de comensales

diff --git a/src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersShow.jsp new file mode 100644 index 000000000..a344a6221 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersShow.jsp @@ -0,0 +1,31 @@ +<%@ page session="false" trimDirectiveWhitespaces="true" %> +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> + + + +

Oferta por franja horária

+ + + + + + + + + + + + + + + + + + + +
Inicio de la oferta
Fin de la oferta
Descuento
Codigo de la oferta
+ +