mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Validaciones de atributos hidden
This commit is contained in:
parent
ba3aa68598
commit
db9cbbd8fa
10 changed files with 145 additions and 73 deletions
|
@ -4,8 +4,10 @@ package org.springframework.cheapy.web;
|
|||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
|
@ -30,7 +32,7 @@ public class FoodOfferController {
|
|||
this.foodOfferService = foodOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkIdentity(final int foodOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
@ -42,6 +44,15 @@ public class FoodOfferController {
|
|||
return res;
|
||||
}
|
||||
|
||||
private boolean checkOffer(final FoodOffer session, final FoodOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/food/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
FoodOffer foodOffer = new FoodOffer();
|
||||
|
@ -61,7 +72,7 @@ public class FoodOfferController {
|
|||
return "redirect:/offers/food/" + foodOffer.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/activate")
|
||||
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, ModelMap modelMap) {
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
|
@ -73,7 +84,7 @@ public class FoodOfferController {
|
|||
} else {
|
||||
modelMap.addAttribute("message", "You don't have access to this food offer");
|
||||
}
|
||||
return "redirect:/offers/food/"+foodOfferId;
|
||||
return "redirect:/offers/food/" + foodOfferId;
|
||||
|
||||
}
|
||||
|
||||
|
@ -83,29 +94,41 @@ public class FoodOfferController {
|
|||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
|
||||
model.put("foodOffer", foodOffer);
|
||||
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
|
||||
return "offers/food/foodOffersShow";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||
|
||||
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
if (foodOffer.getStatus().equals(StatusOffer.inactive)) {
|
||||
return "error";
|
||||
}
|
||||
model.addAttribute("foodOffer", foodOffer);
|
||||
request.getSession().setAttribute("idFood", foodOfferId);
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result, final ModelMap model) {
|
||||
|
||||
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferEdit.getId())) {
|
||||
System.out.println("Fallo Indentity");
|
||||
return "error";
|
||||
}
|
||||
Integer id = (Integer) request.getSession().getAttribute("idFood");
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(id);
|
||||
if (!this.checkOffer(foodOffer, foodOfferEdit)) {
|
||||
System.out.println("Fallo offer");
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
@ -114,6 +137,8 @@ public class FoodOfferController {
|
|||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
BeanUtils.copyProperties(this.foodOfferService.findFoodOfferById(foodOfferEdit.getId()), foodOfferEdit,
|
||||
"start", "end", "food", "discount");
|
||||
this.foodOfferService.saveFoodOffer(foodOfferEdit);
|
||||
return "redirect:/offers/food/" + foodOfferEdit.getId();
|
||||
}
|
||||
|
@ -121,7 +146,7 @@ public class FoodOfferController {
|
|||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/disable")
|
||||
public String disableFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
@ -133,7 +158,7 @@ public class FoodOfferController {
|
|||
|
||||
@PostMapping(value = "/offers/food/{foodOfferId}/disable")
|
||||
public String disableFoodOfferForm(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
|
|
@ -4,20 +4,19 @@ import java.security.Principal;
|
|||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.NuOfferService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
|
@ -34,11 +33,6 @@ public class NuOfferController {
|
|||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
// @InitBinder
|
||||
// public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
// dataBinder.setDisallowedFields("id");
|
||||
// }
|
||||
|
||||
@GetMapping("/offers/nu/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
NuOffer nuOffer = new NuOffer();
|
||||
|
@ -57,6 +51,15 @@ public class NuOfferController {
|
|||
return res;
|
||||
}
|
||||
|
||||
private boolean checkOffer(final NuOffer session, final NuOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/nu/new")
|
||||
public String processCreationForm(@Valid NuOffer nuOffer, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
|
@ -100,29 +103,41 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model) {
|
||||
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
if (nuOffer.getStatus().equals(StatusOffer.inactive)) {
|
||||
return "error";
|
||||
}
|
||||
model.addAttribute("nuOffer", nuOffer);
|
||||
request.getSession().setAttribute("idNu", nuOfferId);
|
||||
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, final ModelMap model) {
|
||||
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
Integer id = (Integer) request.getSession().getAttribute("idNu");
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(id);
|
||||
if (!this.checkOffer(nuOffer, nuOfferEdit)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("nuOffer", nuOfferEdit);
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
BeanUtils.copyProperties(this.nuOfferService.findNuOfferById(nuOfferEdit.getId()), nuOfferEdit, "start",
|
||||
"end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
this.nuOfferService.saveNuOffer(nuOfferEdit);
|
||||
return "redirect:/offers/nu/" + nuOfferEdit.getId();
|
||||
}
|
||||
|
|
|
@ -3,10 +3,12 @@ package org.springframework.cheapy.web;
|
|||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.SpeedOfferService;
|
||||
|
@ -29,7 +31,7 @@ public class SpeedOfferController {
|
|||
this.speedOfferService = speedOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkIdentity(final int speedOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
@ -41,6 +43,15 @@ public class SpeedOfferController {
|
|||
return res;
|
||||
}
|
||||
|
||||
private boolean checkOffer(final SpeedOffer session, final SpeedOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/speed/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
SpeedOffer speedOffer = new SpeedOffer();
|
||||
|
@ -61,7 +72,6 @@ public class SpeedOfferController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/activate")
|
||||
public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, ModelMap modelMap) {
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
|
@ -87,29 +97,41 @@ public class SpeedOfferController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||
|
||||
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model, HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
if (speedOffer.getStatus().equals(StatusOffer.inactive)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
model.addAttribute("speedOffer", speedOffer);
|
||||
request.getSession().setAttribute("idSpeed", speedOfferId);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result, final ModelMap model) {
|
||||
|
||||
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
Integer id = (Integer) request.getSession().getAttribute("idSpeed");
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(id);
|
||||
if (!this.checkOffer(speedOffer, speedOfferEdit)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("speedOffer", speedOfferEdit);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
BeanUtils.copyProperties(this.speedOfferService.findSpeedOfferById(speedOfferEdit.getId()), speedOfferEdit,
|
||||
"start", "end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
|
||||
return "redirect:/offers/speed/" + speedOfferEdit.getId();
|
||||
}
|
||||
|
@ -118,7 +140,7 @@ public class SpeedOfferController {
|
|||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/disable")
|
||||
public String disableSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
@ -130,7 +152,7 @@ public class SpeedOfferController {
|
|||
|
||||
@PostMapping(value = "/offers/speed/{speedOfferId}/disable")
|
||||
public String disableSpeedOfferForm(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package org.springframework.cheapy.web;
|
||||
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
|
@ -29,7 +30,7 @@ public class TimeOfferController {
|
|||
this.timeOfferService = timeOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkIdentity(final int timeOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
@ -41,6 +42,15 @@ public class TimeOfferController {
|
|||
return res;
|
||||
}
|
||||
|
||||
private boolean checkOffer(final TimeOffer session, final TimeOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/time/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
TimeOffer timeOffer = new TimeOffer();
|
||||
|
@ -64,7 +74,7 @@ public class TimeOfferController {
|
|||
}
|
||||
}
|
||||
|
||||
@GetMapping(value ="/offers/time/{timeOfferId}/activate")
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/activate")
|
||||
public String activateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap modelMap) {
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
|
@ -73,13 +83,11 @@ public class TimeOfferController {
|
|||
timeOffer.setCode("TI-" + timeOfferId);
|
||||
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||
|
||||
|
||||
} else {
|
||||
modelMap.addAttribute("message", "You don't have access to this time offer");
|
||||
}
|
||||
return "redirect:/offers/time/" + timeOffer.getId();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/offers/time/{timeOfferId}")
|
||||
|
@ -90,35 +98,48 @@ public class TimeOfferController {
|
|||
model.put("timeOffer", timeOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
|
||||
return "offers/time/timeOffersShow";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||
|
||||
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
if (timeOffer.getStatus().equals(StatusOffer.inactive)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
model.addAttribute("timeOffer", timeOffer);
|
||||
request.getSession().setAttribute("idTime", timeOfferId);
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result, final ModelMap model) {
|
||||
|
||||
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
Integer id = (Integer) request.getSession().getAttribute("idTime");
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(id);
|
||||
if (!this.checkOffer(timeOffer, timeOfferEdit)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("timeOffer", timeOfferEdit);
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
BeanUtils.copyProperties(this.timeOfferService.findTimeOfferById(timeOfferEdit.getId()), timeOfferEdit,
|
||||
"start", "end", "init", "finish", "discount");
|
||||
this.timeOfferService.saveTimeOffer(timeOfferEdit);
|
||||
return "redirect:/offers/time/" + timeOfferEdit.getId();
|
||||
}
|
||||
|
@ -127,7 +148,7 @@ public class TimeOfferController {
|
|||
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/disable")
|
||||
public String disableTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
@ -139,7 +160,7 @@ public class TimeOfferController {
|
|||
|
||||
@PostMapping(value = "/offers/time/{timeOfferId}/disable")
|
||||
public String disableTimeOfferForm(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
@ -152,7 +173,6 @@ public class TimeOfferController {
|
|||
|
||||
return "redirect:/myOffers";
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Wa
|
|||
|
||||
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','admin','admin', TRUE );
|
||||
INSERT INTO authorities VALUES ('admin','admin');
|
||||
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','manoli','manoli', TRUE );
|
||||
|
||||
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','manoli','manoli', TRUE );
|
||||
INSERT INTO authorities VALUES ('manoli','client');
|
||||
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','david','david', TRUE );
|
||||
INSERT INTO authorities VALUES ('david','client');
|
||||
|
@ -32,8 +32,18 @@ INSERT INTO usuarios VALUES (4, 'Pepe', 'Lopez', '12456776V', 'C/Macarena', '690
|
|||
INSERT INTO clients (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (1,'bar manoli','manoli@gmail.com','C/Betis','10:00','22:00','608726190', 'description 1', 'code1', 'ESPAÑOLA','manoli');
|
||||
INSERT INTO clients (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (2,'bar david','david@gmail.com','C/Sevilla','09:30','22:00','608726190', 'description 2', 'code2', 'americana','david');
|
||||
|
||||
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'FO-1', 'inactive', 1, 'macarrones', 15);
|
||||
INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'T-1', 'active', 1, '12:00:00', '13:00:00', 10);
|
||||
INSERT INTO speed_offers(start, end, code, status, 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',1,5,25,10,15,15,10);
|
||||
INSERT INTO nu_offers(start, end, code, status, 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',1,15,25,10,15,5,10);
|
||||
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-08-14 12:00:00', '2021-08-15 12:00:00', 'FO-1', 'inactive', 1, 'macarrones', 15);
|
||||
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-08-15 12:00:00', '2021-08-16 12:00:00', 'FO-2', 'active', 1, 'macarrones con tomate', 10);
|
||||
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-08-16 12:00:00', '2021-08-17 12:00:00', null, 'hidden', 1, 'macarrones con queso', 5);
|
||||
|
||||
INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-08-14 12:00:00', '2021-08-15 12:00:00', 'T-1', 'inactive', 1, '12:00:00', '13:00:00', 5);
|
||||
INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-08-15 12:00:00', '2021-08-16 12:00:00', 'T-2', 'active', 1, '12:00:00', '13:00:00', 10);
|
||||
INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-08-16 12:00:00', '2021-08-17 12:00:00', null, 'hidden', 1, '12:00:00', '13:00:00', 15);
|
||||
|
||||
INSERT INTO speed_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-14 12:00:00', '2021-08-15 12:00:00', 'SP-1', 'inactive',1,5,25,10,15,15,10);
|
||||
INSERT INTO speed_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-15 12:00:00', '2021-08-16 12:00:00', 'SP-2', 'active',1,5,25,10,15,15,10);
|
||||
INSERT INTO speed_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-16 12:00:00', '2021-08-17 12:00:00', null, 'hidden',1,5,25,10,15,15,10);
|
||||
|
||||
INSERT INTO nu_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-14 12:00:00', '2021-08-15 12:00:00', 'NU-1', 'inactive',1,15,25,10,15,5,10);
|
||||
INSERT INTO nu_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-15 12:00:00', '2021-08-16 12:00:00', 'NU-2', 'active',1,15,25,10,15,5,10);
|
||||
INSERT INTO nu_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-16 12:00:00', '2021-08-17 12:00:00', null, 'hidden',1,15,25,10,15,5,10);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<h2>
|
||||
<c:if test="${foodOffer['new']}">Nueva </c:if> Oferta de plato específico
|
||||
</h2>
|
||||
|
||||
<form:form modelAttribute="foodOffer" class="form-horizontal" id="add-foodOffer-form">
|
||||
<div class="form-group has-feedback">
|
||||
<form:hidden path="id"/>
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
<h2> ¿Está seguro de que quiere eliminar su oferta? </h2>
|
||||
|
||||
<form:form modelAttribute="foodOffer" class="form-horizontal">
|
||||
<input type="hidden" name="food" value="${food_offer.food}" />
|
||||
<input type="hidden" name="discount" value="${food_offer.discount}" />
|
||||
|
||||
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
|
||||
</form:form>
|
||||
|
||||
|
|
|
@ -11,13 +11,6 @@
|
|||
<h2> ¿Está seguro de que quiere dar de baja su oferta? </h2>
|
||||
|
||||
<form:form modelAttribute="nuOffer" class="form-horizontal">
|
||||
<input type="hidden" name="gold" value="${nu_offer.gold}" />
|
||||
<input type="hidden" name="discountGold" value="${nu_offer.discount_gold}" />
|
||||
<input type="hidden" name="silver" value="${nu_offer.silver}" />
|
||||
<input type="hidden" name="discountSilver" value="${nu_offer.discount_silver}" />
|
||||
<input type="hidden" name="bronze" value="${nu_offer.bronze}" />
|
||||
<input type="hidden" name="discountBronze" value="${nu_offer.discount_bronze}" />
|
||||
|
||||
<button class="btn btn-default" type="submit">Dar de baja</button>
|
||||
</form:form>
|
||||
|
||||
|
|
|
@ -11,13 +11,6 @@
|
|||
<h2> ¿Está seguro de que quiere dar de baja su oferta? </h2>
|
||||
|
||||
<form:form modelAttribute="speedOffer" class="form-horizontal">
|
||||
<input type="hidden" name="gold" value="${nu_offer.gold}" />
|
||||
<input type="hidden" name="discountGold" value="${nu_offer.discount_gold}" />
|
||||
<input type="hidden" name="silver" value="${nu_offer.silver}" />
|
||||
<input type="hidden" name="discountSilver" value="${nu_offer.discount_silver}" />
|
||||
<input type="hidden" name="bronze" value="${nu_offer.bronze}" />
|
||||
<input type="hidden" name="discountBronze" value="${nu_offer.discount_bronze}" />
|
||||
|
||||
<button class="btn btn-default" type="submit">Dar de baja</button>
|
||||
</form:form>
|
||||
|
||||
|
|
|
@ -11,10 +11,6 @@
|
|||
<h2> ¿Está seguro de que quiere eliminar su oferta? </h2>
|
||||
|
||||
<form:form modelAttribute="foodOffer" class="form-horizontal">
|
||||
<input type="hidden" name="init" value="${time_offer.init}" />
|
||||
<input type="hidden" name="finish" value="${time_offer.finish}" />
|
||||
<input type="hidden" name="discount" value="${time_offer.discount}" />
|
||||
|
||||
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
|
||||
</form:form>
|
||||
|
||||
|
|
Loading…
Reference in a new issue