Error corregido

This commit is contained in:
gabgutpri@alum.us.es 2021-03-26 19:28:11 +01:00
parent a75a5adc70
commit 14585f778a
11 changed files with 186 additions and 266 deletions

View file

@ -5,7 +5,7 @@
* 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
* 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,
@ -13,85 +13,92 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;
@Entity
@Table(name = "nu_offers")
public class NuOffer extends Offer {
//Oferta por numero de comensales
//Oferta por numero de comensales
@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;
}
}
}

View file

@ -5,7 +5,7 @@
* 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
* 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,
@ -13,85 +13,92 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;
@Entity
@Table(name = "speed_offers")
public class SpeedOffer extends Offer {
//Ofertar por rapidez comiendo
//Ofertar por rapidez comiendo
@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;
}
}
}

View file

@ -1,18 +1,18 @@
package org.springframework.cheapy.service;
import java.util.Collection;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cheapy.model.NuOffer;
import org.springframework.cheapy.model.Owner;
import org.springframework.cheapy.repository.NuOfferRepository;
import org.springframework.cheapy.repository.OwnerRepository;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class NuOfferService {
private NuOfferRepository nuOfferRepository;
@ -21,17 +21,18 @@ public class NuOfferService {
this.nuOfferRepository = nuOfferRepository;
}
@Transactional
public NuOffer findNuOfferById(final int id) {
return this.nuOfferRepository.findById(id);
}
@Transactional
public List<NuOffer> findAllNuOffer() { //
return this.nuOfferRepository.findAllNuOffer();
}
@Transactional
public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException { //
this.nuOfferRepository.save(nuOffer);
}
}

View file

@ -1,6 +1,6 @@
package org.springframework.cheapy.service;
import java.util.Collection;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
@ -8,9 +8,11 @@ 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 {
private SpeedOfferRepository speedOfferRepository;
@ -19,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);
}
}

View file

@ -5,7 +5,7 @@
* 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
* 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,
@ -13,21 +13,16 @@
* 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.service.SpeedOfferService;
@ -39,27 +34,24 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @author Juergen Hoeller
* @author Ken Krebs
* @author Arjen Poutsma
* @author Michael Isvy
*/
@Controller
@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 FoodOfferService foodOfferService;
private final NuOfferService nuOfferService;
private final SpeedOfferService speedOfferService;
private final TimeOfferService timeOfferService;
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) {
public NuOfferController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService, final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
this.foodOfferService = foodOfferService;
this.nuOfferService = nuOfferService;
this.speedOfferService = speedOfferService;
@ -67,121 +59,77 @@ public class NuOfferController {
}
@GetMapping("/offers/nu/{nuOfferId}")
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
public String processShowForm(@PathVariable("nuOfferId") final int nuOfferId, final Map<String, Object> model) {
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
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;
// }
@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 "redirect:";
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:";
}
}

View file

@ -5,7 +5,7 @@
* 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
* 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,
@ -13,21 +13,16 @@
* 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.service.SpeedOfferService;
@ -39,27 +34,24 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @author Juergen Hoeller
* @author Ken Krebs
* @author Arjen Poutsma
* @author Michael Isvy
*/
@Controller
@Controller
public class SpeedOfferController {
private static final String VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM = "speedOffers/createOrUpdateSpeedOfferForm";
private static final String VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM = "speedOffers/createOrUpdateSpeedOfferForm";
private final FoodOfferService foodOfferService;
private final NuOfferService nuOfferService;
private final SpeedOfferService speedOfferService;
private final TimeOfferService timeOfferService;
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) {
public SpeedOfferController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService, final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
this.foodOfferService = foodOfferService;
this.nuOfferService = nuOfferService;
this.speedOfferService = speedOfferService;
@ -67,121 +59,77 @@ public class SpeedOfferController {
}
@GetMapping("/offers/speed/{speedOfferId}")
public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map<String, Object> model) {
public String processShowForm(@PathVariable("speedOfferId") final int speedOfferId, final Map<String, Object> model) {
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
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;
// }
@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:";
}
}

View file

@ -10,10 +10,10 @@ INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Mad
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
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 food_offers(start, end, code, type, client_id, food, discount, units) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'F-001', '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', 'T-001', '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-001', '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-001', 'active', null,15,'25%',10,'15%',5,'10%' );
INSERT INTO users(username,password,enabled) VALUES ('admin1','4dm1n',TRUE);
INSERT INTO authorities(id,username,authority) VALUES (1,'admin1','admin');

View file

@ -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>

View file

@ -48,9 +48,9 @@
</tr>
</table>
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
<spring:param name="ownerId" value="${owner.id}"/>
<spring:url value="{nuOfferId}/edit" var="editUrl">
<spring:param name="nuOfferId" value="${nuOffer.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 ofeta</a>
</cheapy:layout>

View file

@ -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>

View file

@ -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>