mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 07:45:49 +00:00
Modf Gabo a Modf Seg
Error corregido
This commit is contained in:
commit
fe623f2c6f
11 changed files with 162 additions and 216 deletions
|
@ -3,6 +3,7 @@ package org.springframework.cheapy.model;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
@ -10,75 +11,80 @@ import javax.validation.constraints.NotNull;
|
|||
@Table(name = "nu_offers")
|
||||
public class NuOffer extends Offer {
|
||||
|
||||
//Oferta por numero de comensales
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
private Integer gold;
|
||||
@Min(1)
|
||||
private Integer gold;
|
||||
|
||||
@Column(name = "discount_gold")
|
||||
@NotBlank
|
||||
private String discountGold;
|
||||
private String discountGold;
|
||||
|
||||
@NotNull
|
||||
private Integer silver;
|
||||
@Min(1)
|
||||
private Integer silver;
|
||||
|
||||
@Column(name = "discount_silver")
|
||||
@NotBlank
|
||||
private String discountSilver;
|
||||
private String discountSilver;
|
||||
|
||||
@NotNull
|
||||
private Integer bronze;
|
||||
@Min(1)
|
||||
private Integer bronze;
|
||||
|
||||
@Column(name = "discount_bronze")
|
||||
@NotBlank
|
||||
private String discountBronze;
|
||||
private String discountBronze;
|
||||
|
||||
|
||||
public Integer getGold() {
|
||||
return gold;
|
||||
return this.gold;
|
||||
}
|
||||
|
||||
public void setGold(Integer gold) {
|
||||
public void setGold(final Integer gold) {
|
||||
this.gold = gold;
|
||||
}
|
||||
|
||||
public String getDiscountGold() {
|
||||
return discountGold;
|
||||
return this.discountGold;
|
||||
}
|
||||
|
||||
public void setDiscountGold(String discountGold) {
|
||||
public void setDiscountGold(final String discountGold) {
|
||||
this.discountGold = discountGold;
|
||||
}
|
||||
|
||||
public Integer getSilver() {
|
||||
return silver;
|
||||
return this.silver;
|
||||
}
|
||||
|
||||
public void setSilver(Integer silver) {
|
||||
public void setSilver(final Integer silver) {
|
||||
this.silver = silver;
|
||||
}
|
||||
|
||||
public String getDiscountSilver() {
|
||||
return discountSilver;
|
||||
return this.discountSilver;
|
||||
}
|
||||
|
||||
public void setDiscountSilver(String discountSilver) {
|
||||
public void setDiscountSilver(final String discountSilver) {
|
||||
this.discountSilver = discountSilver;
|
||||
}
|
||||
|
||||
public Integer getBronze() {
|
||||
return bronze;
|
||||
return this.bronze;
|
||||
}
|
||||
|
||||
public void setBronze(Integer bronze) {
|
||||
public void setBronze(final Integer bronze) {
|
||||
this.bronze = bronze;
|
||||
}
|
||||
|
||||
public String getDiscountBronze() {
|
||||
return discountBronze;
|
||||
return this.discountBronze;
|
||||
}
|
||||
|
||||
public void setDiscountBronze(String discountBronze) {
|
||||
public void setDiscountBronze(final String discountBronze) {
|
||||
this.discountBronze = discountBronze;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.springframework.cheapy.model;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
@ -10,75 +11,80 @@ import javax.validation.constraints.NotNull;
|
|||
@Table(name = "speed_offers")
|
||||
public class SpeedOffer extends Offer {
|
||||
|
||||
//Ofertar por rapidez comiendo
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
private Integer gold; // x minutos
|
||||
@Min(0)
|
||||
private Integer gold; // x minutos
|
||||
|
||||
@Column(name = "discount_gold")
|
||||
@NotBlank
|
||||
private String discountGold;
|
||||
private String discountGold;
|
||||
|
||||
@NotNull
|
||||
private Integer silver;
|
||||
@Min(0)
|
||||
private Integer silver;
|
||||
|
||||
@Column(name = "discount_silver")
|
||||
@NotBlank
|
||||
private String discountSilver;
|
||||
private String discountSilver;
|
||||
|
||||
@NotNull
|
||||
private Integer bronze;
|
||||
@Min(0)
|
||||
private Integer bronze;
|
||||
|
||||
@Column(name = "discount_bronze")
|
||||
@NotBlank
|
||||
private String discountBronze;
|
||||
private String discountBronze;
|
||||
|
||||
|
||||
public Integer getGold() {
|
||||
return gold;
|
||||
return this.gold;
|
||||
}
|
||||
|
||||
public void setGold(Integer gold) {
|
||||
public void setGold(final Integer gold) {
|
||||
this.gold = gold;
|
||||
}
|
||||
|
||||
public String getDiscountGold() {
|
||||
return discountGold;
|
||||
return this.discountGold;
|
||||
}
|
||||
|
||||
public void setDiscountGold(String discountGold) {
|
||||
public void setDiscountGold(final String discountGold) {
|
||||
this.discountGold = discountGold;
|
||||
}
|
||||
|
||||
public Integer getSilver() {
|
||||
return silver;
|
||||
return this.silver;
|
||||
}
|
||||
|
||||
public void setSilver(Integer silver) {
|
||||
public void setSilver(final Integer silver) {
|
||||
this.silver = silver;
|
||||
}
|
||||
|
||||
public String getDiscountSilver() {
|
||||
return discountSilver;
|
||||
return this.discountSilver;
|
||||
}
|
||||
|
||||
public void setDiscountSilver(String discountSilver) {
|
||||
public void setDiscountSilver(final String discountSilver) {
|
||||
this.discountSilver = discountSilver;
|
||||
}
|
||||
|
||||
public Integer getBronze() {
|
||||
return bronze;
|
||||
return this.bronze;
|
||||
}
|
||||
|
||||
public void setBronze(Integer bronze) {
|
||||
public void setBronze(final Integer bronze) {
|
||||
this.bronze = bronze;
|
||||
}
|
||||
|
||||
public String getDiscountBronze() {
|
||||
return discountBronze;
|
||||
return this.discountBronze;
|
||||
}
|
||||
|
||||
public void setDiscountBronze(String discountBronze) {
|
||||
public void setDiscountBronze(final String discountBronze) {
|
||||
this.discountBronze = discountBronze;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package org.springframework.cheapy.service;
|
||||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
|
@ -8,9 +8,11 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class NuOfferService {
|
||||
|
||||
private NuOfferRepository nuOfferRepository;
|
||||
|
||||
|
||||
|
@ -19,18 +21,18 @@ public class NuOfferService {
|
|||
this.nuOfferRepository = nuOfferRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public NuOffer findNuOfferById(final int id) {
|
||||
|
||||
return this.nuOfferRepository.findNuOfferById(id);
|
||||
}
|
||||
public List<NuOffer> findAllNuOffer() { //
|
||||
return this.nuOfferRepository.findAllNuOffer();
|
||||
|
||||
@Transactional
|
||||
public List<NuOffer> findAllNuOffer() { //
|
||||
return this.nuOfferRepository.findAllNuOffer();
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException { //
|
||||
this.nuOfferRepository.save(nuOffer);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package org.springframework.cheapy.service;
|
||||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -8,6 +8,7 @@ import org.springframework.cheapy.model.SpeedOffer;
|
|||
import org.springframework.cheapy.repository.SpeedOfferRepository;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class SpeedOfferService {
|
||||
|
@ -20,17 +21,18 @@ public class SpeedOfferService {
|
|||
this.speedOfferRepository = speedOfferRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SpeedOffer findSpeedOfferById(final int id) {
|
||||
return this.speedOfferRepository.findById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<SpeedOffer> findAllSpeedOffer() { //
|
||||
return this.speedOfferRepository.findAllSpeedOffer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { //
|
||||
this.speedOfferRepository.save(speedOffer);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.Owner;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.service.FoodOfferService;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
|
@ -37,12 +33,16 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class NuOfferController {
|
||||
|
||||
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "nuOffers/createOrUpdateNuOfferForm";
|
||||
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "nuOffers/createOrUpdateNuOfferForm";
|
||||
|
||||
private final NuOfferService nuOfferService;
|
||||
private final ClientService clientService;
|
||||
private final FoodOfferService foodOfferService;
|
||||
private final NuOfferService nuOfferService;
|
||||
private final SpeedOfferService speedOfferService;
|
||||
private final TimeOfferService timeOfferService;
|
||||
|
||||
public NuOfferController(final NuOfferService nuOfferService,ClientService clientService) {
|
||||
|
||||
public NuOfferController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService, final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
|
||||
this.foodOfferService = foodOfferService;
|
||||
this.nuOfferService = nuOfferService;
|
||||
this.clientService = clientService;
|
||||
|
||||
|
@ -102,111 +102,72 @@ public class NuOfferController {
|
|||
|
||||
@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);
|
||||
|
||||
|
||||
model.put("nuOffer", nuOffer);
|
||||
return "nuOffers/nuOffersShow";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
|
||||
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
model.put("nuOffer", nuOffer);
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
model.addAttribute("nuOffer", nuOffer);
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, @PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final Principal principal, final ModelMap model) {
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.put("nuOffer", nuOfferEdit);
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
model.addAttribute("nuOffer", nuOfferEdit);
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
|
||||
NuOffer nuOfferOld=this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
|
||||
BeanUtils.copyProperties(nuOfferEdit, nuOfferOld, "id", "client_id");
|
||||
|
||||
this.nuOfferService.saveNuOffer(nuOfferOld);
|
||||
|
||||
return "offers/offersList";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value ="/offers/nu/{nuOfferId}/edit")
|
||||
public String initUpdateNuOfferForm(@PathVariable("nuOfferId") int nuOfferId, Model model) {
|
||||
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
model.addAttribute(nuOffer);
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/nu/{nuOfferId}/edit")
|
||||
public String processUpdateOwnerForm(@Valid NuOffer nuOffer, BindingResult result,
|
||||
@PathVariable("nuOfferId") int nuOfferId) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
else {
|
||||
nuOffer.setId(nuOfferId);
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
return "redirect:/offers/nu/{nuOfferId}";
|
||||
this.nuOfferService.saveNuOffer(nuOfferEdit);
|
||||
return "redirect:/offers/nu/" + nuOfferEdit.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
//
|
||||
// if (this.tieneCitasAceptadasYPendientes(vehiculoId)) {
|
||||
// model.addAttribute("x", true);
|
||||
//
|
||||
// } else {
|
||||
// model.addAttribute("x", false);
|
||||
// }
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
//
|
||||
// if (this.tieneCitasAceptadasYPendientes(vehiculoId)) {
|
||||
// model.addAttribute("x", true);
|
||||
//
|
||||
// } else {
|
||||
// model.addAttribute("x", false);
|
||||
// }
|
||||
|
||||
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
model.put("nuOffer", nuOffer);
|
||||
return "nuOffers/nuOffersDisable";
|
||||
}
|
||||
|
||||
@PostMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||
@PostMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
//
|
||||
// if (this.tieneCitasAceptadasYPendientes(vehiculoId)) {
|
||||
// return "redirect:/cliente/vehiculos/{vehiculoId}/disable";
|
||||
//
|
||||
// } else {
|
||||
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
//
|
||||
// if (this.tieneCitasAceptadasYPendientes(vehiculoId)) {
|
||||
// return "redirect:/cliente/vehiculos/{vehiculoId}/disable";
|
||||
//
|
||||
// } else {
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
|
||||
nuOffer.setType(StatusOffer.inactive);
|
||||
|
||||
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
|
||||
|
||||
return "redirect:";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,34 +1,13 @@
|
|||
/*
|
||||
* 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.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.service.FoodOfferService;
|
||||
import org.springframework.cheapy.service.NuOfferService;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
|
@ -105,81 +84,66 @@ public class SpeedOfferController {
|
|||
model.put("speedOffer", speedOffer);
|
||||
return "speedOffers/speedOffersShow";
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateNuOffer(@PathVariable("speedOfferId") final int speedOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
|
||||
SpeedOffer speedOffer=this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
model.put("speedOffer", speedOffer);
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
model.addAttribute("speedOffer", speedOffer);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateNuOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result, @PathVariable("speedOfferId") final int speedOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
public String updateNuOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result, final Principal principal, final ModelMap model) {
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.put("speedOffer", speedOfferEdit);
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
model.addAttribute("speedOffer", speedOfferEdit);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
|
||||
SpeedOffer speedOfferOld=this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
|
||||
BeanUtils.copyProperties(speedOfferEdit, speedOfferOld, "id", "client_id");
|
||||
|
||||
this.speedOfferService.saveSpeedOffer(speedOfferOld);
|
||||
|
||||
return "redirect:";
|
||||
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
|
||||
return "redirect:/offers/speed/" + speedOfferEdit.getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/disable")
|
||||
public String disableSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
//
|
||||
// if (this.tieneCitasAceptadasYPendientes(vehiculoId)) {
|
||||
// model.addAttribute("x", true);
|
||||
//
|
||||
// } else {
|
||||
// model.addAttribute("x", false);
|
||||
// }
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
//
|
||||
// if (this.tieneCitasAceptadasYPendientes(vehiculoId)) {
|
||||
// model.addAttribute("x", true);
|
||||
//
|
||||
// } else {
|
||||
// model.addAttribute("x", false);
|
||||
// }
|
||||
|
||||
SpeedOffer speedOffer=this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
model.put("speedOffer", speedOffer);
|
||||
return "speedOffers/speedOffersDisable";
|
||||
}
|
||||
|
||||
@PostMapping(value = "/offers/speed/{speedOfferId}/disable")
|
||||
@PostMapping(value = "/offers/speed/{speedOfferId}/disable")
|
||||
public String disableNuOfferForm(@PathVariable("speedOfferId") final int speedOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
//
|
||||
// if (this.tieneCitasAceptadasYPendientes(vehiculoId)) {
|
||||
// return "redirect:/cliente/vehiculos/{vehiculoId}/disable";
|
||||
//
|
||||
// } else {
|
||||
SpeedOffer speedOffer=this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
|
||||
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
|
||||
// return "exception";
|
||||
// }
|
||||
//
|
||||
// if (this.tieneCitasAceptadasYPendientes(vehiculoId)) {
|
||||
// return "redirect:/cliente/vehiculos/{vehiculoId}/disable";
|
||||
//
|
||||
// } else {
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
|
||||
speedOffer.setType(StatusOffer.inactive);
|
||||
|
||||
|
||||
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||
|
||||
|
||||
return "redirect:";
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,8 +31,7 @@ INSERT INTO clients VALUES (1,'manoli@gmail.com','C/Betis','10:00','22:00','608
|
|||
INSERT INTO clients VALUES (2,'david@gmail.com','C/Sevilla','09:30','22:00','608726190', 'description 2', 'code2', 'americana','david');
|
||||
|
||||
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', 'FO-1', 'active', null, 'macarrones', '15%', 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', 'SP-1', 'active', null, 5, '15%', 10, '10%', 15, '5%');
|
||||
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 time_offers(start, end, code, type, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'T-1', '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', 'SP-1', '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', 'NU-1', 'active', null,15,'25%',10,'15%',5,'10%' );
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
</h2>
|
||||
<form:form modelAttribute="nuOffer" class="form-horizontal" id="add-nuOffer-form">
|
||||
<div class="form-group has-feedback">
|
||||
<form:hidden path="id"/>
|
||||
<form:hidden path="code"/>
|
||||
<form:hidden path="type"/>
|
||||
<petclinic:inputField label="Fecha de inicio" name="start"/>
|
||||
<petclinic:inputField label="Fecha de fin" name="end"/>
|
||||
|
||||
|
@ -27,10 +30,10 @@
|
|||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<c:choose>
|
||||
<c:when test="${nuOffer['new']}">
|
||||
<button class="btn btn-default" type="submit">Add Offer</button>
|
||||
<button class="btn btn-default" type="submit">Crear oferta</button>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<button class="btn btn-default" type="submit">Update Offer</button>
|
||||
<button class="btn btn-default" type="submit">Modificar</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
|
|
|
@ -49,13 +49,13 @@
|
|||
</table>
|
||||
|
||||
<spring:url value="{nuOfferId}/edit" var="editUrl">
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar Oferta</a>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||
|
||||
<spring:url value="{nuOfferId}/disable" var="editUrl">
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Eliminar Oferta</a>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactiva oferta</a>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
</h2>
|
||||
<form:form modelAttribute="speedOffer" class="form-horizontal" id="add-speedOffer-form">
|
||||
<div class="form-group has-feedback">
|
||||
<form:hidden path="id"/>
|
||||
<form:hidden path="code"/>
|
||||
<form:hidden path="type"/>
|
||||
<petclinic:inputField label="Start Date" name="start"/>
|
||||
<petclinic:inputField label="End Date" name="end"/>
|
||||
<petclinic:inputField label="Gold" name="gold"/>
|
||||
|
@ -25,10 +28,10 @@
|
|||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<c:choose>
|
||||
<c:when test="${speedOffer['new']}">
|
||||
<button class="btn btn-default" type="submit">Add Speed Offer</button>
|
||||
<button class="btn btn-default" type="submit">Crear oferta</button>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<button class="btn btn-default" type="submit">Update Offer</button>
|
||||
<button class="btn btn-default" type="submit">Modificar</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
|
|
|
@ -48,9 +48,9 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:url value="{speedOfferId}/edit" var="editUrl">
|
||||
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a> --%>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
Loading…
Reference in a new issue