mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
commit
f3df2441aa
6 changed files with 46 additions and 29 deletions
|
@ -105,14 +105,17 @@ public class FoodOfferController {
|
|||
public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map<String, Object> model) {
|
||||
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
if(!foodOffer.getStatus().equals(StatusOffer.active)) {
|
||||
return "error";
|
||||
if(foodOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("foodOffer", foodOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersShow";
|
||||
|
||||
}else if(foodOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(foodOfferId))) {
|
||||
model.put("foodOffer", foodOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersShow";
|
||||
}else {
|
||||
model.put("foodOffer", foodOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
return "offers/food/foodOffersShow";
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,13 +136,17 @@ public class NuOfferController {
|
|||
@GetMapping("/offers/nu/{nuOfferId}")
|
||||
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
if(!nuOffer.getStatus().equals(StatusOffer.active)) {
|
||||
return "error";
|
||||
if(nuOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("nuOffer", nuOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
}else if(nuOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(nuOfferId))) {
|
||||
model.put("nuOffer", nuOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
|
||||
}else {
|
||||
model.put("nuOffer", nuOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -131,13 +131,17 @@ public class SpeedOfferController {
|
|||
@GetMapping("/offers/speed/{speedOfferId}")
|
||||
public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map<String, Object> model) {
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
if(!speedOffer.getStatus().equals(StatusOffer.active)) {
|
||||
return "error";
|
||||
if(speedOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("speedOffer", speedOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
}else if(speedOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(speedOfferId))) {
|
||||
model.put("speedOffer", speedOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
|
||||
}else {
|
||||
model.put("speedOffer", speedOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,18 +120,20 @@ public class TimeOfferController {
|
|||
|
||||
@GetMapping("/offers/time/{timeOfferId}")
|
||||
public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map<String, Object> model) {
|
||||
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
if(!timeOffer.getStatus().equals(StatusOffer.active)) {
|
||||
return "error";
|
||||
if(timeOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("timeOffer", timeOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersShow";
|
||||
|
||||
} else if(timeOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(timeOfferId))) {
|
||||
model.put("timeOffer", timeOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersShow";
|
||||
|
||||
}else {
|
||||
model.put("timeOffer", timeOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
return "offers/time/timeOffersShow";
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
|
|
|
@ -5,6 +5,7 @@ spring.datasource.data=classpath*:db/${database}/data.sql
|
|||
spring.h2.console.enabled=true
|
||||
spring.profiles.active=mysql
|
||||
spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/cheapy?serverTimezone=UTC}
|
||||
|
||||
# Web
|
||||
spring.thymeleaf.mode=HTML
|
||||
|
||||
|
|
|
@ -51,4 +51,7 @@ finishOffer= Fin del intervalo
|
|||
name= Nombre del restaurante
|
||||
status= Estado de oferta
|
||||
myOffers= Ver mis Ofertas
|
||||
|
||||
typeMismatch=Debe ser del formato correcto
|
||||
typeMismatch.java.lang.Integer=Debe ser un número
|
||||
typeMismatch.java.time.LocalDateTime=Debe ser una fecha válida
|
||||
typeMismatch.java.time.LocalTime=Debe ser una hora válida
|
||||
|
|
Loading…
Reference in a new issue