mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 07:45:49 +00:00
shows de noOffer y speedOffer completados y funcionales
This commit is contained in:
parent
bf08d78e1a
commit
5a55aa8084
8 changed files with 349 additions and 24 deletions
|
@ -38,7 +38,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||
.antMatchers(HttpMethod.GET, "/", "/oups").permitAll()
|
||||
.antMatchers("/users/new").permitAll()
|
||||
.antMatchers("/usuarios/new").permitAll()
|
||||
.antMatchers("/offers").permitAll()
|
||||
.antMatchers("/offers/**").permitAll()
|
||||
.antMatchers("/admin/**").hasAnyAuthority("admin")
|
||||
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
|
||||
.antMatchers("/vets/**").authenticated().anyRequest().denyAll()
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* 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 NuOfferController {
|
||||
|
||||
//private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";
|
||||
|
||||
private final FoodOfferService foodOfferService;
|
||||
private final NuOfferService nuOfferService;
|
||||
private final SpeedOfferService speedOfferService;
|
||||
private final TimeOfferService timeOfferService;
|
||||
|
||||
|
||||
|
||||
public NuOfferController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService,
|
||||
final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
|
||||
this.foodOfferService = foodOfferService;
|
||||
this.nuOfferService = nuOfferService;
|
||||
this.speedOfferService = speedOfferService;
|
||||
this.timeOfferService = timeOfferService;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/offers/nu/{nuOfferId}")
|
||||
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
|
||||
|
||||
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
|
||||
model.put("nuOffer", nuOffer);
|
||||
|
||||
return "nuOffers/nuOffersShow";
|
||||
|
||||
}
|
||||
|
||||
// @GetMapping("/owners/{ownerId}/edit")
|
||||
// public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||
// Owner owner = this.ownerService.findOwnerById(ownerId);
|
||||
// model.addAttribute(owner);
|
||||
// return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/owners/{ownerId}/edit")
|
||||
// public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result,
|
||||
// @PathVariable("ownerId") int ownerId) {
|
||||
// if (result.hasErrors()) {
|
||||
// return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||
// }
|
||||
// else {
|
||||
// owner.setId(ownerId);
|
||||
// this.ownerService.saveOwner(owner);
|
||||
// return "redirect:/owners/{ownerId}";
|
||||
// }
|
||||
// }
|
||||
// @GetMapping("/owners/{ownerId}")
|
||||
// public ModelAndView showOwner(@PathVariable("ownerId") int ownerId) {
|
||||
// ModelAndView mav = new ModelAndView("owners/ownerDetails");
|
||||
// Owner owner = this.ownerService.findOwnerById(ownerId);
|
||||
//
|
||||
// mav.addObject(owner);
|
||||
// return mav;
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* 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 SpeedOfferController {
|
||||
|
||||
//private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";
|
||||
|
||||
private final FoodOfferService foodOfferService;
|
||||
private final NuOfferService nuOfferService;
|
||||
private final SpeedOfferService speedOfferService;
|
||||
private final TimeOfferService timeOfferService;
|
||||
|
||||
|
||||
|
||||
public SpeedOfferController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService,
|
||||
final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
|
||||
this.foodOfferService = foodOfferService;
|
||||
this.nuOfferService = nuOfferService;
|
||||
this.speedOfferService = speedOfferService;
|
||||
this.timeOfferService = timeOfferService;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/offers/speed/{speedOfferId}")
|
||||
public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map<String, Object> model) {
|
||||
|
||||
SpeedOffer speedOffer=this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
|
||||
model.put("speedOffer", speedOffer);
|
||||
|
||||
return "speedOffers/speedOffersShow";
|
||||
|
||||
}
|
||||
|
||||
// @GetMapping("/owners/{ownerId}/edit")
|
||||
// public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||
// Owner owner = this.ownerService.findOwnerById(ownerId);
|
||||
// model.addAttribute(owner);
|
||||
// return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/owners/{ownerId}/edit")
|
||||
// public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result,
|
||||
// @PathVariable("ownerId") int ownerId) {
|
||||
// if (result.hasErrors()) {
|
||||
// return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||
// }
|
||||
// else {
|
||||
// owner.setId(ownerId);
|
||||
// this.ownerService.saveOwner(owner);
|
||||
// return "redirect:/owners/{ownerId}";
|
||||
// }
|
||||
// }
|
||||
// @GetMapping("/owners/{ownerId}")
|
||||
// public ModelAndView showOwner(@PathVariable("ownerId") int ownerId) {
|
||||
// ModelAndView mav = new ModelAndView("owners/ownerDetails");
|
||||
// Owner owner = this.ownerService.findOwnerById(ownerId);
|
||||
//
|
||||
// mav.addObject(owner);
|
||||
// return mav;
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -13,6 +13,8 @@ INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Wa
|
|||
INSERT INTO food_offers(start, end, code, type, client_id, food, discount, units) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, 'macarrones', '15%', 10);
|
||||
|
||||
INSERT INTO time_offers(start, end, code, type, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, '12:00:00', '13:00:00', '10%');
|
||||
INSERT INTO speed_offers(start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null,5,'25%',10,'15%',15,'10%' );
|
||||
INSERT INTO nu_offers(start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null,15,'25%',10,'15%',5,'10%' );
|
||||
|
||||
--insert into usuarios(username, password, enabled) values ('admin3', 'admin', true);
|
||||
--insert into authorities(id ,usuario, authority) values (42,'admin3', 'admin');
|
||||
|
|
56
src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersShow.jsp
Normal file
56
src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersShow.jsp
Normal file
|
@ -0,0 +1,56 @@
|
|||
<%@ 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" %>
|
||||
|
||||
<cheapy:layout pageName="timeOffer">
|
||||
|
||||
<h2>Oferta por número de comensales</h2>
|
||||
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Inicio de la oferta</th>
|
||||
<td><b><c:out value="${nuOffer.start}"/></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Fin de la oferta</th>
|
||||
<td><c:out value="${nuOffer.end}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Meta oro</th>
|
||||
<td><c:out value="${nuOffer.gold}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Descuento oro</th>
|
||||
<td><c:out value="${nuOffer.discountGold}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Meta plata</th>
|
||||
<td><c:out value="${nuOffer.silver}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Descuento plata</th>
|
||||
<td><c:out value="${nuOffer.discountSilver}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Meta bronce</th>
|
||||
<td><c:out value="${nuOffer.bronze}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Descuento bronce</th>
|
||||
<td><c:out value="${nuOffer.discountBronze}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Codigo de la oferta</th>
|
||||
<td><c:out value="${nuOffer.code}"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a> --%>
|
||||
|
||||
</cheapy:layout>
|
|
@ -50,30 +50,31 @@
|
|||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th style="width: 150px;">Fecha inicio</th>
|
||||
<th style="width: 200px;">Fecha fin</th>
|
||||
<th> </th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${nuOfferLs}" var="nuOffer">
|
||||
<tr>
|
||||
<%-- <td>
|
||||
<spring:url value="/offers/nu/{offerId}" var="nuOfferUrl">
|
||||
<spring:param name="offerId" value="${nuOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(nuOfferUrl)}"><c:out value="${nuOffer.client.username}"/></a>
|
||||
</td> --%>
|
||||
|
||||
<td>
|
||||
<c:out value="${nuOffer.start}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${nuOffer.end}"/>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<spring:url value="/offers/nu/{nuOfferId}" var="nuOfferUrl">
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(nuOfferUrl)}"/>Enlace</a>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<h2>Ofertas por plato específico</h2>
|
||||
<h2>Ofertas rapidez comiendo</h2>
|
||||
|
||||
<table id="speedOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
|
@ -81,30 +82,32 @@
|
|||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th style="width: 150px;">Fecha inicio</th>
|
||||
<th style="width: 200px;">Fecha fin</th>
|
||||
<th> </th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${speedOfferLs}" var="speedOffer">
|
||||
<tr>
|
||||
<%-- <td>
|
||||
<spring:url value="/offers/speed/{offerId}" var="speedOfferUrl">
|
||||
<spring:param name="offerId" value="${speedOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(speedOfferUrl)}"><c:out value="${speedOffer.client.username}"/></a>
|
||||
</td> --%>
|
||||
|
||||
<td>
|
||||
<c:out value="${speedOffer.start}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${speedOffer.end}"/>
|
||||
</td>
|
||||
<td>
|
||||
<spring:url value="/offers/speed/{speedOfferId}" var="speedOfferUrl">
|
||||
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(speedOfferUrl)}"/>Enlace</a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<h2>Ofertas por plato específico</h2>
|
||||
<h2>Ofertas por franja horaria</h2>
|
||||
|
||||
<table id="timeOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
|
@ -118,19 +121,19 @@
|
|||
<tbody>
|
||||
<c:forEach items="${timeOfferLs}" var="timeOffer">
|
||||
<tr>
|
||||
<%-- <td>
|
||||
<spring:url value="/offers/time/{offerId}" var="timeOfferUrl">
|
||||
<spring:param name="offerId" value="${timeOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(timeOfferUrl)}"><c:out value="${timeOffer.client.username}"/></a>
|
||||
</td> --%>
|
||||
|
||||
<td>
|
||||
<c:out value="${timeOffer.start}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${timeOffer.end}"/>
|
||||
</td>
|
||||
|
||||
<%-- <td>
|
||||
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
|
||||
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(timeOfferUrl)}"><c:out value="${timeOffer.client.username}"/></a>
|
||||
</td> --%>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
|
|
56
src/main/webapp/WEB-INF/jsp/speedOffers/speedOffersShow.jsp
Normal file
56
src/main/webapp/WEB-INF/jsp/speedOffers/speedOffersShow.jsp
Normal file
|
@ -0,0 +1,56 @@
|
|||
<%@ 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" %>
|
||||
|
||||
<cheapy:layout pageName="speedOffer">
|
||||
|
||||
<h2>Oferta por comer veloz</h2>
|
||||
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Inicio de la oferta</th>
|
||||
<td><b><c:out value="${speedOffer.start}"/></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Fin de la oferta</th>
|
||||
<td><c:out value="${speedOffer.end}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Meta oro</th>
|
||||
<td><c:out value="${speedOffer.gold}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Descuento oro</th>
|
||||
<td><c:out value="${speedOffer.discountGold}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Meta plata</th>
|
||||
<td><c:out value="${speedOffer.silver}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Descuento plata</th>
|
||||
<td><c:out value="${speedOffer.discountSilver}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Meta bronce</th>
|
||||
<td><c:out value="${speedOffer.bronze}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Descuento bronce</th>
|
||||
<td><c:out value="${speedOffer.discountBronze}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Codigo de la oferta</th>
|
||||
<td><c:out value="${speedOffer.code}"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a> --%>
|
||||
|
||||
</cheapy:layout>
|
Loading…
Reference in a new issue