mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 07:45:49 +00:00
Merge branch '008-verOfertas' into loginfixed
This commit is contained in:
commit
49dd2a76f0
11 changed files with 224 additions and 37 deletions
|
@ -36,11 +36,8 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||
|
||||
http.authorizeRequests().antMatchers("/resources/**", "/webjars/**", "/h2-console/**").permitAll()
|
||||
.antMatchers(HttpMethod.GET, "/", "/oups").permitAll()
|
||||
.antMatchers("/users/new").permitAll()
|
||||
.antMatchers("/usuarios/new").permitAll()
|
||||
.antMatchers("/offers/**").permitAll()
|
||||
.antMatchers("/admin/**").hasAnyAuthority("admin")
|
||||
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
|
||||
.antMatchers("/clients/new").permitAll()
|
||||
.antMatchers("/offers/**").hasAnyAuthority("admin")
|
||||
.antMatchers("/vets/**").authenticated().anyRequest().denyAll()
|
||||
.and().formLogin()
|
||||
/* .loginPage("/login") */
|
||||
|
|
|
@ -6,5 +6,10 @@ import javax.persistence.Table;
|
|||
@Entity
|
||||
@Table(name = "administrators")
|
||||
public class Administrator extends User{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public class Client extends BaseEntity{
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// (id, email, address, init, finish, telephone, description, code, food, usuar)
|
||||
|
||||
@NotEmpty
|
||||
private String email;
|
||||
|
||||
|
|
|
@ -1,19 +1,8 @@
|
|||
package org.springframework.cheapy.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
|
@ -27,7 +16,12 @@ public class User{
|
|||
private String password;
|
||||
|
||||
boolean enabled;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public String getUsername() {
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.service.FoodOfferService;
|
||||
import org.springframework.cheapy.service.NuOfferService;
|
||||
import org.springframework.cheapy.service.SpeedOfferService;
|
||||
import org.springframework.cheapy.service.TimeOfferService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
* @author Michael Isvy
|
||||
*/
|
||||
@Controller
|
||||
public class FoodOfferController {
|
||||
|
||||
//private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";
|
||||
|
||||
private final FoodOfferService foodOfferService;
|
||||
|
||||
|
||||
|
||||
public FoodOfferController(final FoodOfferService foodOfferService) {
|
||||
this.foodOfferService = foodOfferService;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/offers/food/{foodOfferId}")
|
||||
public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map<String, Object> model) {
|
||||
|
||||
FoodOffer foodOffer=this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
|
||||
model.put("foodOffer", foodOffer);
|
||||
|
||||
return "foodOffers/foodOffersShow";
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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.util.Map;
|
||||
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.service.TimeOfferService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
* @author Michael Isvy
|
||||
*/
|
||||
@Controller
|
||||
public class TimeOfferController {
|
||||
|
||||
//private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";
|
||||
private final TimeOfferService timeOfferService;
|
||||
|
||||
public TimeOfferController(final TimeOfferService timeOfferService) {
|
||||
this.timeOfferService = timeOfferService;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/offers/time/{timeOfferId}")
|
||||
public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map<String, Object> model) {
|
||||
|
||||
TimeOffer timeOffer=this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
|
||||
model.put("timeOffer", timeOffer);
|
||||
|
||||
return "timeOffers/timeOffersShow";
|
||||
|
||||
}
|
||||
}
|
|
@ -16,12 +16,6 @@ INSERT INTO time_offers(start, end, code, type, client_id, init, finish, discoun
|
|||
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 usuarios(username, password, enabled) values ('admin3', 'admin', true);
|
||||
--insert into authorities(id ,usuario, authority) values (42,'admin3', 'admin');
|
||||
|
||||
--INSERT INTO users(username,password,enabled) VALUES ('admin1','4dm1n',TRUE);
|
||||
--INSERT INTO authorities(id,username,authority) VALUES (1,'admin1','admin');
|
||||
|
||||
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 );
|
||||
|
|
44
src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersShow.jsp
Normal file
44
src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersShow.jsp
Normal file
|
@ -0,0 +1,44 @@
|
|||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
<cheapy:layout pageName="foodOffer">
|
||||
|
||||
<h2>Oferta por plato específico</h2>
|
||||
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Inicio de la oferta</th>
|
||||
<td><b><c:out value="${foodOffer.start}"/></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Fin de la oferta</th>
|
||||
<td><c:out value="${foodOffer.end}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Plato en oferta</th>
|
||||
<td><c:out value="${foodOffer.food}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Descuento</th>
|
||||
<td><c:out value="${foodOffer.discount}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Cantidad</th>
|
||||
<td><c:out value="${foodOffer.units}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Codigo de la oferta</th>
|
||||
<td><c:out value="${foodOffer.code}"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a> --%>
|
||||
|
||||
</cheapy:layout>
|
|
@ -4,7 +4,7 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
<cheapy:layout pageName="timeOffer">
|
||||
<cheapy:layout pageName="nuOffer">
|
||||
|
||||
<h2>Oferta por número de comensales</h2>
|
||||
|
||||
|
|
|
@ -15,18 +15,12 @@
|
|||
<th style="width: 150px;">Plato</th>
|
||||
<th style="width: 150px;">Fecha inicio</th>
|
||||
<th style="width: 200px;">Fecha fin</th>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${foodOfferLs}" var="foodOffer">
|
||||
<tr>
|
||||
<%-- <td>
|
||||
<spring:url value="/offers/food/{offerId}" var="foodOfferUrl">
|
||||
<spring:param name="offerId" value="${foodOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(foodOfferUrl)}"><c:out value="${foodOffer.client.username}"/></a>
|
||||
</td> --%>
|
||||
<td>
|
||||
<c:out value="${foodOffer.food}"/>
|
||||
</td>
|
||||
|
@ -36,6 +30,12 @@
|
|||
<td>
|
||||
<c:out value="${foodOffer.end}"/>
|
||||
</td>
|
||||
<td>
|
||||
<spring:url value="/offers/food/{foodOfferId}" var="foodOfferUrl">
|
||||
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(foodOfferUrl)}"/>Enlace</a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</c:forEach>
|
||||
|
@ -115,11 +115,11 @@
|
|||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th style="width: 150px;">Fecha inicio</th>
|
||||
<th style="width: 200px;">Fecha fin</th>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${timeOfferLs}" var="timeOffer">
|
||||
<c:forEach items="${timeOfferLs}" var="timeOffer">
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
|
@ -128,12 +128,12 @@
|
|||
<td>
|
||||
<c:out value="${timeOffer.end}"/>
|
||||
</td>
|
||||
<%-- <td>
|
||||
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
|
||||
<td>
|
||||
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
|
||||
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(timeOfferUrl)}"><c:out value="${timeOffer.client.username}"/></a>
|
||||
</td> --%>
|
||||
<a href="${fn:escapeXml(timeOfferUrl)}"/>Enlace</a>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
|
|
31
src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersShow.jsp
Normal file
31
src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersShow.jsp
Normal file
|
@ -0,0 +1,31 @@
|
|||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
<cheapy:layout pageName="timeOffer">
|
||||
|
||||
<h2>Oferta por franja horária</h2>
|
||||
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Inicio de la oferta</th>
|
||||
<td><b><c:out value="${timeOffer.start}"/></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Fin de la oferta</th>
|
||||
<td><c:out value="${timeOffer.end}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Descuento</th>
|
||||
<td><c:out value="${timeOffer.discount}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Codigo de la oferta</th>
|
||||
<td><c:out value="${timeOffer.code}"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</cheapy:layout>
|
Loading…
Reference in a new issue