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

@ -13,19 +13,23 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cheapy.model; package org.springframework.cheapy.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@Entity @Entity
@Table(name = "nu_offers") @Table(name = "nu_offers")
public class NuOffer extends Offer { public class NuOffer extends Offer {
//Oferta por numero de comensales //Oferta por numero de comensales
@NotNull @NotNull
@Min(1)
private Integer gold; private Integer gold;
@Column(name = "discount_gold") @Column(name = "discount_gold")
@ -33,6 +37,7 @@ public class NuOffer extends Offer {
private String discountGold; private String discountGold;
@NotNull @NotNull
@Min(1)
private Integer silver; private Integer silver;
@Column(name = "discount_silver") @Column(name = "discount_silver")
@ -40,57 +45,59 @@ public class NuOffer extends Offer {
private String discountSilver; private String discountSilver;
@NotNull @NotNull
@Min(1)
private Integer bronze; private Integer bronze;
@Column(name = "discount_bronze") @Column(name = "discount_bronze")
@NotBlank @NotBlank
private String discountBronze; private String discountBronze;
public Integer getGold() { public Integer getGold() {
return gold; return this.gold;
} }
public void setGold(Integer gold) { public void setGold(final Integer gold) {
this.gold = gold; this.gold = gold;
} }
public String getDiscountGold() { public String getDiscountGold() {
return discountGold; return this.discountGold;
} }
public void setDiscountGold(String discountGold) { public void setDiscountGold(final String discountGold) {
this.discountGold = discountGold; this.discountGold = discountGold;
} }
public Integer getSilver() { public Integer getSilver() {
return silver; return this.silver;
} }
public void setSilver(Integer silver) { public void setSilver(final Integer silver) {
this.silver = silver; this.silver = silver;
} }
public String getDiscountSilver() { public String getDiscountSilver() {
return discountSilver; return this.discountSilver;
} }
public void setDiscountSilver(String discountSilver) { public void setDiscountSilver(final String discountSilver) {
this.discountSilver = discountSilver; this.discountSilver = discountSilver;
} }
public Integer getBronze() { public Integer getBronze() {
return bronze; return this.bronze;
} }
public void setBronze(Integer bronze) { public void setBronze(final Integer bronze) {
this.bronze = bronze; this.bronze = bronze;
} }
public String getDiscountBronze() { public String getDiscountBronze() {
return discountBronze; return this.discountBronze;
} }
public void setDiscountBronze(String discountBronze) { public void setDiscountBronze(final String discountBronze) {
this.discountBronze = discountBronze; this.discountBronze = discountBronze;
} }

View file

@ -13,19 +13,23 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cheapy.model; package org.springframework.cheapy.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@Entity @Entity
@Table(name = "speed_offers") @Table(name = "speed_offers")
public class SpeedOffer extends Offer { public class SpeedOffer extends Offer {
//Ofertar por rapidez comiendo //Ofertar por rapidez comiendo
@NotNull @NotNull
@Min(0)
private Integer gold; // x minutos private Integer gold; // x minutos
@Column(name = "discount_gold") @Column(name = "discount_gold")
@ -33,6 +37,7 @@ public class SpeedOffer extends Offer {
private String discountGold; private String discountGold;
@NotNull @NotNull
@Min(0)
private Integer silver; private Integer silver;
@Column(name = "discount_silver") @Column(name = "discount_silver")
@ -40,57 +45,59 @@ public class SpeedOffer extends Offer {
private String discountSilver; private String discountSilver;
@NotNull @NotNull
@Min(0)
private Integer bronze; private Integer bronze;
@Column(name = "discount_bronze") @Column(name = "discount_bronze")
@NotBlank @NotBlank
private String discountBronze; private String discountBronze;
public Integer getGold() { public Integer getGold() {
return gold; return this.gold;
} }
public void setGold(Integer gold) { public void setGold(final Integer gold) {
this.gold = gold; this.gold = gold;
} }
public String getDiscountGold() { public String getDiscountGold() {
return discountGold; return this.discountGold;
} }
public void setDiscountGold(String discountGold) { public void setDiscountGold(final String discountGold) {
this.discountGold = discountGold; this.discountGold = discountGold;
} }
public Integer getSilver() { public Integer getSilver() {
return silver; return this.silver;
} }
public void setSilver(Integer silver) { public void setSilver(final Integer silver) {
this.silver = silver; this.silver = silver;
} }
public String getDiscountSilver() { public String getDiscountSilver() {
return discountSilver; return this.discountSilver;
} }
public void setDiscountSilver(String discountSilver) { public void setDiscountSilver(final String discountSilver) {
this.discountSilver = discountSilver; this.discountSilver = discountSilver;
} }
public Integer getBronze() { public Integer getBronze() {
return bronze; return this.bronze;
} }
public void setBronze(Integer bronze) { public void setBronze(final Integer bronze) {
this.bronze = bronze; this.bronze = bronze;
} }
public String getDiscountBronze() { public String getDiscountBronze() {
return discountBronze; return this.discountBronze;
} }
public void setDiscountBronze(String discountBronze) { public void setDiscountBronze(final String discountBronze) {
this.discountBronze = discountBronze; this.discountBronze = discountBronze;
} }

View file

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

View file

@ -1,6 +1,6 @@
package org.springframework.cheapy.service; package org.springframework.cheapy.service;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; 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.cheapy.repository.SpeedOfferRepository;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class SpeedOfferService { public class SpeedOfferService {
private SpeedOfferRepository speedOfferRepository; private SpeedOfferRepository speedOfferRepository;
@ -19,17 +21,18 @@ public class SpeedOfferService {
this.speedOfferRepository = speedOfferRepository; this.speedOfferRepository = speedOfferRepository;
} }
@Transactional
public SpeedOffer findSpeedOfferById(final int id) { public SpeedOffer findSpeedOfferById(final int id) {
return this.speedOfferRepository.findById(id); return this.speedOfferRepository.findById(id);
} }
@Transactional
public List<SpeedOffer> findAllSpeedOffer() { // public List<SpeedOffer> findAllSpeedOffer() { //
return this.speedOfferRepository.findAllSpeedOffer(); return this.speedOfferRepository.findAllSpeedOffer();
} }
@Transactional
public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { // public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { //
this.speedOfferRepository.save(speedOffer); this.speedOfferRepository.save(speedOffer);
} }
} }

View file

@ -13,21 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cheapy.web; package org.springframework.cheapy.web;
import java.security.Principal; import java.security.Principal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.validation.Valid; 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.NuOffer;
import org.springframework.cheapy.model.SpeedOffer;
import org.springframework.cheapy.model.StatusOffer; import org.springframework.cheapy.model.StatusOffer;
import org.springframework.cheapy.model.TimeOffer;
import org.springframework.cheapy.service.FoodOfferService; import org.springframework.cheapy.service.FoodOfferService;
import org.springframework.cheapy.service.NuOfferService; import org.springframework.cheapy.service.NuOfferService;
import org.springframework.cheapy.service.SpeedOfferService; import org.springframework.cheapy.service.SpeedOfferService;
@ -39,7 +34,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Ken Krebs * @author Ken Krebs
@ -57,9 +51,7 @@ public class NuOfferController {
private final TimeOfferService timeOfferService; 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.foodOfferService = foodOfferService;
this.nuOfferService = nuOfferService; this.nuOfferService = nuOfferService;
this.speedOfferService = speedOfferService; this.speedOfferService = speedOfferService;
@ -67,9 +59,8 @@ public class NuOfferController {
} }
@GetMapping("/offers/nu/{nuOfferId}") @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);
@ -79,67 +70,24 @@ public class NuOfferController {
} }
// @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") @GetMapping(value = "/offers/nu/{nuOfferId}/edit")
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) { 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); NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
model.put("nuOffer", nuOffer); model.addAttribute("nuOffer", nuOffer);
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM; return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
} }
@PostMapping(value = "/offers/nu/{nuOfferId}/edit") @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) { public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final Principal principal, final ModelMap model) {
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
// return "exception";
// }
if (result.hasErrors()) { if (result.hasErrors()) {
model.put("nuOffer", nuOfferEdit); model.addAttribute("nuOffer", nuOfferEdit);
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM; return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
} else { } else {
this.nuOfferService.saveNuOffer(nuOfferEdit);
NuOffer nuOfferOld=this.nuOfferService.findNuOfferById(nuOfferId); return "redirect:/offers/nu/" + nuOfferEdit.getId();
BeanUtils.copyProperties(nuOfferEdit, nuOfferOld, "id", "client_id");
this.nuOfferService.saveNuOffer(nuOfferOld);
return "redirect:";
} }
} }

View file

@ -13,21 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cheapy.web; package org.springframework.cheapy.web;
import java.security.Principal; import java.security.Principal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.validation.Valid; 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.SpeedOffer;
import org.springframework.cheapy.model.StatusOffer; import org.springframework.cheapy.model.StatusOffer;
import org.springframework.cheapy.model.TimeOffer;
import org.springframework.cheapy.service.FoodOfferService; import org.springframework.cheapy.service.FoodOfferService;
import org.springframework.cheapy.service.NuOfferService; import org.springframework.cheapy.service.NuOfferService;
import org.springframework.cheapy.service.SpeedOfferService; import org.springframework.cheapy.service.SpeedOfferService;
@ -39,7 +34,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Ken Krebs * @author Ken Krebs
@ -57,9 +51,7 @@ public class SpeedOfferController {
private final TimeOfferService timeOfferService; 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.foodOfferService = foodOfferService;
this.nuOfferService = nuOfferService; this.nuOfferService = nuOfferService;
this.speedOfferService = speedOfferService; this.speedOfferService = speedOfferService;
@ -67,9 +59,8 @@ public class SpeedOfferController {
} }
@GetMapping("/offers/speed/{speedOfferId}") @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);
@ -79,66 +70,24 @@ public class SpeedOfferController {
} }
// @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") @GetMapping(value = "/offers/speed/{speedOfferId}/edit")
public String updateNuOffer(@PathVariable("speedOfferId") final int speedOfferId, final Principal principal, final ModelMap model) { 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); SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
model.put("speedOffer", speedOffer); model.addAttribute("speedOffer", speedOffer);
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM; return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
} }
@PostMapping(value = "/offers/speed/{speedOfferId}/edit") @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) { public String updateNuOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result, final Principal principal, final ModelMap model) {
// if (!this.comprobarIdentidad(principal, vehiculoId)) {
// return "exception";
// }
if (result.hasErrors()) { if (result.hasErrors()) {
model.put("speedOffer", speedOfferEdit); model.addAttribute("speedOffer", speedOfferEdit);
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM; return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
} else { } else {
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
SpeedOffer speedOfferOld=this.speedOfferService.findSpeedOfferById(speedOfferId); return "redirect:/offers/speed/" + speedOfferEdit.getId();
BeanUtils.copyProperties(speedOfferEdit, speedOfferOld, "id", "client_id");
this.speedOfferService.saveSpeedOffer(speedOfferOld);
return "redirect:";
} }
} }
@ -183,5 +132,4 @@ public class SpeedOfferController {
} }
} }

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 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 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', 'jkhlljk', 'active', null, '12:00:00', '13:00:00', '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', 'jkhlljk', 'active', null,5,'25%',10,'15%',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-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', 'jkhlljk', 'active', null,15,'25%',10,'15%',5,'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 users(username,password,enabled) VALUES ('admin1','4dm1n',TRUE);
INSERT INTO authorities(id,username,authority) VALUES (1,'admin1','admin'); INSERT INTO authorities(id,username,authority) VALUES (1,'admin1','admin');

View file

@ -12,6 +12,9 @@
</h2> </h2>
<form:form modelAttribute="nuOffer" class="form-horizontal" id="add-nuOffer-form"> <form:form modelAttribute="nuOffer" class="form-horizontal" id="add-nuOffer-form">
<div class="form-group has-feedback"> <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 inicio" name="start"/>
<petclinic:inputField label="Fecha de fin" name="end"/> <petclinic:inputField label="Fecha de fin" name="end"/>
@ -27,10 +30,10 @@
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<c:choose> <c:choose>
<c:when test="${nuOffer['new']}"> <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:when>
<c:otherwise> <c:otherwise>
<button class="btn btn-default" type="submit">Update Offer</button> <button class="btn btn-default" type="submit">Modificar</button>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</div> </div>

View file

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

View file

@ -12,6 +12,9 @@
</h2> </h2>
<form:form modelAttribute="speedOffer" class="form-horizontal" id="add-speedOffer-form"> <form:form modelAttribute="speedOffer" class="form-horizontal" id="add-speedOffer-form">
<div class="form-group has-feedback"> <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="Start Date" name="start"/>
<petclinic:inputField label="End Date" name="end"/> <petclinic:inputField label="End Date" name="end"/>
<petclinic:inputField label="Gold" name="gold"/> <petclinic:inputField label="Gold" name="gold"/>
@ -25,10 +28,10 @@
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<c:choose> <c:choose>
<c:when test="${speedOffer['new']}"> <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:when>
<c:otherwise> <c:otherwise>
<button class="btn btn-default" type="submit">Update Offer</button> <button class="btn btn-default" type="submit">Modificar</button>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</div> </div>

View file

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