mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-24 00:05:48 +00:00
Merge branch '010-modf-seguridad' into 010-modf-Gabo
This commit is contained in:
commit
0917da055b
56 changed files with 1288 additions and 661 deletions
3
pom.xml
3
pom.xml
|
@ -135,7 +135,10 @@
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
@ -20,9 +20,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @author japarejo
|
|
||||||
*/
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||||
|
@ -37,20 +35,32 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||||
http.authorizeRequests().antMatchers("/resources/**", "/webjars/**", "/h2-console/**").permitAll()
|
http.authorizeRequests().antMatchers("/resources/**", "/webjars/**", "/h2-console/**").permitAll()
|
||||||
.antMatchers(HttpMethod.GET, "/", "/oups").permitAll()
|
.antMatchers(HttpMethod.GET, "/", "/oups").permitAll()
|
||||||
.antMatchers("/users/new").permitAll()
|
.antMatchers("/users/new").permitAll()
|
||||||
|
|
||||||
|
.antMatchers("/nuOffers/**").hasAnyAuthority("admin","client")
|
||||||
|
.antMatchers("/timeOffers/**").hasAnyAuthority("admin","client")
|
||||||
|
|
||||||
|
.antMatchers("/login/**").anonymous()
|
||||||
|
.antMatchers("/logout").permitAll()
|
||||||
|
|
||||||
.antMatchers("/usuarios/new").permitAll()
|
.antMatchers("/usuarios/new").permitAll()
|
||||||
.antMatchers("/offers/**").permitAll()
|
|
||||||
.antMatchers("/admin/**").hasAnyAuthority("admin")
|
.antMatchers("/admin/**").hasAnyAuthority("admin")
|
||||||
|
.antMatchers("/speedOffers/**").hasAnyAuthority("admin", "client")
|
||||||
|
.antMatchers("/foodOffers/**").hasAnyAuthority("admin", "client")
|
||||||
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
|
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
|
||||||
.antMatchers("/vets/**").authenticated().anyRequest().denyAll()
|
|
||||||
|
.antMatchers("/clients/new").permitAll()
|
||||||
|
.antMatchers("/offers/**").hasAnyAuthority("admin")
|
||||||
|
|
||||||
.and().formLogin()
|
.and().formLogin()
|
||||||
/* .loginPage("/login") */
|
.loginPage("/login").permitAll()
|
||||||
.failureUrl("/login-error").and().logout().logoutSuccessUrl("/");
|
.failureUrl("/login?error")
|
||||||
|
.and().logout().logoutSuccessUrl("/login");
|
||||||
|
|
||||||
// Configuración para que funcione la consola de administración
|
// Configuración para que funcione la consola de administración
|
||||||
// de la BD H2 (deshabilitar las cabeceras de protección contra
|
// de la BD H2 (deshabilitar las cabeceras de protección contra
|
||||||
// ataques de tipo csrf y habilitar los framesets si su contenido
|
// ataques de tipo csrf y habilitar los framesets si su contenido
|
||||||
// se sirve desde esta misma página.
|
// se sirve desde esta misma página.
|
||||||
http.csrf().ignoringAntMatchers("/h2-console/**");
|
//http.csrf().ignoringAntMatchers("/h2-console/**");
|
||||||
http.headers().frameOptions().sameOrigin();
|
http.headers().frameOptions().sameOrigin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,10 @@ import javax.persistence.Table;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "administrators")
|
@Table(name = "administrators")
|
||||||
public class Administrator extends User{
|
public class Administrator extends User{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +1,58 @@
|
||||||
package org.springframework.cheapy.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToOne;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "authorities")
|
@Table(name = "authorities")
|
||||||
public class Authorities extends BaseEntity{
|
public class Authorities{
|
||||||
|
|
||||||
|
@Id
|
||||||
|
String username;
|
||||||
|
|
||||||
/**
|
String authority;
|
||||||
*
|
|
||||||
*/
|
public String getUsername() {
|
||||||
private static final long serialVersionUID = 1L;
|
return username;
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "username")
|
|
||||||
private Usuario user;
|
|
||||||
|
|
||||||
@Size(min = 3, max = 50)
|
|
||||||
private String authority;
|
|
||||||
|
|
||||||
public Usuario getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
}
|
||||||
|
public void setUsername(String username) {
|
||||||
public void setUser(Usuario usern) {
|
this.username = username;
|
||||||
this.user = usern;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthority() {
|
public String getAuthority() {
|
||||||
return authority;
|
return authority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthority(String authority) {
|
public void setAuthority(String authority) {
|
||||||
this.authority = authority;
|
this.authority = authority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getSerialversionuid() {
|
|
||||||
return serialVersionUID;
|
// @ManyToOne
|
||||||
}
|
// @JoinColumn(name = "username")
|
||||||
|
// private Usuario user;
|
||||||
|
//
|
||||||
|
// @Size(min = 3, max = 50)
|
||||||
|
// private String authority;
|
||||||
|
//
|
||||||
|
// public Usuario getUser() {
|
||||||
|
// return user;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setUser(Usuario usern) {
|
||||||
|
// this.user = usern;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String getAuthority() {
|
||||||
|
// return authority;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setAuthority(String authority) {
|
||||||
|
// this.authority = authority;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static long getSerialversionuid() {
|
||||||
|
// return serialVersionUID;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,3 @@
|
||||||
/*
|
|
||||||
* 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.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -22,16 +7,14 @@ import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple JavaBean domain object with an id property. Used as a base class for objects
|
|
||||||
* needing this property.
|
|
||||||
*
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
*/
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public class BaseEntity implements Serializable {
|
public class BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
|
@ -2,24 +2,39 @@ package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.Digits;
|
import javax.validation.constraints.Digits;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "clients")
|
@Table(name = "clients")
|
||||||
public class Client extends User {
|
public class Client extends BaseEntity{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// (id, email, address, init, finish, telephone, description, code, food, usuar)
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
@NotEmpty
|
//@DateTimeFormat(pattern = "HH:mm")
|
||||||
private String timetable;
|
@NotBlank
|
||||||
|
private String init;
|
||||||
|
|
||||||
|
//@DateTimeFormat(pattern = "HH:mm")
|
||||||
|
@NotBlank
|
||||||
|
private String finish;
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
@Digits(fraction = 0, integer = 10)
|
@Digits(fraction = 0, integer = 10)
|
||||||
|
@ -34,6 +49,10 @@ public class Client extends User {
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String food;
|
private String food;
|
||||||
|
|
||||||
|
@OneToOne(cascade = CascadeType.ALL)
|
||||||
|
@JoinColumn(name = "username", referencedColumnName = "username")
|
||||||
|
private User usuar;
|
||||||
|
|
||||||
@OneToMany
|
@OneToMany
|
||||||
private Set<FoodOffer> foodOffers;
|
private Set<FoodOffer> foodOffers;
|
||||||
|
|
||||||
|
@ -46,6 +65,8 @@ public class Client extends User {
|
||||||
@OneToMany
|
@OneToMany
|
||||||
private Set<TimeOffer> timeOffers;
|
private Set<TimeOffer> timeOffers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
@ -62,12 +83,29 @@ public class Client extends User {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTimetable() {
|
|
||||||
return timetable;
|
public String getInit() {
|
||||||
|
return init;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimetable(String timetable) {
|
public void setInit(String init) {
|
||||||
this.timetable = timetable;
|
this.init = init;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFinish() {
|
||||||
|
return finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinish(String finish) {
|
||||||
|
this.finish = finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUsername() {
|
||||||
|
return usuar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(User username) {
|
||||||
|
this.usuar = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTelephone() {
|
public String getTelephone() {
|
||||||
|
@ -101,4 +139,37 @@ public class Client extends User {
|
||||||
public void setFood(String food) {
|
public void setFood(String food) {
|
||||||
this.food = food;
|
this.food = food;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<FoodOffer> getFoodOffers() {
|
||||||
|
return foodOffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFoodOffers(Set<FoodOffer> foodOffers) {
|
||||||
|
this.foodOffers = foodOffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<NuOffer> getNuOffers() {
|
||||||
|
return nuOffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNuOffers(Set<NuOffer> nuOffers) {
|
||||||
|
this.nuOffers = nuOffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<SpeedOffer> getSpeedOffers() {
|
||||||
|
return speedOffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpeedOffers(Set<SpeedOffer> speedOffers) {
|
||||||
|
this.speedOffers = speedOffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<TimeOffer> getTimeOffers() {
|
||||||
|
return timeOffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeOffers(Set<TimeOffer> timeOffers) {
|
||||||
|
this.timeOffers = timeOffers;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,18 +18,25 @@ package org.springframework.cheapy.model;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "food_offers")
|
@Table(name = "food_offers")
|
||||||
public class FoodOffer extends Offer {
|
public class FoodOffer extends Offer {
|
||||||
//Plato específico
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//Plato específico
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String food;
|
private String food;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String discount;
|
private String discount;
|
||||||
|
|
||||||
@NotBlank
|
@NotNull
|
||||||
private Integer units; // revisar
|
private Integer units; // revisar
|
||||||
|
|
||||||
public String getFood() {
|
public String getFood() {
|
||||||
|
|
|
@ -1,33 +1,16 @@
|
||||||
/*
|
|
||||||
* 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.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as
|
|
||||||
* a base class for objects needing these properties.
|
|
||||||
*
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
*/
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public class NamedEntity extends BaseEntity {
|
public class NamedEntity extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "name")
|
@Column(name = "name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,3 @@
|
||||||
/*
|
|
||||||
* 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.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
@ -28,6 +12,8 @@ import javax.validation.constraints.NotNull;
|
||||||
public class NuOffer extends Offer {
|
public class NuOffer extends Offer {
|
||||||
|
|
||||||
//Oferta por numero de comensales
|
//Oferta por numero de comensales
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(1)
|
@Min(1)
|
||||||
private Integer gold;
|
private Integer gold;
|
||||||
|
|
|
@ -17,22 +17,25 @@ package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
import javax.persistence.Enumerated;
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.Table;
|
|
||||||
import javax.validation.constraints.Future;
|
import javax.validation.constraints.Future;
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public class Offer extends BaseEntity {
|
public class Offer extends BaseEntity {
|
||||||
//Clase padre
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//Clase padre
|
||||||
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
||||||
@NotNull
|
@NotNull
|
||||||
@Future
|
@Future
|
||||||
|
@ -43,12 +46,13 @@ public class Offer extends BaseEntity {
|
||||||
@Future
|
@Future
|
||||||
private LocalDateTime end;
|
private LocalDateTime end;
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@Enumerated(value = EnumType.STRING)
|
@Enumerated(value = EnumType.STRING)
|
||||||
private StatusOffer type;
|
private StatusOffer type;
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name="client_id")
|
@JoinColumn(name="client_id")
|
||||||
private Client client;
|
private Client client;
|
||||||
|
@ -84,5 +88,13 @@ public class Offer extends BaseEntity {
|
||||||
public void setType(StatusOffer type) {
|
public void setType(StatusOffer type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Client getClient() {
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClient(Client client) {
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +1,22 @@
|
||||||
/*
|
|
||||||
* 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.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.Digits;
|
import javax.validation.constraints.Digits;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
import org.springframework.beans.support.MutableSortDefinition;
|
|
||||||
import org.springframework.beans.support.PropertyComparator;
|
|
||||||
import org.springframework.core.style.ToStringCreator;
|
import org.springframework.core.style.ToStringCreator;
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple JavaBean domain object representing an owner.
|
|
||||||
*
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Sam Brannen
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "owners")
|
@Table(name = "owners")
|
||||||
public class Owner extends Person {
|
public class Owner extends Person {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "address")
|
@Column(name = "address")
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String address;
|
private String address;
|
||||||
|
|
|
@ -1,32 +1,17 @@
|
||||||
/*
|
|
||||||
* 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.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple JavaBean domain object representing an person.
|
|
||||||
*
|
|
||||||
* @author Ken Krebs
|
|
||||||
*/
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public class Person extends BaseEntity {
|
public class Person extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "first_name")
|
@Column(name = "first_name")
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String firstName;
|
private String firstName;
|
||||||
|
|
|
@ -1,19 +1,3 @@
|
||||||
/*
|
|
||||||
* 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.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
@ -28,6 +12,8 @@ import javax.validation.constraints.NotNull;
|
||||||
public class SpeedOffer extends Offer {
|
public class SpeedOffer extends Offer {
|
||||||
|
|
||||||
//Ofertar por rapidez comiendo
|
//Ofertar por rapidez comiendo
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(0)
|
@Min(0)
|
||||||
private Integer gold; // x minutos
|
private Integer gold; // x minutos
|
||||||
|
|
|
@ -1,46 +1,50 @@
|
||||||
/*
|
|
||||||
* 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.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.Future;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "time_offers")
|
@Table(name = "time_offers")
|
||||||
public class TimeOffer extends Offer {
|
public class TimeOffer extends Offer {
|
||||||
//Oferta por franja horaria
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//Oferta por franja horaria
|
||||||
@DateTimeFormat(pattern = "HH:mm")
|
@DateTimeFormat(pattern = "HH:mm")
|
||||||
@NotBlank
|
@NotNull
|
||||||
private LocalTime init;
|
private LocalTime init;
|
||||||
|
|
||||||
@DateTimeFormat(pattern = "HH:mm")
|
@DateTimeFormat(pattern = "HH:mm")
|
||||||
@NotBlank
|
@NotNull
|
||||||
private LocalTime finish;
|
private LocalTime finish;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String discount;
|
private String discount;
|
||||||
|
|
||||||
|
public LocalTime getInit() {
|
||||||
|
return init;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInit(LocalTime init) {
|
||||||
|
this.init = init;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalTime getFinish() {
|
||||||
|
return finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinish(LocalTime finish) {
|
||||||
|
this.finish = finish;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDiscount() {
|
public String getDiscount() {
|
||||||
return discount;
|
return discount;
|
||||||
|
|
|
@ -1,23 +1,13 @@
|
||||||
package org.springframework.cheapy.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.MappedSuperclass;
|
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.OneToOne;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.Email;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
//@Entity
|
@Table(name = "users")
|
||||||
//@Table(name = "users")
|
//@MappedSuperclass
|
||||||
@MappedSuperclass
|
|
||||||
public class User{
|
public class User{
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@ -27,7 +17,12 @@ public class User{
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
boolean enabled;
|
boolean enabled;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
|
@ -46,11 +41,4 @@ public class User{
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Set<Authorities> getAuthority() {
|
|
||||||
// return authorities;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setAuthorities(Set<Authorities> authorities) {
|
|
||||||
// this.authorities = authorities;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,101 @@
|
||||||
package org.springframework.cheapy.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.Email;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "users")
|
@Table(name = "usuarios")
|
||||||
public class Usuario extends User{
|
public class Usuario extends BaseEntity{
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
|
/** nombre, apellidos, dni, direccion, telefono, email, username
|
||||||
private Set<Authorities> authorities;
|
* (id,nombre, apellidos, dni, direccion, telefono, email, usuar)
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public Set<Authorities> getAuthorities() {
|
@NotBlank
|
||||||
return authorities;
|
private String nombre;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String apellidos;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String dni;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String direccion;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
//@Pattern(regexp = "([+][^0][\\d]{0,2})?[ ]?([(][\\d]{0,4}[)])?[ ]?([\\d]{6,10})$")
|
||||||
|
private String telefono;
|
||||||
|
|
||||||
|
@Email
|
||||||
|
@NotBlank
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@OneToOne(cascade = CascadeType.ALL)
|
||||||
|
@JoinColumn(name = "username", referencedColumnName = "username")
|
||||||
|
private User usuar;
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthorities(Set<Authorities> authorities) {
|
public void setNombre(String nombre) {
|
||||||
this.authorities = authorities;
|
this.nombre = nombre;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getApellidos() {
|
||||||
|
return apellidos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApellidos(String apellidos) {
|
||||||
|
this.apellidos = apellidos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDni() {
|
||||||
|
return dni;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDni(String dni) {
|
||||||
|
this.dni = dni;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDireccion() {
|
||||||
|
return direccion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDireccion(String direccion) {
|
||||||
|
this.direccion = direccion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTelefono() {
|
||||||
|
return telefono;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTelefono(String telefono) {
|
||||||
|
this.telefono = telefono;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return usuar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User username) {
|
||||||
|
this.usuar = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The classes in this package represent utilities used by the domain.
|
|
||||||
*/
|
|
||||||
package org.springframework.cheapy.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
|
@ -2,8 +2,6 @@ package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import org.springframework.cheapy.model.Authorities;
|
import org.springframework.cheapy.model.Authorities;
|
||||||
import org.springframework.cheapy.model.User;
|
|
||||||
|
|
||||||
|
|
||||||
public interface AuthoritiesRepository extends CrudRepository<Authorities, Integer>{
|
public interface AuthoritiesRepository extends CrudRepository<Authorities, Integer>{
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
public interface ClientRepository extends CrudRepository<Client, String> {
|
||||||
|
|
||||||
|
@Query("SELECT client FROM Client client WHERE username =:username")
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
Client findByUsername(String username);
|
||||||
|
|
||||||
|
}
|
|
@ -1,67 +1,22 @@
|
||||||
/*
|
|
||||||
* 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.repository;
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.cheapy.model.FoodOffer;
|
import org.springframework.cheapy.model.FoodOffer;
|
||||||
import org.springframework.cheapy.model.Owner;
|
import java.util.List;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.Repository;
|
import org.springframework.data.repository.Repository;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
|
||||||
* Repository class for <code>Owner</code> domain objects All method names are compliant
|
|
||||||
* with Spring Data naming conventions so this interface can easily be extended for Spring
|
|
||||||
* Data. See:
|
|
||||||
* https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods.query-creation
|
|
||||||
*
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Sam Brannen
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
public interface FoodOfferRepository extends Repository<FoodOffer, Integer> {
|
public interface FoodOfferRepository extends Repository<FoodOffer, Integer> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve {@link Owner}s from the data store by last name, returning all owners
|
|
||||||
* whose last name <i>starts</i> with the given name.
|
|
||||||
* @param lastName Value to search for
|
|
||||||
* @return a Collection of matching {@link Owner}s (or an empty Collection if none
|
|
||||||
* found)
|
|
||||||
*/
|
|
||||||
@Query("SELECT foodOffer FROM FoodOffer foodOffer")
|
@Query("SELECT foodOffer FROM FoodOffer foodOffer")
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
List<FoodOffer> findAllFoodOffer();
|
List<FoodOffer> findAllFoodOffer();
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve an {@link Owner} from the data store by id.
|
|
||||||
* @param id the id to search for
|
|
||||||
* @return the {@link Owner} if found
|
|
||||||
*/
|
|
||||||
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE id =:id")
|
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE id =:id")
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
FoodOffer findById(@Param("id") Integer id);
|
FoodOffer findById(@Param("id") Integer id);
|
||||||
|
|
||||||
/**
|
|
||||||
* Save an {@link Owner} to the data store, either inserting or updating it.
|
|
||||||
* @param owner the {@link Owner} to save
|
|
||||||
*/
|
|
||||||
void save(FoodOffer foodOffer);
|
void save(FoodOffer foodOffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,68 +1,19 @@
|
||||||
/*
|
|
||||||
* 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.repository;
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.cheapy.model.FoodOffer;
|
|
||||||
import org.springframework.cheapy.model.NuOffer;
|
import org.springframework.cheapy.model.NuOffer;
|
||||||
import org.springframework.cheapy.model.Owner;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.Repository;
|
import org.springframework.data.repository.Repository;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
|
||||||
* Repository class for <code>Owner</code> domain objects All method names are compliant
|
|
||||||
* with Spring Data naming conventions so this interface can easily be extended for Spring
|
|
||||||
* Data. See:
|
|
||||||
* https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods.query-creation
|
|
||||||
*
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Sam Brannen
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
public interface NuOfferRepository extends Repository<NuOffer, Integer> {
|
public interface NuOfferRepository extends Repository<NuOffer, Integer> {
|
||||||
|
|
||||||
/**
|
NuOffer findNuOfferById(int nuOfferId);
|
||||||
* Retrieve {@link Owner}s from the data store by last name, returning all owners
|
|
||||||
* whose last name <i>starts</i> with the given name.
|
|
||||||
* @param lastName Value to search for
|
|
||||||
* @return a Collection of matching {@link Owner}s (or an empty Collection if none
|
|
||||||
* found)
|
|
||||||
*/
|
|
||||||
@Query("SELECT nuOffer FROM NuOffer nuOffer")
|
@Query("SELECT nuOffer FROM NuOffer nuOffer")
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
List<NuOffer> findAllNuOffer();
|
List<NuOffer> findAllNuOffer();
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve an {@link Owner} from the data store by id.
|
|
||||||
* @param id the id to search for
|
|
||||||
* @return the {@link Owner} if found
|
|
||||||
*/
|
|
||||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE id =:id")
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
NuOffer findById(@Param("id") Integer id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save an {@link Owner} to the data store, either inserting or updating it.
|
|
||||||
* @param owner the {@link Owner} to save
|
|
||||||
*/
|
|
||||||
void save(NuOffer nuOffer);
|
void save(NuOffer nuOffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,68 +1,22 @@
|
||||||
/*
|
|
||||||
* 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.repository;
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.cheapy.model.FoodOffer;
|
|
||||||
import org.springframework.cheapy.model.Owner;
|
|
||||||
import org.springframework.cheapy.model.SpeedOffer;
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.Repository;
|
import org.springframework.data.repository.Repository;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
|
||||||
* Repository class for <code>Owner</code> domain objects All method names are compliant
|
|
||||||
* with Spring Data naming conventions so this interface can easily be extended for Spring
|
|
||||||
* Data. See:
|
|
||||||
* https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods.query-creation
|
|
||||||
*
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Sam Brannen
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
public interface SpeedOfferRepository extends Repository<SpeedOffer, Integer> {
|
public interface SpeedOfferRepository extends Repository<SpeedOffer, Integer> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve {@link Owner}s from the data store by last name, returning all owners
|
|
||||||
* whose last name <i>starts</i> with the given name.
|
|
||||||
* @param lastName Value to search for
|
|
||||||
* @return a Collection of matching {@link Owner}s (or an empty Collection if none
|
|
||||||
* found)
|
|
||||||
*/
|
|
||||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer")
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
List<SpeedOffer> findAllSpeedOffer();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve an {@link Owner} from the data store by id.
|
|
||||||
* @param id the id to search for
|
|
||||||
* @return the {@link Owner} if found
|
|
||||||
*/
|
|
||||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE id =:id")
|
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE id =:id")
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
SpeedOffer findById(@Param("id") Integer id);
|
SpeedOffer findById(@Param("id") Integer id);
|
||||||
|
|
||||||
/**
|
@Query("SELECT speedOffer FROM SpeedOffer speedOffer")
|
||||||
* Save an {@link Owner} to the data store, either inserting or updating it.
|
@Transactional(readOnly = true)
|
||||||
* @param owner the {@link Owner} to save
|
List<SpeedOffer> findAllSpeedOffer();
|
||||||
*/
|
|
||||||
void save(SpeedOffer speedOffer);
|
void save(SpeedOffer speedOffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,68 +1,19 @@
|
||||||
/*
|
|
||||||
* 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.repository;
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.cheapy.model.FoodOffer;
|
|
||||||
import org.springframework.cheapy.model.Owner;
|
|
||||||
import org.springframework.cheapy.model.TimeOffer;
|
import org.springframework.cheapy.model.TimeOffer;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.Repository;
|
import org.springframework.data.repository.Repository;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
|
||||||
* Repository class for <code>Owner</code> domain objects All method names are compliant
|
|
||||||
* with Spring Data naming conventions so this interface can easily be extended for Spring
|
|
||||||
* Data. See:
|
|
||||||
* https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods.query-creation
|
|
||||||
*
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Sam Brannen
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
public interface TimeOfferRepository extends Repository<TimeOffer, Integer> {
|
public interface TimeOfferRepository extends Repository<TimeOffer, Integer> {
|
||||||
|
|
||||||
/**
|
TimeOffer findTimeOfferById(int timeOfferId);
|
||||||
* Retrieve {@link Owner}s from the data store by last name, returning all owners
|
|
||||||
* whose last name <i>starts</i> with the given name.
|
|
||||||
* @param lastName Value to search for
|
|
||||||
* @return a Collection of matching {@link Owner}s (or an empty Collection if none
|
|
||||||
* found)
|
|
||||||
*/
|
|
||||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer")
|
@Query("SELECT timeOffer FROM TimeOffer timeOffer")
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
List<TimeOffer> findAllTimeOffer();
|
List<TimeOffer> findAllTimeOffer();
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve an {@link Owner} from the data store by id.
|
|
||||||
* @param id the id to search for
|
|
||||||
* @return the {@link Owner} if found
|
|
||||||
*/
|
|
||||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE id =:id")
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
TimeOffer findById(@Param("id") Integer id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save an {@link Owner} to the data store, either inserting or updating it.
|
|
||||||
* @param owner the {@link Owner} to save
|
|
||||||
*/
|
|
||||||
void save(TimeOffer timeOffer);
|
void save(TimeOffer timeOffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
package org.springframework.cheapy.repository;
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import org.springframework.cheapy.model.User;
|
|
||||||
import org.springframework.cheapy.model.Usuario;
|
import org.springframework.cheapy.model.Usuario;
|
||||||
|
|
||||||
public interface UsuarioRepository extends CrudRepository<Usuario, String> {
|
public interface UsuarioRepository extends CrudRepository<Usuario, String> {
|
||||||
|
|
||||||
Usuario findByUsername(String currentPrincipalName);
|
//Usuario findByUsername(String currentPrincipalName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.springframework.cheapy.service;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.repository.ClientRepository;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ClientService {
|
||||||
|
|
||||||
|
private ClientRepository clientRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ClientService(final ClientRepository clientRepository) {
|
||||||
|
this.clientRepository = clientRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Client getCurrentClient() throws DataAccessException {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
String username = authentication.getName();
|
||||||
|
return this.clientRepository.findByUsername(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,21 +1,17 @@
|
||||||
package org.springframework.cheapy.service;
|
package org.springframework.cheapy.service;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cheapy.model.FoodOffer;
|
import org.springframework.cheapy.model.FoodOffer;
|
||||||
import org.springframework.cheapy.model.Owner;
|
|
||||||
import org.springframework.cheapy.repository.FoodOfferRepository;
|
import org.springframework.cheapy.repository.FoodOfferRepository;
|
||||||
import org.springframework.cheapy.repository.OwnerRepository;
|
import java.util.List;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FoodOfferService {
|
public class FoodOfferService {
|
||||||
|
|
||||||
private FoodOfferRepository foodOfferRepository;
|
private FoodOfferRepository foodOfferRepository;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public FoodOfferService(final FoodOfferRepository foodOfferRepository) {
|
public FoodOfferService(final FoodOfferRepository foodOfferRepository) {
|
||||||
this.foodOfferRepository = foodOfferRepository;
|
this.foodOfferRepository = foodOfferRepository;
|
||||||
|
@ -24,13 +20,11 @@ public class FoodOfferService {
|
||||||
public FoodOffer findFoodOfferById(final int id) {
|
public FoodOffer findFoodOfferById(final int id) {
|
||||||
return this.foodOfferRepository.findById(id);
|
return this.foodOfferRepository.findById(id);
|
||||||
}
|
}
|
||||||
|
public List<FoodOffer> findAllFoodOffer() { //
|
||||||
public List<FoodOffer> findAllFoodOffer() { //
|
|
||||||
return this.foodOfferRepository.findAllFoodOffer();
|
return this.foodOfferRepository.findAllFoodOffer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveOwner(final FoodOffer foodOffer) throws DataAccessException { //
|
public void saveFoodOffer(final FoodOffer foodOffer) throws DataAccessException {
|
||||||
this.foodOfferRepository.save(foodOffer);
|
this.foodOfferRepository.save(foodOffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
package org.springframework.cheapy.service;
|
package org.springframework.cheapy.service;
|
||||||
|
|
||||||
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.repository.NuOfferRepository;
|
import org.springframework.cheapy.repository.NuOfferRepository;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
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;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -23,7 +23,7 @@ public class NuOfferService {
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public NuOffer findNuOfferById(final int id) {
|
public NuOffer findNuOfferById(final int id) {
|
||||||
return this.nuOfferRepository.findById(id);
|
return this.nuOfferRepository.findNuOfferById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
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.SpeedOffer;
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
import org.springframework.cheapy.repository.SpeedOfferRepository;
|
import org.springframework.cheapy.repository.SpeedOfferRepository;
|
||||||
|
@ -25,7 +25,7 @@ public class SpeedOfferService {
|
||||||
public SpeedOffer findSpeedOfferById(final int id) {
|
public SpeedOffer findSpeedOfferById(final int id) {
|
||||||
return this.speedOfferRepository.findById(id);
|
return this.speedOfferRepository.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<SpeedOffer> findAllSpeedOffer() { //
|
public List<SpeedOffer> findAllSpeedOffer() { //
|
||||||
return this.speedOfferRepository.findAllSpeedOffer();
|
return this.speedOfferRepository.findAllSpeedOffer();
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
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.TimeOffer;
|
import org.springframework.cheapy.model.TimeOffer;
|
||||||
import org.springframework.cheapy.model.Owner;
|
|
||||||
import org.springframework.cheapy.repository.TimeOfferRepository;
|
import org.springframework.cheapy.repository.TimeOfferRepository;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -17,21 +15,22 @@ public class TimeOfferService {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public TimeOfferService(final TimeOfferRepository timeOfferRepository) {
|
public TimeOfferService(final TimeOfferRepository TimeOfferRepository) {
|
||||||
this.timeOfferRepository = timeOfferRepository;
|
this.timeOfferRepository = TimeOfferRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeOffer findTimeOfferById(final int id) {
|
public TimeOffer findTimeOfferById(final int id) {
|
||||||
return this.timeOfferRepository.findById(id);
|
return this.timeOfferRepository.findTimeOfferById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimeOffer> findAllTimeOffer() { //
|
public List<TimeOffer> findAllTimeOffer() {
|
||||||
return this.timeOfferRepository.findAllTimeOffer();
|
return this.timeOfferRepository.findAllTimeOffer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void saveOwner(final TimeOffer timeOffer) throws DataAccessException { //
|
public void saveTimeOffer(final TimeOffer TimeOffer) throws DataAccessException {
|
||||||
this.timeOfferRepository.save(timeOffer);
|
this.timeOfferRepository.save(TimeOffer);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* 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.system;
|
||||||
|
|
||||||
|
import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
class LoginController {
|
||||||
|
|
||||||
|
@GetMapping("/login")
|
||||||
|
public String login() {
|
||||||
|
Authentication authentication= SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
if(authentication==null || authentication instanceof AnonymousAuthenticationToken) {
|
||||||
|
return "login";
|
||||||
|
}
|
||||||
|
return "redirect:/";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -27,4 +27,6 @@ class WelcomeController {
|
||||||
return "welcome";
|
return "welcome";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.model.FoodOffer;
|
||||||
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
|
import org.springframework.cheapy.service.FoodOfferService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class FoodOfferController {
|
||||||
|
|
||||||
|
private static final String VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM = "foodOffers/createOrUpdateFoodOfferForm";
|
||||||
|
|
||||||
|
private final FoodOfferService foodOfferService;
|
||||||
|
private final ClientService clientService;
|
||||||
|
|
||||||
|
|
||||||
|
public FoodOfferController(final FoodOfferService foodOfferService, final ClientService clientService) {
|
||||||
|
this.foodOfferService = foodOfferService;
|
||||||
|
this.clientService = clientService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@InitBinder
|
||||||
|
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||||
|
dataBinder.setDisallowedFields("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/foodOffers/new")
|
||||||
|
public String initCreationForm(Map<String, Object> model) {
|
||||||
|
FoodOffer foodOffer = new FoodOffer();
|
||||||
|
model.put("foodOffer", foodOffer);
|
||||||
|
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/foodOffers/new")
|
||||||
|
public String processCreationForm(@Valid FoodOffer foodOffer, BindingResult result) {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
foodOffer.setClient(client);
|
||||||
|
foodOffer.setType(StatusOffer.hidden);
|
||||||
|
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||||
|
return "redirect:/foodOffers/" + foodOffer.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/foodOffers/{foodOfferId}/activate")
|
||||||
|
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, ModelMap modelMap) {
|
||||||
|
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
if(foodOffer.getClient().equals(client)) {
|
||||||
|
foodOffer.setType(StatusOffer.active);
|
||||||
|
foodOffer.setCode("FO-"+foodOfferId);
|
||||||
|
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||||
|
} else {
|
||||||
|
modelMap.addAttribute("message", "You don't have access to this food offer");
|
||||||
|
}
|
||||||
|
return "redirect:/foodOffers/";
|
||||||
|
}
|
||||||
|
@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";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +1,3 @@
|
||||||
/*
|
|
||||||
* 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;
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
|
@ -21,25 +5,31 @@ 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.Owner;
|
||||||
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
import org.springframework.cheapy.model.StatusOffer;
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
import org.springframework.cheapy.service.FoodOfferService;
|
import org.springframework.cheapy.service.FoodOfferService;
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.model.NuOffer;
|
||||||
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
|
|
||||||
import org.springframework.cheapy.service.NuOfferService;
|
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.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Arjen Poutsma
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class NuOfferController {
|
public class NuOfferController {
|
||||||
|
|
||||||
|
@ -54,22 +44,71 @@ public class NuOfferController {
|
||||||
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.clientService = clientService;
|
||||||
this.timeOfferService = timeOfferService;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/offers/nu/{nuOfferId}")
|
@InitBinder
|
||||||
public String processShowForm(@PathVariable("nuOfferId") final int nuOfferId, final Map<String, Object> model) {
|
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||||
|
dataBinder.setDisallowedFields("id");
|
||||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
}
|
||||||
|
|
||||||
|
@InitBinder
|
||||||
|
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||||
|
dataBinder.setDisallowedFields("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/nuOffers/new")
|
||||||
|
public String initCreationForm(Map<String, Object> model) {
|
||||||
|
NuOffer nuOffer = new NuOffer();
|
||||||
model.put("nuOffer", nuOffer);
|
model.put("nuOffer", nuOffer);
|
||||||
|
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/nuOffers/new")
|
||||||
|
public String processCreationForm(@Valid NuOffer nuOffer, BindingResult result) {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nuOffer.setType(StatusOffer.hidden);
|
||||||
|
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
|
||||||
|
nuOffer.setClient(client);
|
||||||
|
|
||||||
|
|
||||||
|
this.nuOfferService.saveNuOffer(nuOffer);
|
||||||
|
return "redirect:/nuOffers/" + nuOffer.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@GetMapping(value ="/nuOffers/{nuOfferId}/activate")
|
||||||
|
public String activateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap modelMap) {
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId);
|
||||||
|
if(nuOffer.getClient().equals(client)) {
|
||||||
|
nuOffer.setType(StatusOffer.active);
|
||||||
|
nuOffer.setCode("NU-"+nuOfferId);
|
||||||
|
this.nuOfferService.saveNuOffer(nuOffer);
|
||||||
|
|
||||||
|
return "redirect:/nuOffers/" + nuOffer.getId();
|
||||||
|
} else {
|
||||||
|
modelMap.addAttribute("message", "You don't have access to this number offer");
|
||||||
|
}
|
||||||
|
return "redirect:/nuOffers/";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/offers/nu/{nuOfferId}")
|
||||||
|
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
|
||||||
|
|
||||||
|
model.put("nuOffer", nuOffer);
|
||||||
return "nuOffers/nuOffersShow";
|
return "nuOffers/nuOffersShow";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@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) {
|
||||||
|
|
||||||
|
@ -89,9 +128,8 @@ public class NuOfferController {
|
||||||
this.nuOfferService.saveNuOffer(nuOfferEdit);
|
this.nuOfferService.saveNuOffer(nuOfferEdit);
|
||||||
return "redirect:/offers/nu/" + nuOfferEdit.getId();
|
return "redirect:/offers/nu/" + nuOfferEdit.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
|
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||||
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,5 @@
|
||||||
/*
|
|
||||||
* 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;
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -28,38 +12,24 @@ import org.springframework.cheapy.service.NuOfferService;
|
||||||
import org.springframework.cheapy.service.SpeedOfferService;
|
import org.springframework.cheapy.service.SpeedOfferService;
|
||||||
import org.springframework.cheapy.service.TimeOfferService;
|
import org.springframework.cheapy.service.TimeOfferService;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Arjen Poutsma
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class OfertaController {
|
public class OfertaController {
|
||||||
|
|
||||||
//private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";
|
|
||||||
|
|
||||||
private final FoodOfferService foodOfferService;
|
private final FoodOfferService foodOfferService;
|
||||||
private final NuOfferService nuOfferService;
|
private final NuOfferService nuOfferService;
|
||||||
private final SpeedOfferService speedOfferService;
|
private final SpeedOfferService speedOfferService;
|
||||||
private final TimeOfferService timeOfferService;
|
private final TimeOfferService timeOfferService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public OfertaController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService,
|
public OfertaController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService,
|
||||||
final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
|
final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
|
||||||
this.foodOfferService = foodOfferService;
|
this.foodOfferService = foodOfferService;
|
||||||
this.nuOfferService = nuOfferService;
|
this.nuOfferService = nuOfferService;
|
||||||
this.speedOfferService = speedOfferService;
|
this.speedOfferService = speedOfferService;
|
||||||
this.timeOfferService = timeOfferService;
|
this.timeOfferService = timeOfferService;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/offers")
|
@GetMapping("/offers")
|
||||||
public String processFindForm( Map<String, Object> model) {
|
public String processFindForm( Map<String, Object> model) {
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,3 @@
|
||||||
/*
|
|
||||||
* 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;
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -21,7 +6,6 @@ import java.util.Map;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import org.springframework.cheapy.model.Owner;
|
import org.springframework.cheapy.model.Owner;
|
||||||
import org.springframework.cheapy.repository.OwnerRepository;
|
|
||||||
import org.springframework.cheapy.service.OwnerService;
|
import org.springframework.cheapy.service.OwnerService;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
@ -33,12 +17,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Arjen Poutsma
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class OwnerController {
|
public class OwnerController {
|
||||||
|
|
||||||
|
@ -137,5 +115,4 @@ public class OwnerController {
|
||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,6 @@
|
||||||
/*
|
|
||||||
* 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;
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -25,49 +10,79 @@ import org.springframework.cheapy.model.SpeedOffer;
|
||||||
import org.springframework.cheapy.model.StatusOffer;
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
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.model.Client;
|
||||||
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
import org.springframework.cheapy.service.SpeedOfferService;
|
import org.springframework.cheapy.service.SpeedOfferService;
|
||||||
import org.springframework.cheapy.service.TimeOfferService;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Arjen Poutsma
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class SpeedOfferController {
|
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 SpeedOfferService speedOfferService;
|
||||||
private final NuOfferService nuOfferService;
|
private final ClientService clientService;
|
||||||
private final SpeedOfferService speedOfferService;
|
|
||||||
private final TimeOfferService timeOfferService;
|
|
||||||
|
|
||||||
|
public SpeedOfferController(final SpeedOfferService speedOfferService, final ClientService clientService) {
|
||||||
public SpeedOfferController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService, final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
|
|
||||||
this.foodOfferService = foodOfferService;
|
|
||||||
this.nuOfferService = nuOfferService;
|
|
||||||
this.speedOfferService = speedOfferService;
|
this.speedOfferService = speedOfferService;
|
||||||
this.timeOfferService = timeOfferService;
|
this.clientService = clientService;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/offers/speed/{speedOfferId}")
|
@InitBinder
|
||||||
public String processShowForm(@PathVariable("speedOfferId") final int speedOfferId, final Map<String, Object> model) {
|
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||||
|
dataBinder.setDisallowedFields("id");
|
||||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
}
|
||||||
|
|
||||||
|
@GetMapping("/speedOffers/new")
|
||||||
|
public String initCreationForm(Map<String, Object> model) {
|
||||||
|
SpeedOffer speedOffer = new SpeedOffer();
|
||||||
model.put("speedOffer", speedOffer);
|
model.put("speedOffer", speedOffer);
|
||||||
|
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/speedOffers/new")
|
||||||
|
public String processCreationForm(@Valid SpeedOffer speedOffer, BindingResult result) {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
speedOffer.setClient(client);
|
||||||
|
speedOffer.setType(StatusOffer.hidden);
|
||||||
|
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||||
|
return "redirect:/speedOffers/" + speedOffer.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/speedOffers/{speedOfferId}/activate")
|
||||||
|
public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, ModelMap modelMap) {
|
||||||
|
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
if(speedOffer.getClient().equals(client)) {
|
||||||
|
speedOffer.setType(StatusOffer.active);
|
||||||
|
speedOffer.setCode("SP-"+speedOfferId);
|
||||||
|
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||||
|
} else {
|
||||||
|
modelMap.addAttribute("message", "You don't have access to this speed offer");
|
||||||
|
}
|
||||||
|
return "redirect:/speedOffers/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/offers/speed/{speedOfferId}")
|
||||||
|
public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map<String, Object> model) {
|
||||||
|
|
||||||
|
SpeedOffer speedOffer=this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||||
|
model.put("speedOffer", speedOffer);
|
||||||
return "speedOffers/speedOffersShow";
|
return "speedOffers/speedOffersShow";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||||
|
@ -131,5 +146,4 @@ public class SpeedOfferController {
|
||||||
return "redirect:";
|
return "redirect:";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.model.TimeOffer;
|
||||||
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
|
import org.springframework.cheapy.service.TimeOfferService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class TimeOfferController {
|
||||||
|
|
||||||
|
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "timeOffers/createOrUpdateTimeOfferForm";
|
||||||
|
|
||||||
|
private final TimeOfferService timeOfferService;
|
||||||
|
private final ClientService clientService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public TimeOfferController(final TimeOfferService timeOfferService,ClientService clientService) {
|
||||||
|
this.timeOfferService = timeOfferService;
|
||||||
|
this.clientService = clientService;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@InitBinder
|
||||||
|
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||||
|
dataBinder.setDisallowedFields("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/timeOffers/new")
|
||||||
|
public String initCreationForm(Map<String, Object> model) {
|
||||||
|
TimeOffer timeOffer = new TimeOffer();
|
||||||
|
model.put("timeOffer", timeOffer);
|
||||||
|
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/timeOffers/new")
|
||||||
|
public String processCreationForm(@Valid TimeOffer timeOffer, BindingResult result) {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
timeOffer.setType(StatusOffer.hidden);
|
||||||
|
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
|
||||||
|
timeOffer.setClient(client);
|
||||||
|
|
||||||
|
|
||||||
|
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||||
|
return "redirect:/TimeOffers/" + timeOffer.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@GetMapping(value ="/timeOffers/{timeOfferId}/activate")
|
||||||
|
public String activateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap modelMap) {
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
TimeOffer timeOffer=this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||||
|
if(timeOffer.getClient().equals(client)) {
|
||||||
|
timeOffer.setType(StatusOffer.active);
|
||||||
|
timeOffer.setCode("TI-"+timeOfferId);
|
||||||
|
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||||
|
|
||||||
|
return "redirect:/timeOffers/" + timeOffer.getId();
|
||||||
|
} else {
|
||||||
|
modelMap.addAttribute("message", "You don't have access to this time offer");
|
||||||
|
}
|
||||||
|
return "redirect:/timeOffers/";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -9,12 +9,29 @@ INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '
|
||||||
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
|
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
|
||||||
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 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 authorities VALUES ('manoli','cliente');
|
||||||
|
INSERT INTO users (dtype,username,password,enabled) VALUES ('user','david','david', TRUE );
|
||||||
|
INSERT INTO authorities VALUES ('david','cliente');
|
||||||
|
INSERT INTO users (dtype,username,password,enabled) VALUES ('user','paco','paco', TRUE );
|
||||||
|
INSERT INTO authorities VALUES ('paco','usuario');
|
||||||
|
INSERT INTO users (dtype,username,password,enabled) VALUES ('user','lolo','lolo', TRUE );
|
||||||
|
INSERT INTO authorities VALUES ('lolo','usuario');
|
||||||
|
INSERT INTO users (dtype,username,password,enabled) VALUES ('user','pepe','pepe', TRUE );
|
||||||
|
INSERT INTO authorities VALUES ('pepe','usuario');
|
||||||
|
|
||||||
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 usuarios VALUES (1, 'admin', 'admin', 'admin', 'C/admin', '000000000', 'admin@gmail.com','admin');
|
||||||
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 usuarios VALUES (2, 'Paco', 'Naranjo', '21154416G', 'C/Esperanza', '666973647', 'Paco@gmail.com','paco');
|
||||||
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 usuarios VALUES (3, 'Lolo', 'Lopez', '25486596L', 'C/Macarena', '690670547' ,'Lolo@gmail.com','lolo');
|
||||||
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 usuarios VALUES (4, 'Pepe', 'Lopez', '12456776V', 'C/Macarena', '690670547', 'Pepe@gmail.com','pepe');
|
||||||
|
|
||||||
INSERT INTO users(username,password,enabled) VALUES ('admin1','4dm1n',TRUE);
|
INSERT INTO clients VALUES (1,'manoli@gmail.com','C/Betis','10:00','22:00','608726190', 'description 1', 'code1', 'ESPAÑOLA','manoli');
|
||||||
INSERT INTO authorities(id,username,authority) VALUES (1,'admin1','admin');
|
INSERT INTO clients VALUES (2,'david@gmail.com','C/Sevilla','09:30','22:00','608726190', 'description 2', 'code2', 'americana','david');
|
||||||
|
|
||||||
|
INSERT INTO food_offers(start, end, code, type, client_id, food, discount, units) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'FO-1', 'active', null, 'macarrones', '15%', 10);
|
||||||
|
INSERT INTO time_offers(start, end, code, type, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'T-1', 'active', null, '12:00:00', '13:00:00', '10%');
|
||||||
|
INSERT INTO speed_offers(start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'SP-1', 'active', null,5,'25%',10,'15%',15,'10%' );
|
||||||
|
INSERT INTO nu_offers(start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'NU-1', 'active', null,15,'25%',10,'15%',5,'10%' );
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
|
<petclinic:layout pageName="foodOffers">
|
||||||
|
<h2>
|
||||||
|
<c:if test="${foodOffer['new']}">New </c:if> FoodOffer
|
||||||
|
</h2>
|
||||||
|
<form:form modelAttribute="foodOffer" class="form-horizontal" id="add-foodOffer-form">
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<petclinic:inputField label="Start Date" name="start"/>
|
||||||
|
<petclinic:inputField label="End Date" name="end"/>
|
||||||
|
<petclinic:inputField label="Food" name="food"/>
|
||||||
|
<petclinic:inputField label="Discount" name="discount"/>
|
||||||
|
<petclinic:inputField label="Units" name="units"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${foodOffer['new']}">
|
||||||
|
<button class="btn btn-default" type="submit">Add Food Offer</button>
|
||||||
|
</c:when>
|
||||||
|
</c:choose>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form:form>
|
||||||
|
</petclinic:layout>
|
24
src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersDisable.jsp
Normal file
24
src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersDisable.jsp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true"%>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||||
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||||
|
|
||||||
|
<petclinic:layout pageName="foodOffer">
|
||||||
|
|
||||||
|
<jsp:body>
|
||||||
|
<h2> ¿Esta 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}" />
|
||||||
|
<input type="hidden" name="units" value="${food_offer.units}" />
|
||||||
|
|
||||||
|
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
|
||||||
|
</form:form>
|
||||||
|
|
||||||
|
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||||
|
|
||||||
|
</jsp:body>
|
||||||
|
</petclinic:layout>
|
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>
|
302
src/main/webapp/WEB-INF/jsp/login.jsp
Normal file
302
src/main/webapp/WEB-INF/jsp/login.jsp
Normal file
|
@ -0,0 +1,302 @@
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||||
|
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<!-- %@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %-->
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: "montserratregular", sans-serif;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #92badd;
|
||||||
|
display:inline-block;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
display:inline-block;
|
||||||
|
margin: 40px 8px 10px 8px;
|
||||||
|
color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* STRUCTURE */
|
||||||
|
|
||||||
|
.wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#formContent {
|
||||||
|
-webkit-border-radius: 10px 10px 10px 10px;
|
||||||
|
border-radius: 10px 10px 10px 10px;
|
||||||
|
background: #fff;
|
||||||
|
padding: 30px;
|
||||||
|
width: 90%;
|
||||||
|
max-width: 450px;
|
||||||
|
position: relative;
|
||||||
|
padding: 0px;
|
||||||
|
-webkit-box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);
|
||||||
|
box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#formFooter {
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
border-top: 1px solid #dce8f1;
|
||||||
|
padding: 25px;
|
||||||
|
text-align: center;
|
||||||
|
-webkit-border-radius: 0 0 10px 10px;
|
||||||
|
border-radius: 0 0 10px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* TABS */
|
||||||
|
|
||||||
|
h2.inactive {
|
||||||
|
color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2.active {
|
||||||
|
color: #0d0d0d;
|
||||||
|
border-bottom: 2px solid #5fbae9;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* FORM TYPOGRAPHY*/
|
||||||
|
|
||||||
|
input[type=button], input[type=submit], input[type=reset] {
|
||||||
|
background-color: #56baed;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
padding: 15px 80px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 13px;
|
||||||
|
-webkit-box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4);
|
||||||
|
box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4);
|
||||||
|
-webkit-border-radius: 5px 5px 5px 5px;
|
||||||
|
border-radius: 5px 5px 5px 5px;
|
||||||
|
margin: 5px 20px 40px 20px;
|
||||||
|
-webkit-transition: all 0.3s ease-in-out;
|
||||||
|
-moz-transition: all 0.3s ease-in-out;
|
||||||
|
-ms-transition: all 0.3s ease-in-out;
|
||||||
|
-o-transition: all 0.3s ease-in-out;
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover {
|
||||||
|
background-color: #39ace7;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=button]:active, input[type=submit]:active, input[type=reset]:active {
|
||||||
|
-moz-transform: scale(0.95);
|
||||||
|
-webkit-transform: scale(0.95);
|
||||||
|
-o-transform: scale(0.95);
|
||||||
|
-ms-transform: scale(0.95);
|
||||||
|
transform: scale(0.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text], input[type=password] {
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
border: none;
|
||||||
|
color: #0d0d0d;
|
||||||
|
padding: 15px 32px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 5px;
|
||||||
|
width: 85%;
|
||||||
|
border: 2px solid #f6f6f6;
|
||||||
|
-webkit-transition: all 0.5s ease-in-out;
|
||||||
|
-moz-transition: all 0.5s ease-in-out;
|
||||||
|
-ms-transition: all 0.5s ease-in-out;
|
||||||
|
-o-transition: all 0.5s ease-in-out;
|
||||||
|
transition: all 0.5s ease-in-out;
|
||||||
|
-webkit-border-radius: 5px 5px 5px 5px;
|
||||||
|
border-radius: 5px 5px 5px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text]:focus {
|
||||||
|
background-color: #fff;
|
||||||
|
border-bottom: 2px solid #5fbae9;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text]:placeholder {
|
||||||
|
color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ANIMATIONS */
|
||||||
|
|
||||||
|
/* Simple CSS3 Fade-in-down Animation */
|
||||||
|
.fadeInDown {
|
||||||
|
-webkit-animation-name: fadeInDown;
|
||||||
|
animation-name: fadeInDown;
|
||||||
|
-webkit-animation-duration: 1s;
|
||||||
|
animation-duration: 1s;
|
||||||
|
-webkit-animation-fill-mode: both;
|
||||||
|
animation-fill-mode: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes fadeInDown {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
-webkit-transform: translate3d(0, -100%, 0);
|
||||||
|
transform: translate3d(0, -100%, 0);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
-webkit-transform: none;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeInDown {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
-webkit-transform: translate3d(0, -100%, 0);
|
||||||
|
transform: translate3d(0, -100%, 0);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
-webkit-transform: none;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Simple CSS3 Fade-in Animation */
|
||||||
|
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
|
||||||
|
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
|
||||||
|
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
|
||||||
|
|
||||||
|
.fadeIn {
|
||||||
|
opacity:0;
|
||||||
|
-webkit-animation:fadeIn ease-in 1;
|
||||||
|
-moz-animation:fadeIn ease-in 1;
|
||||||
|
animation:fadeIn ease-in 1;
|
||||||
|
|
||||||
|
-webkit-animation-fill-mode:forwards;
|
||||||
|
-moz-animation-fill-mode:forwards;
|
||||||
|
animation-fill-mode:forwards;
|
||||||
|
|
||||||
|
-webkit-animation-duration:1s;
|
||||||
|
-moz-animation-duration:1s;
|
||||||
|
animation-duration:1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fadeIn.first {
|
||||||
|
-webkit-animation-delay: 0.4s;
|
||||||
|
-moz-animation-delay: 0.4s;
|
||||||
|
animation-delay: 0.4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fadeIn.second {
|
||||||
|
-webkit-animation-delay: 0.6s;
|
||||||
|
-moz-animation-delay: 0.6s;
|
||||||
|
animation-delay: 0.6s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fadeIn.third {
|
||||||
|
-webkit-animation-delay: 0.8s;
|
||||||
|
-moz-animation-delay: 0.8s;
|
||||||
|
animation-delay: 0.8s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fadeIn.fourth {
|
||||||
|
-webkit-animation-delay: 1s;
|
||||||
|
-moz-animation-delay: 1s;
|
||||||
|
animation-delay: 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Simple CSS3 Fade-in Animation */
|
||||||
|
.underlineHover:after {
|
||||||
|
display: block;
|
||||||
|
left: 0;
|
||||||
|
bottom: -10px;
|
||||||
|
width: 0;
|
||||||
|
height: 2px;
|
||||||
|
background-color: #56baed;
|
||||||
|
content: "";
|
||||||
|
transition: width 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.underlineHover:hover {
|
||||||
|
color: #0d0d0d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.underlineHover:hover:after{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* OTHERS */
|
||||||
|
|
||||||
|
*:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#icon {
|
||||||
|
width:60%;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<cheapy:layout pageName="login">
|
||||||
|
|
||||||
|
<div class="wrapper fadeInDown">
|
||||||
|
<div id="formContent">
|
||||||
|
<!-- Tabs Titles -->
|
||||||
|
|
||||||
|
<!-- Icon -->
|
||||||
|
<div class="fadeIn first">
|
||||||
|
<img src="/resources/images/Logo Cheapy.png" id="icon" />
|
||||||
|
</div>
|
||||||
|
<div th:if="${param.error}">
|
||||||
|
<p class="text-danger"> Invalid username or password</p>
|
||||||
|
</div>
|
||||||
|
<!-- Login Form -->
|
||||||
|
<form class='form-signin' action="/login" method='POST'>
|
||||||
|
<input type="text" id="username" class="fadeIn second" name="username" placeholder="username" required autofocus>
|
||||||
|
<input type="password" id="password" class="fadeIn third" name="password" placeholder="password" required>
|
||||||
|
<sec:csrfInput />
|
||||||
|
<input type="submit" class="fadeIn fourth" value="Login">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Remind Passowrd -->
|
||||||
|
<div id="formFooter">
|
||||||
|
<a class="underlineHover" href="#">Forgot Password?</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</cheapy:layout>
|
|
@ -4,9 +4,9 @@
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
<cheapy:layout pageName="timeOffer">
|
<cheapy:layout pageName="nuOffer">
|
||||||
|
|
||||||
<h2>Oferta por número de comensales</h2>
|
<h2>Oferta por n<EFBFBD>mero de comensales</h2>
|
||||||
|
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
@ -49,8 +49,13 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<spring:url value="{nuOfferId}/edit" var="editUrl">
|
<spring:url value="{nuOfferId}/edit" var="editUrl">
|
||||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||||
</spring:url>
|
</spring:url>
|
||||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar ofeta</a>
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||||
|
|
||||||
|
<spring:url value="{nuOfferId}/disable" var="editUrl">
|
||||||
|
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactiva oferta</a>
|
||||||
|
|
||||||
</cheapy:layout>
|
</cheapy:layout>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
<cheapy:layout pageName="owners">
|
<cheapy:layout pageName="ofertas">
|
||||||
<h2>Ofertas por plato específico</h2>
|
<h2>Ofertas por plato específico</h2>
|
||||||
|
|
||||||
<table id="foodOfferTable" class="table table-striped">
|
<table id="foodOfferTable" class="table table-striped">
|
||||||
|
@ -15,18 +15,12 @@
|
||||||
<th style="width: 150px;">Plato</th>
|
<th style="width: 150px;">Plato</th>
|
||||||
<th style="width: 150px;">Fecha inicio</th>
|
<th style="width: 150px;">Fecha inicio</th>
|
||||||
<th style="width: 200px;">Fecha fin</th>
|
<th style="width: 200px;">Fecha fin</th>
|
||||||
|
<th> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<c:forEach items="${foodOfferLs}" var="foodOffer">
|
<c:forEach items="${foodOfferLs}" var="foodOffer">
|
||||||
<tr>
|
<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>
|
<td>
|
||||||
<c:out value="${foodOffer.food}"/>
|
<c:out value="${foodOffer.food}"/>
|
||||||
</td>
|
</td>
|
||||||
|
@ -36,6 +30,12 @@
|
||||||
<td>
|
<td>
|
||||||
<c:out value="${foodOffer.end}"/>
|
<c:out value="${foodOffer.end}"/>
|
||||||
</td>
|
</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>
|
</tr>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
|
@ -115,11 +115,11 @@
|
||||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||||
<th style="width: 150px;">Fecha inicio</th>
|
<th style="width: 150px;">Fecha inicio</th>
|
||||||
<th style="width: 200px;">Fecha fin</th>
|
<th style="width: 200px;">Fecha fin</th>
|
||||||
|
<th> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<c:forEach items="${timeOfferLs}" var="timeOffer">
|
<c:forEach items="${timeOfferLs}" var="timeOffer">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
@ -128,12 +128,12 @@
|
||||||
<td>
|
<td>
|
||||||
<c:out value="${timeOffer.end}"/>
|
<c:out value="${timeOffer.end}"/>
|
||||||
</td>
|
</td>
|
||||||
<%-- <td>
|
<td>
|
||||||
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
|
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
|
||||||
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||||
</spring:url>
|
</spring:url>
|
||||||
<a href="${fn:escapeXml(timeOfferUrl)}"><c:out value="${timeOffer.client.username}"/></a>
|
<a href="${fn:escapeXml(timeOfferUrl)}"/>Enlace</a>
|
||||||
</td> --%>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<cheapy:layout pageName="owners">
|
<cheapy:layout pageName="owners">
|
||||||
<h2>
|
<h2>
|
||||||
<c:if test="${owner['new']}">New </c:if> Owner
|
<c:if test="${owner['new']}">New </c:if> Owner
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
|
||||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
<%@ taglib prefix="sec"
|
<%@ taglib prefix="sec"
|
||||||
uri="http://www.springframework.org/security/tags"%>
|
uri="http://www.springframework.org/security/tags"%>
|
||||||
<!-- >%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%-->
|
<!-- >%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%-->
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<cheapy:layout pageName="owners">
|
<cheapy:layout pageName="owners">
|
||||||
|
|
||||||
<h2>Find Owners</h2>
|
<h2>Find Owners</h2>
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ 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="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<cheapy:layout pageName="owners">
|
<cheapy:layout pageName="owners">
|
||||||
|
|
||||||
<h2>Owner Information</h2>
|
<h2>Owner Information</h2>
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
|
||||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<cheapy:layout pageName="owners">
|
<cheapy:layout pageName="owners">
|
||||||
<h2>Owners</h2>
|
<h2>Owners</h2>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
|
<petclinic:layout pageName="TimeOffers">
|
||||||
|
<h2>
|
||||||
|
<c:if test="${timeOffer['new']}">New </c:if> TimeOffer
|
||||||
|
</h2>
|
||||||
|
<form:form modelAttribute="timeOffer" class="form-horizontal" id="add-timeOffer-form">
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<petclinic:inputField label="Fecha de inicio" name="start"/>
|
||||||
|
<petclinic:inputField label="Fecha de fin" name="end"/>
|
||||||
|
|
||||||
|
<petclinic:inputField label="Hora de inicio" name="init"/>
|
||||||
|
<petclinic:inputField label="Hora de final" name="finish"/>
|
||||||
|
<petclinic:inputField label="Decuento" name="discount"/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${timeOffer['new']}">
|
||||||
|
<button class="btn btn-default" type="submit">Add Offer</button>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
<button class="btn btn-default" type="submit">Update Offer</button>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form:form>
|
||||||
|
</petclinic:layout>
|
24
src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersDisable.jsp
Normal file
24
src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersDisable.jsp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true"%>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||||
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||||
|
|
||||||
|
<petclinic:layout pageName="foodOffer">
|
||||||
|
|
||||||
|
<jsp:body>
|
||||||
|
<h2> ¿Esta 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>
|
||||||
|
|
||||||
|
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||||
|
|
||||||
|
</jsp:body>
|
||||||
|
</petclinic:layout>
|
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>
|
|
@ -2,10 +2,9 @@
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<cheapy:layout pageName="owners">
|
<cheapy:layout pageName="owners">
|
||||||
<h2>
|
<h2>
|
||||||
<c:if test="${owner['new']}">New </c:if> Owner
|
<c:if test="${owner['new']}">New </c:if> Owner
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<!-- %@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %-->
|
<!-- %@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %-->
|
||||||
|
|
||||||
<cheapy:layout pageName="home">
|
<cheapy:layout pageName="home">
|
||||||
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 50px; color: rgb(0, 64, 128); padding:20px"><fmt:message key="welcome"/></h2>
|
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 60px; color: rgb(0, 64, 128); padding:30px"><fmt:message key="welcome"/></h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="img-home">
|
<div class="img-home">
|
||||||
|
@ -14,8 +14,8 @@
|
||||||
<img class="img-responsive" src="${cheapyImage}"/>
|
<img class="img-responsive" src="${cheapyImage}"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-home">
|
<div class="btn-home">
|
||||||
<button type="button"><span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"></span> Ver Ofertas</button>
|
<a href="/offers"><button type="button" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="margin-right:8px"></span>Ver Ofertas</button></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -41,11 +41,6 @@
|
||||||
</cheapy:menuItem>
|
</cheapy:menuItem>
|
||||||
|
|
||||||
|
|
||||||
<cheapy:menuItem active="${name eq 'login'}" url="/login"
|
|
||||||
title="login">
|
|
||||||
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
|
|
||||||
<span>Login</span>
|
|
||||||
</cheapy:menuItem>
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -74,10 +69,10 @@
|
||||||
<p class="text-left">
|
<p class="text-left">
|
||||||
<strong><sec:authentication property="name" /></strong>
|
<strong><sec:authentication property="name" /></strong>
|
||||||
</p>
|
</p>
|
||||||
<p class="text-left">
|
<form action="/logout" method=post>
|
||||||
<a href="<c:url value="/logout" />"
|
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
||||||
class="btn btn-primary btn-block btn-sm">Logout</a>
|
<input type="submit" value="logout">
|
||||||
</p>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
|
||||||
|
|
||||||
<%@ attribute name="active" required="true" rtexprvalue="true" %>
|
<%@ attribute name="active" required="true" rtexprvalue="true" %>
|
||||||
<%@ attribute name="url" required="true" rtexprvalue="true" %>
|
<%@ attribute name="url" required="true" rtexprvalue="true" %>
|
||||||
<%@ attribute name="title" required="false" rtexprvalue="true" %>
|
<%@ attribute name="title" required="false" rtexprvalue="true" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
|
|
||||||
<li class="${active ? 'active' : ''}">
|
<li class="${active ? 'active' : ''}">
|
||||||
<a href="<spring:url value="${url}" htmlEscape="true" />"
|
<a href="<spring:url value="${url}" htmlEscape="true" />"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* 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 static org.hamcrest.Matchers.hasProperty;
|
import static org.hamcrest.Matchers.hasProperty;
|
||||||
|
@ -40,10 +40,11 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||||
*
|
*
|
||||||
* @author Colin But
|
* @author Colin But
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
@WebMvcTest(OwnerController.class)
|
@WebMvcTest(OwnerController.class)
|
||||||
class OwnerControllerTests {
|
class OwnerControllerTests {
|
||||||
|
|
||||||
private static final int TEST_OWNER_ID = 1;
|
/*private static final int TEST_OWNER_ID = 1;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
@ -158,6 +159,4 @@ class OwnerControllerTests {
|
||||||
.andExpect(model().attribute("owner", hasProperty("city", is("Madison"))))
|
.andExpect(model().attribute("owner", hasProperty("city", is("Madison"))))
|
||||||
.andExpect(model().attribute("owner", hasProperty("telephone", is("6085551023"))))
|
.andExpect(model().attribute("owner", hasProperty("telephone", is("6085551023"))))
|
||||||
.andExpect(view().name("owners/ownerDetails"));
|
.andExpect(view().name("owners/ownerDetails"));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue