mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Merge pull request #90 from cheapy-ispp/027-filtro-por-nombre#89
Filtro por nombre
This commit is contained in:
commit
092e0afa6e
11 changed files with 303 additions and 1 deletions
|
@ -34,4 +34,9 @@ public interface FoodOfferRepository extends PagingAndSortingRepository<FoodOffe
|
|||
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE foodOffer.client.id =:id AND foodOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<FoodOffer> findFoodOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE foodOffer.client.name LIKE :name AND foodOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<FoodOffer> findFoodOfferByClientName(String name);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -32,4 +31,8 @@ public interface NuOfferRepository extends PagingAndSortingRepository<NuOffer, I
|
|||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.id =:id AND nuOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findNuOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.name LIKE :name AND nuOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findNuOfferByClientName(String name);
|
||||
}
|
||||
|
|
|
@ -34,4 +34,8 @@ public interface SpeedOfferRepository extends PagingAndSortingRepository<SpeedOf
|
|||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.id =:id AND speedOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findSpeedOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.name LIKE :name AND speedOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findSpeedOfferByClientName(String name);
|
||||
}
|
||||
|
|
|
@ -33,4 +33,8 @@ public interface TimeOfferRepository extends PagingAndSortingRepository<FoodOffe
|
|||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.id =:id AND timeOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findTimeOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.name LIKE :name AND timeOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findTimeOfferByClientName(String name);
|
||||
}
|
||||
|
|
|
@ -45,4 +45,9 @@ public class FoodOfferService {
|
|||
public List<FoodOffer> findFoodOfferActOclByUserId(final int id) {
|
||||
return this.foodOfferRepository.findFoodOfferActOclByUserId(id);
|
||||
}
|
||||
|
||||
public List<FoodOffer> findFoodOfferByClientName(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.foodOfferRepository.findFoodOfferByClientName(nameEdit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,4 +54,9 @@ public class NuOfferService {
|
|||
public List<NuOffer> findNuOfferActOclByUserId(final int id) {
|
||||
return this.nuOfferRepository.findNuOfferActOclByUserId(id);
|
||||
}
|
||||
|
||||
public List<NuOffer> findNuOfferByClientName(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.nuOfferRepository.findNuOfferByClientName(nameEdit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,4 +49,9 @@ public class SpeedOfferService {
|
|||
public List<SpeedOffer> findSpeedOfferActOclByUserId(final int id) {
|
||||
return this.speedOfferRepository.findSpeedOfferActOclByUserId(id);
|
||||
}
|
||||
|
||||
public List<SpeedOffer> findSpeedOfferByClientName(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.speedOfferRepository.findSpeedOfferByClientName(nameEdit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,4 +45,9 @@ public class TimeOfferService {
|
|||
public List<TimeOffer> findTimeOfferActOclByUserId(final int id) {
|
||||
return this.timeOfferRepository.findTimeOfferActOclByUserId(id);
|
||||
}
|
||||
|
||||
public List<TimeOffer> findTimeOfferByClientName(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.timeOfferRepository.findTimeOfferByClientName(nameEdit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,25 @@ public class OfertaController {
|
|||
return "offers/offersList";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/offersByName")
|
||||
public String processFindFormByName(final Map<String, Object> model, String name) {
|
||||
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findFoodOfferByClientName(name);
|
||||
List<NuOffer> nuOfferLs = this.nuOfferService.findNuOfferByClientName(name);
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findSpeedOfferByClientName(name);
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findTimeOfferByClientName(name);
|
||||
model.put("foodOfferLs", foodOfferLs);
|
||||
model.put("nuOfferLs", nuOfferLs);
|
||||
model.put("speedOfferLs", speedOfferLs);
|
||||
model.put("timeOfferLs", timeOfferLs);
|
||||
|
||||
//Se añade formateador de fecha al modelo
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
return "offers/offersListSearch";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/myOffers")
|
||||
public String processMyOffersForm(final Map<String, Object> model) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<%@ 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" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
@ -36,6 +37,13 @@
|
|||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<form class="example" action="/offersByName">
|
||||
<input type="text" name="name">
|
||||
<button type="submit"><i class="fa fa-search"></i></button>
|
||||
</form>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
|
||||
|
||||
|
|
239
src/main/webapp/WEB-INF/jsp/offers/offersListSearch.jsp
Normal file
239
src/main/webapp/WEB-INF/jsp/offers/offersListSearch.jsp
Normal file
|
@ -0,0 +1,239 @@
|
|||
<%@ 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" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
|
||||
|
||||
<c:if test="${empty foodOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty foodOfferLs }">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="foodOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th><fmt:message key="name"/></th>
|
||||
<th><fmt:message key="food"/></th>
|
||||
<th><fmt:message key="discount"/></th>
|
||||
<th><fmt:message key="startDate"/></th>
|
||||
<th><fmt:message key="endDate"/></th>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${foodOfferLs}" var="foodOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/restaurant/${foodOffer.client.id}"><c:out value="${foodOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${foodOffer.food}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${foodOffer.discount}%"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(foodOffer.start)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(foodOffer.end)}"/>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<spring:url value="/offers/food/{foodOfferId}" var="foodOfferUrl">
|
||||
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||
</spring:url>
|
||||
<div class="btn-detalles">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="details"/></button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="nuOffers"/></h2>
|
||||
<c:if test="${empty nuOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por número de comensales activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty nuOfferLs }">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="nuOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th><fmt:message key="name"/></th>
|
||||
<th><fmt:message key="startDate"/></th>
|
||||
<th><fmt:message key="endDate"/></th>
|
||||
<th><fmt:message key="goldGoal"/></th>
|
||||
<th><fmt:message key="goldDiscount"/></th>
|
||||
<th> </th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${nuOfferLs}" var="nuOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/restaurant/${nuOffer.client.id}"><c:out value="${nuOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(nuOffer.start)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(nuOffer.end)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${nuOffer.gold} comensales"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${nuOffer.discountGold}%"/>
|
||||
</td>
|
||||
<td>
|
||||
<spring:url value="/offers/nu/{nuOfferId}" var="nuOfferUrl">
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
</spring:url>
|
||||
<div class="btn-detalles">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="details"/> </button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
|
||||
<c:if test="${empty speedOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por tiempo empleado en comer activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty speedOfferLs }">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="speedOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th><fmt:message key="name"/></th>
|
||||
<th><fmt:message key="startDate"/></th>
|
||||
<th><fmt:message key="endDate"/></th>
|
||||
<th><fmt:message key="goldGoal"/></th>
|
||||
<th><fmt:message key="goldDiscount"/></th>
|
||||
<th> </th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${speedOfferLs}" var="speedOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/restaurant/${speedOffer.client.id}"><c:out value="${speedOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(speedOffer.start)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(speedOffer.end)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${speedOffer.gold} minutos"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${speedOffer.discountGold}%"/>
|
||||
</td>
|
||||
<td>
|
||||
<spring:url value="/offers/speed/{speedOfferId}" var="speedOfferUrl">
|
||||
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||
</spring:url>
|
||||
<div class="btn-detalles">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="details"/> </button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
|
||||
<c:if test="${empty timeOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por franja horaria activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty timeOfferLs }">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="timeOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th><fmt:message key="name"/></th>
|
||||
<th><fmt:message key="startDate"/></th>
|
||||
<th><fmt:message key="endDate"/></th>
|
||||
<th><fmt:message key="init"/></th>
|
||||
<th><fmt:message key="finishOffer"/></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${timeOfferLs}" var="timeOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/restaurant/${timeOffer.client.id}"><c:out value="${timeOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(timeOffer.start)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(timeOffer.end)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${timeOffer.init}h"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${timeOffer.finish}h"/>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
|
||||
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||
</spring:url>
|
||||
<div class="btn-detalles">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="details"/> </button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
|
||||
</cheapy:layout>
|
Loading…
Reference in a new issue