Solucionado buscar sin municipio

This commit is contained in:
gabgutpri@alum.us.es 2021-04-16 12:20:47 +02:00
parent 3c6d98b14e
commit b4bcec89d5

View file

@ -2,7 +2,6 @@
package org.springframework.cheapy.web; package org.springframework.cheapy.web;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -114,6 +113,17 @@ public class OfertaController {
@GetMapping("/offersByPlace") @GetMapping("/offersByPlace")
public String processFindFormByPlace(final Map<String, Object> model, final HttpServletRequest request) { public String processFindFormByPlace(final Map<String, Object> model, final HttpServletRequest request) {
if (request.getParameter("municipio").equals("") || request.getParameter("municipio").equals(null)) {
// Añade la lista de municipios al desplegable
model.put("municipios", Municipio.values());
//Se añade formateador de fecha al modelo
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "redirect:/offers/";
}
Municipio mun = Municipio.valueOf(request.getParameter("municipio")); Municipio mun = Municipio.valueOf(request.getParameter("municipio"));
List<FoodOffer> foodOfferLs = this.foodOfferService.findFoodOfferByClientPlace(mun); List<FoodOffer> foodOfferLs = this.foodOfferService.findFoodOfferByClientPlace(mun);
@ -161,30 +171,30 @@ public class OfertaController {
return "offers/offersCreate"; return "offers/offersCreate";
} }
@GetMapping("/offersRecord") @GetMapping("/offersRecord")
public String processOffersRecordForm(final Map<String, Object> model) { public String processOffersRecordForm(final Map<String, Object> model) {
Pageable p = PageRequest.of(0, 3); Pageable p = PageRequest.of(0, 3);
Map<Offer, String> datos = new HashMap<Offer, String>(); Map<Offer, String> datos = new HashMap<Offer, String>();
for(Offer of:this.foodOfferService.findAllFoodOffer(p)) { for (Offer of : this.foodOfferService.findAllFoodOffer(p)) {
datos.put(of, "food"); datos.put(of, "food");
} }
for(Offer of:this.nuOfferService.findAllNuOffer(p)) { for (Offer of : this.nuOfferService.findAllNuOffer(p)) {
datos.put(of, "nu"); datos.put(of, "nu");
} }
for(Offer of:this.speedOfferService.findAllSpeedOffer(p)) { for (Offer of : this.speedOfferService.findAllSpeedOffer(p)) {
datos.put(of, "speed"); datos.put(of, "speed");
} }
for(Offer of:this.timeOfferService.findAllTimeOffer(p)) { for (Offer of : this.timeOfferService.findAllTimeOffer(p)) {
datos.put(of, "time"); datos.put(of, "time");
} }
model.put("datos", datos); model.put("datos", datos);
//Se añade formateador de fecha al modelo //Se añade formateador de fecha al modelo
@ -192,7 +202,7 @@ public class OfertaController {
return "offers/offersRecordList"; return "offers/offersRecordList";
} }
// @GetMapping("/owners/{ownerId}/edit") // @GetMapping("/owners/{ownerId}/edit")
// public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) { // public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
// Owner owner = this.ownerService.findOwnerById(ownerId); // Owner owner = this.ownerService.findOwnerById(ownerId);