mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-24 00:05:48 +00:00
Merge branch 'develop' into travis
This commit is contained in:
commit
442f238c74
85 changed files with 3124 additions and 704 deletions
|
@ -1,12 +0,0 @@
|
||||||
mysql:
|
|
||||||
image: mysql:5.7
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
environment:
|
|
||||||
- MYSQL_ROOT_PASSWORD=
|
|
||||||
- MYSQL_ALLOW_EMPTY_PASSWORD=true
|
|
||||||
- MYSQL_USER=petclinic
|
|
||||||
- MYSQL_PASSWORD=petclinic
|
|
||||||
- MYSQL_DATABASE=petclinic
|
|
||||||
volumes:
|
|
||||||
- "./conf.d:/etc/mysql/conf.d:ro"
|
|
8
pom.xml
8
pom.xml
|
@ -69,6 +69,11 @@
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-taglibs</artifactId>
|
<artifactId>spring-security-taglibs</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
@ -135,7 +140,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,7 +20,7 @@ import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PetClinic Spring Boot Application.
|
* Cheapy Spring Boot Application.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
*
|
*
|
||||||
|
|
|
@ -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,19 +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("/login/**").anonymous()
|
||||||
|
.antMatchers("/logout").permitAll()
|
||||||
|
|
||||||
.antMatchers("/usuarios/new").permitAll()
|
.antMatchers("/usuarios/new").permitAll()
|
||||||
.antMatchers("/admin/**").hasAnyAuthority("admin")
|
.antMatchers("/admin/**").hasAnyAuthority("admin")
|
||||||
|
|
||||||
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
|
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
|
||||||
.antMatchers("/vets/**").authenticated().anyRequest().denyAll()
|
|
||||||
|
.antMatchers("/offers/**/new").hasAnyAuthority("admin", "client")
|
||||||
|
.antMatchers("/offers/**/activate").hasAnyAuthority("admin","client")
|
||||||
|
|
||||||
|
.antMatchers("/clients/new").permitAll()
|
||||||
|
.antMatchers("/offers/**").permitAll()
|
||||||
|
|
||||||
|
|
||||||
.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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +69,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||||
public void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
public void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.jdbcAuthentication().dataSource(this.dataSource)
|
auth.jdbcAuthentication().dataSource(this.dataSource)
|
||||||
//[login de admin,owner y vet] .usersByUsernameQuery("select username,password,enabled " + "from users " + "where username = ?")
|
//[login de admin,owner y vet] .usersByUsernameQuery("select username,password,enabled " + "from users " + "where username = ?")
|
||||||
.usersByUsernameQuery("select username, password, enabled from users where username=?").authoritiesByUsernameQuery("select username, authority " + "from authorities " + "where username = ?") //[login de tallerespaco]
|
.usersByUsernameQuery("select username, password, enabled from users where username=?").authoritiesByUsernameQuery("select username, authority " + "from authorities " + "where username = ?")
|
||||||
.passwordEncoder(this.passwordEncoder());
|
.passwordEncoder(this.passwordEncoder());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,41 @@ 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, name, email, address, init, finish, telephone, description, code, food,
|
||||||
|
// usuar)
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
private String name;
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
@NotEmpty
|
// Hora de apertura del local
|
||||||
private String timetable;
|
@NotBlank
|
||||||
|
private String init;
|
||||||
|
|
||||||
|
// Hora de cierre del local
|
||||||
|
@NotBlank
|
||||||
|
private String finish;
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
@Digits(fraction = 0, integer = 10)
|
@Digits(fraction = 0, integer = 10)
|
||||||
|
@ -28,32 +45,45 @@ public class Client extends User {
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
// Codigo de activacion de cuenta
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@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;
|
||||||
|
|
||||||
@OneToMany
|
@OneToMany
|
||||||
private Set<NuOffer> nuOffers;
|
private Set<NuOffer> nuOffers;
|
||||||
|
|
||||||
@OneToMany
|
@OneToMany
|
||||||
private Set<SpeedOffer> speedOffers;
|
private Set<SpeedOffer> speedOffers;
|
||||||
|
|
||||||
@OneToMany
|
@OneToMany
|
||||||
private Set<TimeOffer> timeOffers;
|
private Set<TimeOffer> timeOffers;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmail(String email) {
|
public void setEmail(String email) {
|
||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
@ -62,12 +92,20 @@ public class Client extends User {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTimetable() {
|
public String getInit() {
|
||||||
return timetable;
|
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 String getTelephone() {
|
public String getTelephone() {
|
||||||
|
@ -101,4 +139,45 @@ public class Client extends User {
|
||||||
public void setFood(String food) {
|
public void setFood(String food) {
|
||||||
this.food = food;
|
this.food = food;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User getUsuar() {
|
||||||
|
return usuar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsuar(User usuar) {
|
||||||
|
this.usuar = usuar;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,20 +17,23 @@ 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.Min;
|
||||||
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 {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//Plato específico
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String food;
|
private String food;
|
||||||
|
|
||||||
@NotBlank
|
@NotNull
|
||||||
private String discount;
|
@Min(0)
|
||||||
|
private Integer discount;
|
||||||
@NotBlank
|
|
||||||
private Integer units; // revisar
|
|
||||||
|
|
||||||
public String getFood() {
|
public String getFood() {
|
||||||
return food;
|
return food;
|
||||||
|
@ -40,20 +43,12 @@ public class FoodOffer extends Offer {
|
||||||
this.food = food;
|
this.food = food;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiscount() {
|
public Integer getDiscount() {
|
||||||
return discount;
|
return discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscount(String discount) {
|
public void setDiscount(Integer discount) {
|
||||||
this.discount = discount;
|
this.discount = discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getUnits() {
|
|
||||||
return units;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnits(Integer units) {
|
|
||||||
this.units = units;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -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,49 +1,44 @@
|
||||||
/*
|
|
||||||
* 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.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "nu_offers")
|
@Table(name = "nu_offers")
|
||||||
public class NuOffer extends Offer {
|
public class NuOffer extends Offer {
|
||||||
|
|
||||||
@NotBlank
|
//Oferta por numero de comensales
|
||||||
private Integer gold;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Min(1)
|
||||||
|
private Integer gold;
|
||||||
|
|
||||||
@Column(name = "discount_gold")
|
@Column(name = "discount_gold")
|
||||||
@NotBlank
|
@NotNull
|
||||||
private String discountGold;
|
@Min(0)
|
||||||
|
private Integer discountGold;
|
||||||
|
|
||||||
@NotBlank
|
@NotNull
|
||||||
private Integer silver;
|
@Min(1)
|
||||||
|
private Integer silver;
|
||||||
|
|
||||||
@Column(name = "discount_silver")
|
@Column(name = "discount_silver")
|
||||||
@NotBlank
|
@NotNull
|
||||||
private String discountSilver;
|
@Min(0)
|
||||||
|
private Integer discountSilver;
|
||||||
|
|
||||||
@NotBlank
|
@NotNull
|
||||||
private Integer bronze;
|
@Min(1)
|
||||||
|
private Integer bronze;
|
||||||
|
|
||||||
@Column(name = "discount_bronze")
|
@Column(name = "discount_bronze")
|
||||||
@NotBlank
|
@NotNull
|
||||||
private String discountBronze;
|
@Min(0)
|
||||||
|
private Integer discountBronze;
|
||||||
|
|
||||||
public Integer getGold() {
|
public Integer getGold() {
|
||||||
return gold;
|
return gold;
|
||||||
|
@ -53,11 +48,11 @@ public class NuOffer extends Offer {
|
||||||
this.gold = gold;
|
this.gold = gold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiscountGold() {
|
public Integer getDiscountGold() {
|
||||||
return discountGold;
|
return discountGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscountGold(String discountGold) {
|
public void setDiscountGold(Integer discountGold) {
|
||||||
this.discountGold = discountGold;
|
this.discountGold = discountGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +64,11 @@ public class NuOffer extends Offer {
|
||||||
this.silver = silver;
|
this.silver = silver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiscountSilver() {
|
public Integer getDiscountSilver() {
|
||||||
return discountSilver;
|
return discountSilver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscountSilver(String discountSilver) {
|
public void setDiscountSilver(Integer discountSilver) {
|
||||||
this.discountSilver = discountSilver;
|
this.discountSilver = discountSilver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +80,12 @@ public class NuOffer extends Offer {
|
||||||
this.bronze = bronze;
|
this.bronze = bronze;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiscountBronze() {
|
public Integer getDiscountBronze() {
|
||||||
return discountBronze;
|
return discountBronze;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscountBronze(String discountBronze) {
|
public void setDiscountBronze(Integer discountBronze) {
|
||||||
this.discountBronze = discountBronze;
|
this.discountBronze = discountBronze;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,40 @@ 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 org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public class Offer extends BaseEntity {
|
public class Offer extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// Clase padre
|
||||||
|
|
||||||
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
||||||
@NotBlank
|
@NotNull
|
||||||
@Future
|
@Future
|
||||||
private LocalDateTime start;
|
private LocalDateTime start;
|
||||||
|
|
||||||
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
||||||
@NotBlank
|
@NotNull
|
||||||
@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 status;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name="client_id")
|
@JoinColumn(name = "client_id")
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
public LocalDateTime getStart() {
|
public LocalDateTime getStart() {
|
||||||
|
@ -76,12 +77,20 @@ public class Offer extends BaseEntity {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusOffer getType() {
|
public StatusOffer getStatus() {
|
||||||
return type;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(StatusOffer type) {
|
public void setStatus(StatusOffer type) {
|
||||||
this.type = type;
|
this.status = 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,49 +1,44 @@
|
||||||
/*
|
|
||||||
* 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.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "speed_offers")
|
@Table(name = "speed_offers")
|
||||||
public class SpeedOffer extends Offer {
|
public class SpeedOffer extends Offer {
|
||||||
|
|
||||||
@NotBlank
|
// Ofertar por rapidez comiendo
|
||||||
private Integer gold; // x minutos
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Min(0)
|
||||||
|
private Integer gold;
|
||||||
|
|
||||||
@Column(name = "discount_gold")
|
@Column(name = "discount_gold")
|
||||||
@NotBlank
|
@NotNull
|
||||||
private String discountGold;
|
@Min(0)
|
||||||
|
private Integer discountGold;
|
||||||
|
|
||||||
@NotBlank
|
@NotNull
|
||||||
|
@Min(0)
|
||||||
private Integer silver;
|
private Integer silver;
|
||||||
|
|
||||||
@Column(name = "discount_silver")
|
@Column(name = "discount_silver")
|
||||||
@NotBlank
|
@NotNull
|
||||||
private String discountSilver;
|
@Min(0)
|
||||||
|
private Integer discountSilver;
|
||||||
|
|
||||||
@NotBlank
|
@NotNull
|
||||||
|
@Min(0)
|
||||||
private Integer bronze;
|
private Integer bronze;
|
||||||
|
|
||||||
@Column(name = "discount_bronze")
|
@Column(name = "discount_bronze")
|
||||||
@NotBlank
|
@NotNull
|
||||||
private String discountBronze;
|
@Min(0)
|
||||||
|
private Integer discountBronze;
|
||||||
|
|
||||||
public Integer getGold() {
|
public Integer getGold() {
|
||||||
return gold;
|
return gold;
|
||||||
|
@ -53,11 +48,11 @@ public class SpeedOffer extends Offer {
|
||||||
this.gold = gold;
|
this.gold = gold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiscountGold() {
|
public Integer getDiscountGold() {
|
||||||
return discountGold;
|
return discountGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscountGold(String discountGold) {
|
public void setDiscountGold(Integer discountGold) {
|
||||||
this.discountGold = discountGold;
|
this.discountGold = discountGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +64,11 @@ public class SpeedOffer extends Offer {
|
||||||
this.silver = silver;
|
this.silver = silver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiscountSilver() {
|
public Integer getDiscountSilver() {
|
||||||
return discountSilver;
|
return discountSilver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscountSilver(String discountSilver) {
|
public void setDiscountSilver(Integer discountSilver) {
|
||||||
this.discountSilver = discountSilver;
|
this.discountSilver = discountSilver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +80,12 @@ public class SpeedOffer extends Offer {
|
||||||
this.bronze = bronze;
|
this.bronze = bronze;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiscountBronze() {
|
public Integer getDiscountBronze() {
|
||||||
return discountBronze;
|
return discountBronze;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscountBronze(String discountBronze) {
|
public void setDiscountBronze(Integer discountBronze) {
|
||||||
this.discountBronze = discountBronze;
|
this.discountBronze = discountBronze;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,10 @@
|
||||||
/*
|
|
||||||
* 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.NotNull;
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
@ -29,24 +12,42 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||||
@Table(name = "time_offers")
|
@Table(name = "time_offers")
|
||||||
public class TimeOffer extends Offer {
|
public class TimeOffer extends Offer {
|
||||||
|
|
||||||
|
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
|
@NotNull
|
||||||
private String discount;
|
private Integer discount;
|
||||||
|
|
||||||
|
public LocalTime getInit() {
|
||||||
|
return init;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInit(LocalTime init) {
|
||||||
|
this.init = init;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDiscount() {
|
public LocalTime getFinish() {
|
||||||
|
return finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinish(LocalTime finish) {
|
||||||
|
this.finish = finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDiscount() {
|
||||||
return discount;
|
return discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscount(String discount) {
|
public void setDiscount(Integer discount) {
|
||||||
this.discount = discount;
|
this.discount = discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,12 @@
|
||||||
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
|
|
||||||
public class User{
|
public class User{
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@ -27,7 +16,8 @@ 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 +36,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);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
|
import org.springframework.cheapy.model.FoodOffer;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.Repository;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
public interface FoodOfferRepository extends Repository<FoodOffer, Integer> {
|
||||||
|
|
||||||
|
@Query("SELECT foodOffer FROM FoodOffer foodOffer")
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
List<FoodOffer> findAllFoodOffer();
|
||||||
|
|
||||||
|
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE id =:id")
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
FoodOffer findById(@Param("id") Integer id);
|
||||||
|
|
||||||
|
void save(FoodOffer foodOffer);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.cheapy.model.NuOffer;
|
||||||
|
import org.springframework.data.repository.Repository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
public interface NuOfferRepository extends Repository<NuOffer, Integer> {
|
||||||
|
|
||||||
|
NuOffer findNuOfferById(int nuOfferId);
|
||||||
|
|
||||||
|
@Query("SELECT nuOffer FROM NuOffer nuOffer")
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
List<NuOffer> findAllNuOffer();
|
||||||
|
|
||||||
|
void save(NuOffer nuOffer);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.Repository;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
public interface SpeedOfferRepository extends Repository<SpeedOffer, Integer> {
|
||||||
|
|
||||||
|
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE id =:id")
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
SpeedOffer findById(@Param("id") Integer id);
|
||||||
|
|
||||||
|
@Query("SELECT speedOffer FROM SpeedOffer speedOffer")
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
List<SpeedOffer> findAllSpeedOffer();
|
||||||
|
|
||||||
|
void save(SpeedOffer speedOffer);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.springframework.cheapy.repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.cheapy.model.TimeOffer;
|
||||||
|
import org.springframework.data.repository.Repository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
public interface TimeOfferRepository extends Repository<TimeOffer, Integer> {
|
||||||
|
|
||||||
|
TimeOffer findTimeOfferById(int timeOfferId);
|
||||||
|
|
||||||
|
@Query("SELECT timeOffer FROM TimeOffer timeOffer")
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
List<TimeOffer> findAllTimeOffer();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package org.springframework.cheapy.service;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cheapy.model.FoodOffer;
|
||||||
|
import org.springframework.cheapy.repository.FoodOfferRepository;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FoodOfferService {
|
||||||
|
|
||||||
|
private FoodOfferRepository foodOfferRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public FoodOfferService(final FoodOfferRepository foodOfferRepository) {
|
||||||
|
this.foodOfferRepository = foodOfferRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FoodOffer findFoodOfferById(final int id) {
|
||||||
|
return this.foodOfferRepository.findById(id);
|
||||||
|
}
|
||||||
|
public List<FoodOffer> findAllFoodOffer() { //
|
||||||
|
return this.foodOfferRepository.findAllFoodOffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveFoodOffer(final FoodOffer foodOffer) throws DataAccessException {
|
||||||
|
this.foodOfferRepository.save(foodOffer);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
package org.springframework.cheapy.service;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cheapy.model.NuOffer;
|
||||||
|
import org.springframework.cheapy.repository.NuOfferRepository;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class NuOfferService {
|
||||||
|
|
||||||
|
private NuOfferRepository nuOfferRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public NuOfferService(final NuOfferRepository nuOfferRepository) {
|
||||||
|
this.nuOfferRepository = nuOfferRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public NuOffer findNuOfferById(final int id) {
|
||||||
|
return this.nuOfferRepository.findNuOfferById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public List<NuOffer> findAllNuOffer() {
|
||||||
|
return this.nuOfferRepository.findAllNuOffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException {
|
||||||
|
this.nuOfferRepository.save(nuOffer);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
package org.springframework.cheapy.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
|
import org.springframework.cheapy.repository.SpeedOfferRepository;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SpeedOfferService {
|
||||||
|
|
||||||
|
private SpeedOfferRepository speedOfferRepository;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public SpeedOfferService(final SpeedOfferRepository speedOfferRepository) {
|
||||||
|
this.speedOfferRepository = speedOfferRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public SpeedOffer findSpeedOfferById(final int id) {
|
||||||
|
return this.speedOfferRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public List<SpeedOffer> findAllSpeedOffer() { //
|
||||||
|
return this.speedOfferRepository.findAllSpeedOffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { //
|
||||||
|
this.speedOfferRepository.save(speedOffer);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.springframework.cheapy.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cheapy.model.TimeOffer;
|
||||||
|
import org.springframework.cheapy.repository.TimeOfferRepository;
|
||||||
|
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TimeOfferService {
|
||||||
|
private TimeOfferRepository timeOfferRepository;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public TimeOfferService(final TimeOfferRepository TimeOfferRepository) {
|
||||||
|
this.timeOfferRepository = TimeOfferRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeOffer findTimeOfferById(final int id) {
|
||||||
|
return this.timeOfferRepository.findTimeOfferById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TimeOffer> findAllTimeOffer() {
|
||||||
|
return this.timeOfferRepository.findAllTimeOffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void saveTimeOffer(final TimeOffer TimeOffer) throws DataAccessException {
|
||||||
|
this.timeOfferRepository.save(TimeOffer);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,64 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2002-2013 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
|
|
||||||
*
|
|
||||||
* http://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.service;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
import org.springframework.cheapy.model.User;
|
|
||||||
import org.springframework.cheapy.repository.UsuarioRepository;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mostly used as a facade for all Petclinic controllers Also a placeholder
|
|
||||||
* for @Transactional and @Cacheable annotations
|
|
||||||
*
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class UserService {
|
|
||||||
/*
|
|
||||||
private UserRepository userRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public UserService(UserRepository userRepository) {
|
|
||||||
this.userRepository = userRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void saveUser(User user) throws DataAccessException {
|
|
||||||
userRepository.save(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<User> findUser(String username) {
|
|
||||||
return userRepository.findById(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public User getCurrentUser() throws DataAccessException {
|
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
|
||||||
String currentPrincipalName = authentication.getName(); //Obtiene el nombre del ususario actual
|
|
||||||
return this.userRepository.findByUsername(currentPrincipalName); //Obtiene el usuario con ese nombre
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
|
@ -33,7 +33,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
class CacheConfiguration {
|
class CacheConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JCacheManagerCustomizer petclinicCacheConfigurationCustomizer() {
|
public JCacheManagerCustomizer cheapyCacheConfigurationCustomizer() {
|
||||||
return cm -> {
|
return cm -> {
|
||||||
cm.createCache("vets", cacheConfiguration());
|
cm.createCache("vets", cacheConfiguration());
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@Controller
|
@Controller
|
||||||
public class CrashController {
|
public class CrashController {
|
||||||
|
|
||||||
@GetMapping("/oups")
|
@GetMapping(value="/oups")
|
||||||
public String triggerException() {
|
public String triggerException() {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Expected: controller used to showcase what " + "happens when an exception is thrown");
|
"Expected: controller used to showcase what " + "happens when an exception is thrown");
|
||||||
|
|
|
@ -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,128 @@
|
||||||
|
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
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.annotation.GetMapping;
|
||||||
|
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 = "offers/food/createOrUpdateFoodOfferForm";
|
||||||
|
|
||||||
|
private final FoodOfferService foodOfferService;
|
||||||
|
private final ClientService clientService;
|
||||||
|
|
||||||
|
public FoodOfferController(final FoodOfferService foodOfferService, final ClientService clientService) {
|
||||||
|
this.foodOfferService = foodOfferService;
|
||||||
|
this.clientService = clientService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/offers/food/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("/offers/food/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.setStatus(StatusOffer.hidden);
|
||||||
|
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||||
|
return "redirect:/offers/food/" + foodOffer.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/food/{foodOfferId}/activate")
|
||||||
|
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, ModelMap modelMap) {
|
||||||
|
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
if (foodOffer.getClient().equals(client)) {
|
||||||
|
foodOffer.setStatus(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:/offers/food/"+foodOfferId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
|
||||||
|
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||||
|
|
||||||
|
|
||||||
|
return "offers/food/foodOffersShow";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||||
|
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||||
|
model.addAttribute("foodOffer", foodOffer);
|
||||||
|
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||||
|
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result,
|
||||||
|
final ModelMap model) {
|
||||||
|
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
model.addAttribute("foodOffer", foodOfferEdit);
|
||||||
|
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.foodOfferService.saveFoodOffer(foodOfferEdit);
|
||||||
|
return "redirect:/offers/food/" + foodOfferEdit.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/food/{foodOfferId}/disable")
|
||||||
|
public String disableFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||||
|
model.put("foodOffer", foodOffer);
|
||||||
|
return "foodOffers/foodOffersDisable";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/offers/food/{foodOfferId}/disable")
|
||||||
|
public String disableFoodOfferForm(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||||
|
|
||||||
|
foodOffer.setStatus(StatusOffer.inactive);
|
||||||
|
|
||||||
|
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||||
|
|
||||||
|
return "redirect:/offers";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import org.springframework.cheapy.model.NuOffer;
|
||||||
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
|
import org.springframework.cheapy.service.NuOfferService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class NuOfferController {
|
||||||
|
|
||||||
|
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "offers/nu/createOrUpdateNuOfferForm";
|
||||||
|
|
||||||
|
private final NuOfferService nuOfferService;
|
||||||
|
private final ClientService clientService;
|
||||||
|
|
||||||
|
public NuOfferController(final NuOfferService nuOfferService, final ClientService clientService) {
|
||||||
|
this.nuOfferService = nuOfferService;
|
||||||
|
this.clientService = clientService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/offers/nu/new")
|
||||||
|
public String initCreationForm(Map<String, Object> model) {
|
||||||
|
NuOffer nuOffer = new NuOffer();
|
||||||
|
model.put("nuOffer", nuOffer);
|
||||||
|
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/offers/nu/new")
|
||||||
|
public String processCreationForm(@Valid NuOffer nuOffer, BindingResult result) {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
} else {
|
||||||
|
nuOffer.setStatus(StatusOffer.hidden);
|
||||||
|
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
|
||||||
|
nuOffer.setClient(client);
|
||||||
|
|
||||||
|
this.nuOfferService.saveNuOffer(nuOffer);
|
||||||
|
return "redirect:/offers/nu/"+nuOffer.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value ="/offers/nu/{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.setStatus(StatusOffer.active);
|
||||||
|
nuOffer.setCode("NU-" + nuOfferId);
|
||||||
|
this.nuOfferService.saveNuOffer(nuOffer);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
modelMap.addAttribute("message", "You don't have access to this number offer");
|
||||||
|
}
|
||||||
|
return "redirect:/offers/nu/"+ nuOffer.getId();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/offers/nu/{nuOfferId}")
|
||||||
|
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
|
||||||
|
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||||
|
model.put("nuOffer", nuOffer);
|
||||||
|
|
||||||
|
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||||
|
return "offers/nu/nuOffersShow";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||||
|
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||||
|
model.addAttribute("nuOffer", nuOffer);
|
||||||
|
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||||
|
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model) {
|
||||||
|
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
model.addAttribute("nuOffer", nuOfferEdit);
|
||||||
|
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.nuOfferService.saveNuOffer(nuOfferEdit);
|
||||||
|
return "redirect:/offers/nu/" + nuOfferEdit.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||||
|
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
|
||||||
|
final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||||
|
model.put("nuOffer", nuOffer);
|
||||||
|
return "nuOffers/nuOffersDisable";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||||
|
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
|
||||||
|
final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||||
|
nuOffer.setStatus(StatusOffer.inactive);
|
||||||
|
this.nuOfferService.saveNuOffer(nuOffer);
|
||||||
|
return "redirect:/offers";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.cheapy.model.FoodOffer;
|
||||||
|
import org.springframework.cheapy.model.NuOffer;
|
||||||
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
|
import org.springframework.cheapy.model.TimeOffer;
|
||||||
|
import org.springframework.cheapy.service.FoodOfferService;
|
||||||
|
import org.springframework.cheapy.service.NuOfferService;
|
||||||
|
import org.springframework.cheapy.service.SpeedOfferService;
|
||||||
|
import org.springframework.cheapy.service.TimeOfferService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class OfertaController {
|
||||||
|
|
||||||
|
private final FoodOfferService foodOfferService;
|
||||||
|
private final NuOfferService nuOfferService;
|
||||||
|
private final SpeedOfferService speedOfferService;
|
||||||
|
private final TimeOfferService timeOfferService;
|
||||||
|
|
||||||
|
public OfertaController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService,
|
||||||
|
final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
|
||||||
|
this.foodOfferService = foodOfferService;
|
||||||
|
this.nuOfferService = nuOfferService;
|
||||||
|
this.speedOfferService = speedOfferService;
|
||||||
|
this.timeOfferService = timeOfferService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/offers")
|
||||||
|
public String processFindForm( Map<String, Object> model) {
|
||||||
|
|
||||||
|
List<FoodOffer> foodOfferLs=this.foodOfferService.findAllFoodOffer();
|
||||||
|
List<NuOffer> nuOfferLs=this.nuOfferService.findAllNuOffer();
|
||||||
|
List<SpeedOffer> speedOfferLs=this.speedOfferService.findAllSpeedOffer();
|
||||||
|
List<TimeOffer> timeOfferLs=this.timeOfferService.findAllTimeOffer();
|
||||||
|
|
||||||
|
model.put("foodOfferLs", foodOfferLs);
|
||||||
|
model.put("nuOfferLs", nuOfferLs);
|
||||||
|
model.put("speedOfferLs", speedOfferLs);
|
||||||
|
model.put("timeOfferLs", timeOfferLs);
|
||||||
|
|
||||||
|
//Se añade formateador de fecha al modelo
|
||||||
|
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||||
|
|
||||||
|
return "offers/offersList";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// @GetMapping("/owners/{ownerId}/edit")
|
||||||
|
// public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||||
|
// Owner owner = this.ownerService.findOwnerById(ownerId);
|
||||||
|
// model.addAttribute(owner);
|
||||||
|
// return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @PostMapping("/owners/{ownerId}/edit")
|
||||||
|
// public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result,
|
||||||
|
// @PathVariable("ownerId") int ownerId) {
|
||||||
|
// if (result.hasErrors()) {
|
||||||
|
// return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// owner.setId(ownerId);
|
||||||
|
// this.ownerService.saveOwner(owner);
|
||||||
|
// return "redirect:/owners/{ownerId}";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// @GetMapping("/owners/{ownerId}")
|
||||||
|
// public ModelAndView showOwner(@PathVariable("ownerId") int ownerId) {
|
||||||
|
// ModelAndView mav = new ModelAndView("owners/ownerDetails");
|
||||||
|
// Owner owner = this.ownerService.findOwnerById(ownerId);
|
||||||
|
//
|
||||||
|
// mav.addObject(owner);
|
||||||
|
// return mav;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
|
import org.springframework.cheapy.service.SpeedOfferService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class SpeedOfferController {
|
||||||
|
|
||||||
|
private static final String VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM = "offers/speed/createOrUpdateSpeedOfferForm";
|
||||||
|
|
||||||
|
private final SpeedOfferService speedOfferService;
|
||||||
|
private final ClientService clientService;
|
||||||
|
|
||||||
|
public SpeedOfferController(final SpeedOfferService speedOfferService, final ClientService clientService) {
|
||||||
|
this.speedOfferService = speedOfferService;
|
||||||
|
this.clientService = clientService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/offers/speed/new")
|
||||||
|
public String initCreationForm(Map<String, Object> model) {
|
||||||
|
SpeedOffer speedOffer = new SpeedOffer();
|
||||||
|
model.put("speedOffer", speedOffer);
|
||||||
|
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/offers/speed/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.setStatus(StatusOffer.hidden);
|
||||||
|
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||||
|
return "redirect:/offers/speed/" + speedOffer.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/speed/{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.setStatus(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:/offers/speed/" + speedOffer.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
|
||||||
|
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||||
|
return "offers/speed/speedOffersShow";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||||
|
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||||
|
model.addAttribute("speedOffer", speedOffer);
|
||||||
|
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||||
|
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result, final ModelMap model) {
|
||||||
|
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
model.addAttribute("speedOffer", speedOfferEdit);
|
||||||
|
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
|
||||||
|
return "redirect:/offers/speed/" + speedOfferEdit.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/speed/{speedOfferId}/disable")
|
||||||
|
public String disableSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||||
|
model.put("speedOffer", speedOffer);
|
||||||
|
return "speedOffers/speedOffersDisable";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/offers/speed/{speedOfferId}/disable")
|
||||||
|
public String disableSpeedOfferForm(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||||
|
|
||||||
|
speedOffer.setStatus(StatusOffer.inactive);
|
||||||
|
|
||||||
|
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||||
|
|
||||||
|
return "redirect:/offers";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,136 @@
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
|
import org.springframework.cheapy.model.TimeOffer;
|
||||||
|
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.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class TimeOfferController {
|
||||||
|
|
||||||
|
|
||||||
|
private static final String VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM = "offers/time/createOrUpdateTimeOfferForm";
|
||||||
|
private final TimeOfferService timeOfferService;
|
||||||
|
private final ClientService clientService;
|
||||||
|
|
||||||
|
public TimeOfferController(final TimeOfferService timeOfferService, ClientService clientService) {
|
||||||
|
this.timeOfferService = timeOfferService;
|
||||||
|
this.clientService = clientService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/offers/time/new")
|
||||||
|
public String initCreationForm(Map<String, Object> model) {
|
||||||
|
TimeOffer timeOffer = new TimeOffer();
|
||||||
|
model.put("timeOffer", timeOffer);
|
||||||
|
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/offers/time/new")
|
||||||
|
public String processCreationForm(@Valid TimeOffer timeOffer, BindingResult result) {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
} else {
|
||||||
|
timeOffer.setStatus(StatusOffer.hidden);
|
||||||
|
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
|
||||||
|
timeOffer.setClient(client);
|
||||||
|
|
||||||
|
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||||
|
return "redirect:/offers/time/" + timeOffer.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value ="/offers/time/{timeOfferId}/activate")
|
||||||
|
public String activateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap modelMap) {
|
||||||
|
Client client = this.clientService.getCurrentClient();
|
||||||
|
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||||
|
if (timeOffer.getClient().equals(client)) {
|
||||||
|
timeOffer.setStatus(StatusOffer.active);
|
||||||
|
timeOffer.setCode("TI-" + timeOfferId);
|
||||||
|
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
modelMap.addAttribute("message", "You don't have access to this time offer");
|
||||||
|
}
|
||||||
|
return "redirect:/offers/time/" + timeOffer.getId();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/offers/time/{timeOfferId}")
|
||||||
|
public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map<String, Object> model) {
|
||||||
|
|
||||||
|
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||||
|
|
||||||
|
model.put("timeOffer", timeOffer);
|
||||||
|
|
||||||
|
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||||
|
|
||||||
|
return "offers/time/timeOffersShow";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||||
|
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||||
|
model.addAttribute("timeOffer", timeOffer);
|
||||||
|
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||||
|
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result, final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
model.addAttribute("timeOffer", timeOfferEdit);
|
||||||
|
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.timeOfferService.saveTimeOffer(timeOfferEdit);
|
||||||
|
return "redirect:/offers/time/" + timeOfferEdit.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/offers/time/{timeOfferId}/disable")
|
||||||
|
public String disableTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||||
|
model.put("timeOffer", timeOffer);
|
||||||
|
return "timeOffers/timeOffersDisable";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/offers/time/{timeOfferId}/disable")
|
||||||
|
public String disableTimeOfferForm(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||||
|
|
||||||
|
|
||||||
|
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||||
|
|
||||||
|
timeOffer.setStatus(StatusOffer.inactive);
|
||||||
|
|
||||||
|
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||||
|
|
||||||
|
return "redirect:/offers";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,154 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2002-2013 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.cheapy.web;
|
|
||||||
|
|
||||||
import javax.persistence.EntityNotFoundException;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.cheapy.model.Authorities;
|
|
||||||
import org.springframework.cheapy.model.User;
|
|
||||||
import org.springframework.cheapy.service.AuthoritiesService;
|
|
||||||
import org.springframework.cheapy.service.UserService;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.ModelMap;
|
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.validation.FieldError;
|
|
||||||
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.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Juergen Hoeller
|
|
||||||
* @author Ken Krebs
|
|
||||||
* @author Arjen Poutsma
|
|
||||||
* @author Michael Isvy
|
|
||||||
*/
|
|
||||||
@Controller
|
|
||||||
public class UserController {
|
|
||||||
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
private AuthoritiesService authoritiesService;
|
|
||||||
|
|
||||||
// @Autowired
|
|
||||||
// public UserController (UserService userService, AuthoritiesService authoritiesService,
|
|
||||||
// ClienteService clienteService, FarmaceuticoService farmaceuticoService, ProveedorService proveedorService) {
|
|
||||||
// this.userService = userService;
|
|
||||||
// this.authoritiesService = authoritiesService;
|
|
||||||
// this.clienteService = clienteService;
|
|
||||||
// this.farmaceuticoService = farmaceuticoService;
|
|
||||||
// this.proveedorService = proveedorService;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @InitBinder
|
|
||||||
// public void setAllowedFields(final WebDataBinder dataBinder) {
|
|
||||||
// dataBinder.setDisallowedFields("id");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @GetMapping("users")
|
|
||||||
// private String showUserDetails(ModelMap model) {
|
|
||||||
// User user = this.userService.getCurrentUser();
|
|
||||||
// Authorities authority = this.authoritiesService.findAuthoritiyByUser(user);
|
|
||||||
//
|
|
||||||
// if(authority.getAuthority().equals("cliente")) {
|
|
||||||
// Cliente cliente = this.clienteService.findClienteUser(user);
|
|
||||||
// model.addAttribute("cliente", cliente);
|
|
||||||
// }else if(authority.getAuthority().equals("proveedor")) {
|
|
||||||
// Proveedor proveedor = this.proveedorService.findProveedorUser(user);
|
|
||||||
// model.addAttribute("proveedor", proveedor);
|
|
||||||
// }else if(authority.getAuthority().equals("farmaceutico")) {
|
|
||||||
// Farmaceutico farmaceutico = this.farmaceuticoService.findFarmaceuticoByUser(user);
|
|
||||||
// model.addAttribute("farmaceutico", farmaceutico);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// log.info("El usuario '" + user.getUsername() + "' ha mostrado su informacion personal");
|
|
||||||
// return "users/userDetails";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @GetMapping("/users/new")
|
|
||||||
// public String newUser(ModelMap model) {
|
|
||||||
// Cliente cliente = new Cliente();
|
|
||||||
// model.addAttribute("cliente", cliente);
|
|
||||||
// model.addAttribute("dni", new String());
|
|
||||||
// return "users/userRegister";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @PostMapping("/users/new")
|
|
||||||
// public String creationUser(@ModelAttribute("cliente") Cliente cliente, final BindingResult result, ModelMap model) {
|
|
||||||
// if (result.hasErrors()) {
|
|
||||||
// return "users/userRegister";
|
|
||||||
// } else if(cliente.getUser() == null) {
|
|
||||||
// try {
|
|
||||||
// cliente = this.clienteService.clienteDni(cliente.getDni());
|
|
||||||
// }catch(EntityNotFoundException ex) {
|
|
||||||
// result.rejectValue("dni", "clienteNotFound");
|
|
||||||
// return "users/userRegister";
|
|
||||||
// }
|
|
||||||
// cliente.setUser(new User());
|
|
||||||
// model.addAttribute("cliente", cliente);
|
|
||||||
// return "users/userRegister";
|
|
||||||
// }else {
|
|
||||||
// this.userService.saveUser(cliente.getUser());
|
|
||||||
// this.authoritiesService.saveAuthorities(cliente.getUser().getUsername(), "cliente");
|
|
||||||
// this.clienteService.saveCliente(cliente);
|
|
||||||
// log.info("El cliente con dni '" + cliente.getDni() + "' se ha registrado como usuario");
|
|
||||||
// return "redirect:../";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @GetMapping("/users/password")
|
|
||||||
// public String initChangePassword(ModelMap model) {
|
|
||||||
// User currentUser = this.userService.getCurrentUser();
|
|
||||||
// UserValidate user = new UserValidate(currentUser.getUsername(), "");
|
|
||||||
// model.addAttribute("user", user);
|
|
||||||
// return "users/passwordEdit";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @PostMapping("/users/password")
|
|
||||||
// public String changePassword(@ModelAttribute("user") UserValidate user, final BindingResult result, ModelMap model) {
|
|
||||||
// if(result.hasErrors()) {
|
|
||||||
// return "users/passwordEdit";
|
|
||||||
// }else {
|
|
||||||
// User CurrentUser = this.userService.getCurrentUser();
|
|
||||||
// if(CurrentUser.getPassword().equals(user.getPassword()) && user.getNewPassword().equals(user.getValidPassword())) {
|
|
||||||
// if(!user.getNewPassword().isEmpty()) {
|
|
||||||
// CurrentUser.setPassword(user.getNewPassword());
|
|
||||||
// this.userService.saveUser(CurrentUser);
|
|
||||||
// log.info("El usuario '" + CurrentUser.getUsername() + "' ha cambiado satisfactoriamente su contraseña");
|
|
||||||
// return "redirect:../";
|
|
||||||
// }else {
|
|
||||||
// FieldError err = new FieldError("PassException", "newPassword", "Introduce una nueva contraseña");
|
|
||||||
// result.addError(err);
|
|
||||||
// log.warn("El usuario '" + CurrentUser.getUsername() + "' ha tenido un error 'PassException'");
|
|
||||||
// return "users/passwordEdit";
|
|
||||||
// }
|
|
||||||
// }else if(!CurrentUser.getPassword().equals(user.getPassword())){
|
|
||||||
// FieldError err = new FieldError("PassException", "password", "Contraseña incorrecta");
|
|
||||||
// result.addError(err);
|
|
||||||
// log.warn("El usuario '" + CurrentUser.getUsername() + "' ha tenido un error 'PassException'");
|
|
||||||
// return "users/passwordEdit";
|
|
||||||
// }else {
|
|
||||||
// FieldError err = new FieldError("PassException", "newPassword", "Las contraseñas no coinciden");
|
|
||||||
// result.addError(err);
|
|
||||||
// log.warn("El usuario '" + CurrentUser.getUsername() + "' ha tenido un error 'PassException'");
|
|
||||||
// return "users/passwordEdit";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -47,10 +47,10 @@
|
||||||
|
|
||||||
@pagination-active-bg: @spring-brown;
|
@pagination-active-bg: @spring-brown;
|
||||||
@pagination-active-border: @spring-blue;
|
@pagination-active-border: @spring-blue;
|
||||||
@table-border-color: @spring-brown;
|
@table-border-color: rgb(0, 64, 128);
|
||||||
|
|
||||||
.table > thead > tr > th {
|
.table > thead > tr > th {
|
||||||
background-color: lighten(@spring-brown, 3%);
|
background-color: rgb(40, 140, 215);
|
||||||
color: @spring-light-grey;
|
color: @spring-light-grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,131 @@ img.img-responsive{
|
||||||
|
|
||||||
|
|
||||||
.btn-home button:hover {
|
.btn-home button:hover {
|
||||||
background-color: rgb(0, 64, 128);
|
background-color: rgb(40, 140, 215);
|
||||||
|
}
|
||||||
|
|
||||||
|
#foodOfferTable th {
|
||||||
|
width: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nuOfferTable th {
|
||||||
|
width: 33%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#speedOfferTable th {
|
||||||
|
width: 33%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timeOfferTable th {
|
||||||
|
width: 33%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-detalles button {
|
||||||
|
background-color: rgb(0, 64, 128);
|
||||||
|
border: 1px solid rgb(0, 0, 160);
|
||||||
|
color: white;
|
||||||
|
padding: 10px 24px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-detalles button:not(:last-child) {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.btn-detalles button:hover {
|
||||||
|
background-color: rgb(40, 140, 215);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-return{
|
||||||
|
display: table;
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-return button {
|
||||||
|
background-color: rgb(0, 64, 128);
|
||||||
|
border: 1px solid rgb(0, 0, 160);
|
||||||
|
color: white;
|
||||||
|
padding: 10px 24px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
left: 0%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-return button:not(:last-child) {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.btn-return button:hover {
|
||||||
|
background-color: rgb(40, 140, 215);
|
||||||
|
}
|
||||||
|
|
||||||
|
#foodOfferTable td{
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nuOfferTable td{
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#speedOfferTable td{
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timeOfferTable td{
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nuOffer-table tr:nth-child(3){
|
||||||
|
background-color: rgb(255, 215, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#nuOffer-table tr:nth-child(4){
|
||||||
|
background-color: rgb(255, 215, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#nuOffer-table tr:nth-child(5){
|
||||||
|
background-color: rgb(192, 192, 192);
|
||||||
|
}
|
||||||
|
|
||||||
|
#nuOffer-table tr:nth-child(6){
|
||||||
|
background-color: rgb(192, 192, 192);
|
||||||
|
}
|
||||||
|
|
||||||
|
#nuOffer-table tr:nth-child(7){
|
||||||
|
background-color: rgb(204, 128, 51);
|
||||||
|
}
|
||||||
|
|
||||||
|
#nuOffer-table tr:nth-child(8){
|
||||||
|
background-color: rgb(204, 128, 51);
|
||||||
|
}
|
||||||
|
|
||||||
|
#speedOffer-table tr:nth-child(3){
|
||||||
|
background-color: rgb(255, 215, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#speedOffer-table tr:nth-child(4){
|
||||||
|
background-color: rgb(255, 215, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#speedOffer-table tr:nth-child(5){
|
||||||
|
background-color: rgb(192, 192, 192);
|
||||||
|
}
|
||||||
|
|
||||||
|
#speedOffer-table tr:nth-child(6){
|
||||||
|
background-color: rgb(192, 192, 192);
|
||||||
|
}
|
||||||
|
|
||||||
|
#speedOffer-table tr:nth-child(7){
|
||||||
|
background-color: rgb(204, 128, 51);
|
||||||
|
}
|
||||||
|
|
||||||
|
#speedOffer-table tr:nth-child(8){
|
||||||
|
background-color: rgb(204, 128, 51);
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-success {
|
.alert-success {
|
|
@ -1,5 +1,5 @@
|
||||||
================================================================================
|
================================================================================
|
||||||
=== Spring PetClinic sample application - MySQL Configuration ===
|
=== Spring Cheapy sample application - MySQL Configuration ===
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
@author Sam Brannen
|
@author Sam Brannen
|
||||||
|
@ -18,15 +18,15 @@
|
||||||
mysql_1_eedb4818d817 | MySQL init process done. Ready for start up.
|
mysql_1_eedb4818d817 | MySQL init process done. Ready for start up.
|
||||||
...
|
...
|
||||||
|
|
||||||
2) (Once only) create the PetClinic database and user by executing the "db/mysql/user.sql"
|
2) (Once only) create the Cheapy database and user by executing the "db/mysql/user.sql"
|
||||||
scripts. You can connect to the database running in the docker container using
|
scripts. You can connect to the database running in the docker container using
|
||||||
`mysql -u root -h localhost --protocol tcp`, but you don't need to run the script there
|
`mysql -u root -h localhost --protocol tcp`, but you don't need to run the script there
|
||||||
because the petclinic user is already set up if you use the provided `docker-compose.yaml`.
|
because the cheapy user is already set up if you use the provided `docker-compose.yaml`.
|
||||||
|
|
||||||
3) Run the app with `spring.profiles.active=mysql` (e.g. as a System property via the command
|
3) Run the app with `spring.profiles.active=mysql` (e.g. as a System property via the command
|
||||||
line, but any way that sets that property in a Spring Boot app should work).
|
line, but any way that sets that property in a Spring Boot app should work).
|
||||||
|
|
||||||
N.B. the "petclinic" database has to exist for the app to work with the JDBC URL value
|
N.B. the "cheapy" database has to exist for the app to work with the JDBC URL value
|
||||||
as it is configured by default. This condition is taken care of automatically by the
|
as it is configured by default. This condition is taken care of automatically by the
|
||||||
docker-compose configuration provided, or by the `user.sql` script if you run that as
|
docker-compose configuration provided, or by the `user.sql` script if you run that as
|
||||||
root.
|
root.
|
||||||
|
|
|
@ -9,14 +9,31 @@ 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 food_offers(start, end, code, type, client_id, food, discount, units) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, 'macarrones', '15%', 10);
|
INSERT INTO authorities VALUES ('manoli','client');
|
||||||
|
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','david','david', TRUE );
|
||||||
|
INSERT INTO authorities VALUES ('david','client');
|
||||||
|
|
||||||
INSERT INTO time_offers(start, end, code, type, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, '12:00:00', '13:00:00', '10%');
|
INSERT INTO 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 usuarios(username, password, enabled) values ('admin3', 'admin', true);
|
INSERT INTO usuarios VALUES (1, 'admin', 'admin', 'admin', 'C/admin', '000000000', 'admin@gmail.com','admin');
|
||||||
--insert into authorities(id ,usuario, authority) values (42,'admin3', 'admin');
|
INSERT INTO usuarios VALUES (2, 'Paco', 'Naranjo', '21154416G', 'C/Esperanza', '666973647', 'Paco@gmail.com','paco');
|
||||||
|
INSERT INTO usuarios VALUES (3, 'Lolo', 'Lopez', '25486596L', 'C/Macarena', '690670547' ,'Lolo@gmail.com','lolo');
|
||||||
|
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 (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (1,'bar manoli','manoli@gmail.com','C/Betis','10:00','22:00','608726190', 'description 1', 'code1', 'ESPAÑOLA','manoli');
|
||||||
INSERT INTO authorities(id,username,authority) VALUES (1,'admin1','admin');
|
INSERT INTO clients (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (2,'bar david','david@gmail.com','C/Sevilla','09:30','22:00','608726190', 'description 2', 'code2', 'americana','david');
|
||||||
|
|
||||||
|
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'FO-1', 'active', 1, 'macarrones', 15);
|
||||||
|
INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'T-1', 'active', 1, '12:00:00', '13:00:00', 10);
|
||||||
|
INSERT INTO speed_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'SP-1', 'active',1,5,25,10,15,15,10);
|
||||||
|
INSERT INTO nu_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'NU-1', 'active',1,15,25,10,15,5,10);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
welcome=Welcome
|
welcome=Welcome to
|
||||||
|
listOffers=List Offers
|
||||||
|
|
||||||
required=is required
|
required=is required
|
||||||
notFound=has not been found
|
notFound=has not been found
|
||||||
duplicate=is already in use
|
duplicate=is already in use
|
||||||
|
|
|
@ -1,8 +1,34 @@
|
||||||
welcome=Bienvenido a
|
welcome=Bienvenido a
|
||||||
required=Es requerido
|
listOffers=Ver Ofertas
|
||||||
|
foodOffers=Ofertas por plato especifico
|
||||||
|
foodOffer=Oferta por plato especifico
|
||||||
|
nuOffers=Ofertas por numero de comensales
|
||||||
|
nuOffer=Oferta por numero de comensales
|
||||||
|
speedOffers=Ofertas rapidez comiendo
|
||||||
|
speedOffer=Oferta por comer veloz
|
||||||
|
timeOffers=Ofertas por franja horaria
|
||||||
|
timeOffer=Oferta por franja horaria
|
||||||
|
food=Plato
|
||||||
|
foodInOffer=Plato en oferta
|
||||||
|
cuantity=Cantidad
|
||||||
|
discount=Descuento
|
||||||
|
goldGoal=Meta oro
|
||||||
|
goldDiscount=Descuento oro
|
||||||
|
silverGoal=Meta plata
|
||||||
|
silverDiscount=Descuento plata
|
||||||
|
bronzeGoal=Meta bronce
|
||||||
|
bronzeDiscount=Descuento bronce
|
||||||
|
startDate=Fecha inicio
|
||||||
|
offerBeginning=Inicio de la oferta
|
||||||
|
endDate=Fecha fin
|
||||||
|
offerEnding=Fin de la oferta
|
||||||
|
details=Detalles
|
||||||
|
offerCode=Codigo de la oferta
|
||||||
|
return=Volver
|
||||||
|
required=Es requeridOfertas por franja horariao
|
||||||
notFound=No ha sido encontrado
|
notFound=No ha sido encontrado
|
||||||
duplicate=Ya se encuentra en uso
|
duplicate=Ya se encuentra en uso
|
||||||
nonNumeric=Sólo debe contener numeros
|
nonNumeric=Sólo debe contener numeros
|
||||||
duplicateFormSubmission=No se permite el envío de formularios duplicados
|
duplicateFormSubmission=No se permite el envío de formularios duplicados
|
||||||
typeMismatch.date=Fecha invalida
|
typeMismatch.date=Fecha invalida
|
||||||
typeMismatch.birthDate=Fecha invalida
|
typeMismatch.birthDate=Fecha invalida
|
BIN
src/main/resources/static/resources/images/bar3.jpg
Normal file
BIN
src/main/resources/static/resources/images/bar3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 479 KiB |
15
src/main/webapp/WEB-INF/jsp/error.jsp
Normal file
15
src/main/webapp/WEB-INF/jsp/error.jsp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
|
|
||||||
|
<cheapy:layout pageName="error">
|
||||||
|
|
||||||
|
<h2 style="text-align:center">Algo malo ha pasado...</h2>
|
||||||
|
|
||||||
|
<spring:url value="/resources/images/Logo Cheapy.png" htmlEscape="true" var="cheapyImage"/>
|
||||||
|
<img class="img-responsive" src="${cheapyImage}"/>
|
||||||
|
|
||||||
|
<p>${exception.message}</p>
|
||||||
|
|
||||||
|
</cheapy:layout>
|
|
@ -1,14 +0,0 @@
|
||||||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
|
||||||
|
|
||||||
<petclinic:layout pageName="error">
|
|
||||||
|
|
||||||
<spring:url value="/resources/images/pets.png" var="petsImage"/>
|
|
||||||
<img src="${petsImage}"/>
|
|
||||||
|
|
||||||
<h2>Something happened...</h2>
|
|
||||||
|
|
||||||
<p>${exception.message}</p>
|
|
||||||
|
|
||||||
</petclinic: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>
|
|
@ -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="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">
|
||||||
|
<form:hidden path="id"/>
|
||||||
|
<form:hidden path="code"/>
|
||||||
|
<form:hidden path="status"/>
|
||||||
|
<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"/>
|
||||||
|
</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">Crear oferta</button>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
<button class="btn btn-default" type="submit">Modificar</button>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form:form>
|
||||||
|
</petclinic:layout>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<%@ 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}" />
|
||||||
|
|
||||||
|
<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>
|
58
src/main/webapp/WEB-INF/jsp/offers/food/foodOffersShow.jsp
Normal file
58
src/main/webapp/WEB-INF/jsp/offers/food/foodOffersShow.jsp
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<%@ 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="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||||
|
|
||||||
|
<cheapy:layout pageName="foodOffer">
|
||||||
|
|
||||||
|
|
||||||
|
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffer"/></h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<table class="table table-striped" id="foodOfferTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerBeginning"/></th>
|
||||||
|
<td><c:out value="${localDateTimeFormat.format(foodOffer.start)}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerEnding"/></th>
|
||||||
|
<td><c:out value="${localDateTimeFormat.format(foodOffer.end)}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="foodInOffer"/></th>
|
||||||
|
<td><c:out value="${foodOffer.food}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="discount"/></th>
|
||||||
|
<td><c:out value="${foodOffer.discount}"/></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerCode"/></th>
|
||||||
|
<td><c:out value="${foodOffer.code}"/></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="btn-return">
|
||||||
|
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||||
|
<fmt:message key="return"/> </button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<spring:url value="{foodOfferId}/edit" var="editUrl">
|
||||||
|
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||||
|
|
||||||
|
<spring:url value="{foodOfferId}/disable" var="editUrl">
|
||||||
|
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
|
||||||
|
|
||||||
|
</cheapy:layout>
|
|
@ -0,0 +1,42 @@
|
||||||
|
<%@ 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="NumOffers">
|
||||||
|
<h2>
|
||||||
|
<c:if test="${nuOffer['new']}">New </c:if> NuOffer
|
||||||
|
</h2>
|
||||||
|
<form:form modelAttribute="nuOffer" class="form-horizontal" id="add-nuOffer-form">
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<form:hidden path="id"/>
|
||||||
|
<form:hidden path="code"/>
|
||||||
|
<form:hidden path="status"/>
|
||||||
|
<petclinic:inputField label="Fecha de inicio" name="start"/>
|
||||||
|
<petclinic:inputField label="Fecha de fin" name="end"/>
|
||||||
|
|
||||||
|
<petclinic:inputField label="Oro" name="gold"/>
|
||||||
|
<petclinic:inputField label="descuento de oro" name="discountGold"/>
|
||||||
|
<petclinic:inputField label="Plata" name="silver"/>
|
||||||
|
<petclinic:inputField label="Descuento de plata" name="discountSilver"/>
|
||||||
|
<petclinic:inputField label="Bronce" name="bronze"/>
|
||||||
|
<petclinic:inputField label="Descuento de bronce" name="discountBronze"/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${nuOffer['new']}">
|
||||||
|
<button class="btn btn-default" type="submit">Crear oferta</button>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
<button class="btn btn-default" type="submit">Modificar</button>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form:form>
|
||||||
|
</petclinic:layout>
|
27
src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersDisable.jsp
Normal file
27
src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersDisable.jsp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<%@ 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="nuOffer">
|
||||||
|
|
||||||
|
<jsp:body>
|
||||||
|
<h2> ¿Esta seguro de que quiere dar de baja su offer? </h2>
|
||||||
|
|
||||||
|
<form:form modelAttribute="nuOffer" class="form-horizontal">
|
||||||
|
<input type="hidden" name="gold" value="${nu_offer.gold}" />
|
||||||
|
<input type="hidden" name="discountGold" value="${nu_offer.discount_gold}" />
|
||||||
|
<input type="hidden" name="silver" value="${nu_offer.silver}" />
|
||||||
|
<input type="hidden" name="discountSilver" value="${nu_offer.discount_silver}" />
|
||||||
|
<input type="hidden" name="bronze" value="${nu_offer.bronze}" />
|
||||||
|
<input type="hidden" name="discountBronze" value="${nu_offer.discount_bronze}" />
|
||||||
|
|
||||||
|
<button class="btn btn-default" type="submit">Dar de baja</button>
|
||||||
|
</form:form>
|
||||||
|
|
||||||
|
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||||
|
|
||||||
|
</jsp:body>
|
||||||
|
</petclinic:layout>
|
69
src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersShow.jsp
Normal file
69
src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersShow.jsp
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<%@ 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" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||||
|
|
||||||
|
<cheapy:layout pageName="nuOffer">
|
||||||
|
|
||||||
|
<h2 style="text-align:center;padding:5px"><fmt:message key="nuOffer"/></h2>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="table table-striped" id="nuOffer-table">
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerBeginning"/></th>
|
||||||
|
<td><c:out value="${localDateTimeFormat.format(nuOffer.start)}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerEnding"/></th>
|
||||||
|
<td><c:out value="${localDateTimeFormat.format(nuOffer.end)}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="goldGoal"/></th>
|
||||||
|
<td><c:out value="${nuOffer.gold}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="goldDiscount"/></th>
|
||||||
|
<td><c:out value="${nuOffer.discountGold}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="silverGoal"/></th>
|
||||||
|
<td><c:out value="${nuOffer.silver}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="silverDiscount"/></th>
|
||||||
|
<td><c:out value="${nuOffer.discountSilver}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Meta bronce</th>
|
||||||
|
<td><c:out value="${nuOffer.bronze}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="bronzeDiscount"/></th>
|
||||||
|
<td><c:out value="${nuOffer.discountBronze}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerCode"/></th>
|
||||||
|
<td><c:out value="${nuOffer.code}"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="btn-return">
|
||||||
|
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||||
|
<fmt:message key="return"/> </button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<spring:url value="{nuOfferId}/edit" var="editUrl">
|
||||||
|
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">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">Desactivar oferta</a>
|
||||||
|
|
||||||
|
</cheapy:layout>
|
158
src/main/webapp/WEB-INF/jsp/offers/offersList.jsp
Normal file
158
src/main/webapp/WEB-INF/jsp/offers/offersList.jsp
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
<%@ 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="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||||
|
|
||||||
|
<cheapy:layout pageName="ofertas">
|
||||||
|
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
|
||||||
|
|
||||||
|
<table id="foodOfferTable" class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||||
|
<th><fmt:message key="food"/></th>
|
||||||
|
<th><fmt:message key="startDate"/></th>
|
||||||
|
<th><fmt:message key="endDate"/></th>
|
||||||
|
<th> </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:forEach items="${foodOfferLs}" var="foodOffer">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<c:out value="${foodOffer.food}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:out value="${localDateTimeFormat.format(foodOffer.start)}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:out value="${localDateTimeFormat.format(foodOffer.end)}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<spring:url value="/offers/food/{foodOfferId}" var="foodOfferUrl">
|
||||||
|
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<div class="btn-detalles">
|
||||||
|
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||||
|
<fmt:message key="details"/></button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2 style="text-align:center;padding:5px"><fmt:message key="nuOffers"/></h2>
|
||||||
|
|
||||||
|
<table id="nuOfferTable" class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||||
|
<th><fmt:message key="startDate"/></th>
|
||||||
|
<th><fmt:message key="endDate"/></th>
|
||||||
|
<th> </th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:forEach items="${nuOfferLs}" var="nuOffer">
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<c:out value="${localDateTimeFormat.format(nuOffer.start)}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:out value="${localDateTimeFormat.format(nuOffer.end)}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<spring:url value="/offers/nu/{nuOfferId}" var="nuOfferUrl">
|
||||||
|
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<div class="btn-detalles">
|
||||||
|
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||||
|
<fmt:message key="details"/> </button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
|
||||||
|
|
||||||
|
<table id="speedOfferTable" class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||||
|
<th><fmt:message key="startDate"/></th>
|
||||||
|
<th><fmt:message key="endDate"/></th>
|
||||||
|
<th> </th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:forEach items="${speedOfferLs}" var="speedOffer">
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<c:out value="${localDateTimeFormat.format(speedOffer.start)}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:out value="${localDateTimeFormat.format(speedOffer.end)}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<spring:url value="/offers/speed/{speedOfferId}" var="speedOfferUrl">
|
||||||
|
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<div class="btn-detalles">
|
||||||
|
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||||
|
<fmt:message key="details"/> </button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
|
||||||
|
|
||||||
|
<table id="timeOfferTable" class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||||
|
<th><fmt:message key="startDate"/></th>
|
||||||
|
<th><fmt:message key="endDate"/></th>
|
||||||
|
<th> </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:forEach items="${timeOfferLs}" var="timeOffer">
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<c:out value="${localDateTimeFormat.format(timeOffer.start)}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:out value="${localDateTimeFormat.format(timeOffer.end)}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
|
||||||
|
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<div class="btn-detalles">
|
||||||
|
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||||
|
<fmt:message key="details"/> </button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</cheapy:layout>
|
|
@ -0,0 +1,40 @@
|
||||||
|
<%@ 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="speedOffers">
|
||||||
|
<h2>
|
||||||
|
<c:if test="${speedOffer['new']}">New </c:if> SpeedOffer
|
||||||
|
</h2>
|
||||||
|
<form:form modelAttribute="speedOffer" class="form-horizontal" id="add-speedOffer-form">
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<form:hidden path="id"/>
|
||||||
|
<form:hidden path="code"/>
|
||||||
|
<form:hidden path="status"/>
|
||||||
|
<petclinic:inputField label="Start Date" name="start"/>
|
||||||
|
<petclinic:inputField label="End Date" name="end"/>
|
||||||
|
<petclinic:inputField label="Gold" name="gold"/>
|
||||||
|
<petclinic:inputField label="Gold Discount" name="discountGold"/>
|
||||||
|
<petclinic:inputField label="Silver" name="silver"/>
|
||||||
|
<petclinic:inputField label="Silver Discount" name="discountSilver"/>
|
||||||
|
<petclinic:inputField label="Bronze" name="bronze"/>
|
||||||
|
<petclinic:inputField label="Bronze Discount" name="discountBronze"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${speedOffer['new']}">
|
||||||
|
<button class="btn btn-default" type="submit">Crear oferta</button>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
<button class="btn btn-default" type="submit">Modificar</button>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form:form>
|
||||||
|
</petclinic:layout>
|
|
@ -0,0 +1,27 @@
|
||||||
|
<%@ 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="speedOffer">
|
||||||
|
|
||||||
|
<jsp:body>
|
||||||
|
<h2> ¿Esta seguro de que quiere dar de baja su offer? </h2>
|
||||||
|
|
||||||
|
<form:form modelAttribute="speedOffer" class="form-horizontal">
|
||||||
|
<input type="hidden" name="gold" value="${nu_offer.gold}" />
|
||||||
|
<input type="hidden" name="discountGold" value="${nu_offer.discount_gold}" />
|
||||||
|
<input type="hidden" name="silver" value="${nu_offer.silver}" />
|
||||||
|
<input type="hidden" name="discountSilver" value="${nu_offer.discount_silver}" />
|
||||||
|
<input type="hidden" name="bronze" value="${nu_offer.bronze}" />
|
||||||
|
<input type="hidden" name="discountBronze" value="${nu_offer.discount_bronze}" />
|
||||||
|
|
||||||
|
<button class="btn btn-default" type="submit">Dar de baja</button>
|
||||||
|
</form:form>
|
||||||
|
|
||||||
|
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||||
|
|
||||||
|
</jsp:body>
|
||||||
|
</petclinic:layout>
|
69
src/main/webapp/WEB-INF/jsp/offers/speed/speedOffersShow.jsp
Normal file
69
src/main/webapp/WEB-INF/jsp/offers/speed/speedOffersShow.jsp
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<%@ 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" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||||
|
|
||||||
|
<cheapy:layout pageName="speedOffer">
|
||||||
|
|
||||||
|
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffer"/></h2>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="table table-striped" id="speedOffer-table">
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerBeginning"/></th>
|
||||||
|
<td><c:out value="${localDateTimeFormat.format(speedOffer.start)}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerEnding"/></th>
|
||||||
|
<td><c:out value="${localDateTimeFormat.format(speedOffer.end)}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="goldGoal"/></th>
|
||||||
|
<td><c:out value="${speedOffer.gold}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="goldDiscount"/></th>
|
||||||
|
<td><c:out value="${speedOffer.discountGold}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="silverGoal"/></th>
|
||||||
|
<td><c:out value="${speedOffer.silver}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="silverDiscount"/></th>
|
||||||
|
<td><c:out value="${speedOffer.discountSilver}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="bronzeGoal"/></th>
|
||||||
|
<td><c:out value="${speedOffer.bronze}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="bronzeDiscount"/></th>
|
||||||
|
<td><c:out value="${speedOffer.discountBronze}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerCode"/></th>
|
||||||
|
<td><c:out value="${speedOffer.code}"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="btn-return">
|
||||||
|
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||||
|
<fmt:message key="return"/> </button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<spring:url value="{speedOfferId}/edit" var="editUrl">
|
||||||
|
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||||
|
|
||||||
|
<spring:url value="{speedOfferId}/disable" var="editUrl">
|
||||||
|
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
|
||||||
|
|
||||||
|
</cheapy:layout>
|
|
@ -0,0 +1,40 @@
|
||||||
|
<%@ 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">
|
||||||
|
<form:hidden path="id"/>
|
||||||
|
<form:hidden path="code"/>
|
||||||
|
<form:hidden path="status"/>
|
||||||
|
<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="Descuento" 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>
|
|
@ -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>
|
51
src/main/webapp/WEB-INF/jsp/offers/time/timeOffersShow.jsp
Normal file
51
src/main/webapp/WEB-INF/jsp/offers/time/timeOffersShow.jsp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<%@ 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" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||||
|
|
||||||
|
<cheapy:layout pageName="timeOffer">
|
||||||
|
|
||||||
|
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffer"/></h2>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerBeginning"/></th>
|
||||||
|
<td><c:out value="${localDateTimeFormat.format(timeOffer.start)}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerEnding"/></th>
|
||||||
|
<td><c:out value="${localDateTimeFormat.format(timeOffer.end)}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="discount"/></th>
|
||||||
|
<td><c:out value="${timeOffer.discount}"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><fmt:message key="offerCode"/></th>
|
||||||
|
<td><c:out value="${timeOffer.code}"/></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<spring:url value="{timeOfferId}/edit" var="editUrl">
|
||||||
|
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||||
|
|
||||||
|
<spring:url value="{timeOfferId}/disable" var="editUrl">
|
||||||
|
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
|
||||||
|
|
||||||
|
<div class="btn-return">
|
||||||
|
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||||
|
<fmt:message key="return"/> </button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</cheapy:layout>
|
|
@ -2,21 +2,20 @@
|
||||||
<%@ 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="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<petclinic: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
|
||||||
</h2>
|
</h2>
|
||||||
<form:form modelAttribute="owner" class="form-horizontal" id="add-owner-form">
|
<form:form modelAttribute="owner" class="form-horizontal" id="add-owner-form">
|
||||||
<div class="form-group has-feedback">
|
<div class="form-group has-feedback">
|
||||||
<petclinic:inputField label="First Name" name="firstName"/>
|
<cheapy:inputField label="First Name" name="firstName"/>
|
||||||
<petclinic:inputField label="Last Name" name="lastName"/>
|
<cheapy:inputField label="Last Name" name="lastName"/>
|
||||||
<petclinic:inputField label="Address" name="address"/>
|
<cheapy:inputField label="Address" name="address"/>
|
||||||
<petclinic:inputField label="City" name="city"/>
|
<cheapy:inputField label="City" name="city"/>
|
||||||
<petclinic:inputField label="Telephone" name="telephone"/>
|
<cheapy:inputField label="Telephone" name="telephone"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
@ -31,4 +30,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form:form>
|
</form:form>
|
||||||
</petclinic:layout>
|
</cheapy:layout>
|
||||||
|
|
|
@ -2,13 +2,12 @@
|
||||||
<%@ 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="petclinic" 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" %>
|
||||||
<petclinic:layout pageName="owners">
|
<cheapy:layout pageName="owners">
|
||||||
|
|
||||||
<h2>Find Owners</h2>
|
<h2>Find Owners</h2>
|
||||||
|
|
||||||
|
@ -37,4 +36,4 @@
|
||||||
<a class="btn btn-default" href='<spring:url value="/owners/new" htmlEscape="true"/>'>Add Owner</a>
|
<a class="btn btn-default" href='<spring:url value="/owners/new" htmlEscape="true"/>'>Add Owner</a>
|
||||||
</sec:authorize>
|
</sec:authorize>
|
||||||
|
|
||||||
</petclinic:layout>
|
</cheapy:layout>
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<%@ 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="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<petclinic:layout pageName="owners">
|
<cheapy:layout pageName="owners">
|
||||||
|
|
||||||
<h2>Owner Information</h2>
|
<h2>Owner Information</h2>
|
||||||
|
|
||||||
|
@ -33,4 +32,4 @@
|
||||||
</spring:url>
|
</spring:url>
|
||||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a>
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a>
|
||||||
|
|
||||||
</petclinic:layout>
|
</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="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
<cheapy:layout pageName="owners">
|
||||||
|
|
||||||
<petclinic:layout pageName="owners">
|
|
||||||
<h2>Owners</h2>
|
<h2>Owners</h2>
|
||||||
|
|
||||||
<table id="ownersTable" class="table table-striped">
|
<table id="ownersTable" class="table table-striped">
|
||||||
|
@ -41,4 +40,4 @@
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</petclinic:layout>
|
</cheapy:layout>
|
||||||
|
|
|
@ -2,23 +2,22 @@
|
||||||
<%@ 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="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<petclinic: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
|
||||||
</h2>
|
</h2>
|
||||||
<form:form modelAttribute="owner" class="form-horizontal" id="add-owner-form">
|
<form:form modelAttribute="owner" class="form-horizontal" id="add-owner-form">
|
||||||
<div class="form-group has-feedback">
|
<div class="form-group has-feedback">
|
||||||
<petclinic:inputField label="First Name" name="firstName"/>
|
<cheapy:inputField label="First Name" name="firstName"/>
|
||||||
<petclinic:inputField label="Last Name" name="lastName"/>
|
<cheapy:inputField label="Last Name" name="lastName"/>
|
||||||
<petclinic:inputField label="Address" name="address"/>
|
<cheapy:inputField label="Address" name="address"/>
|
||||||
<petclinic:inputField label="City" name="city"/>
|
<cheapy:inputField label="City" name="city"/>
|
||||||
<petclinic:inputField label="Telephone" name="telephone"/>
|
<cheapy:inputField label="Telephone" name="telephone"/>
|
||||||
<petclinic:inputField label="Username" name="user.username"/>
|
<cheapy:inputField label="Username" name="user.username"/>
|
||||||
<petclinic:inputField label="Password" name="user.password"/>
|
<cheapy:inputField label="Password" name="user.password"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
@ -33,4 +32,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form:form>
|
</form:form>
|
||||||
</petclinic:layout>
|
</cheapy:layout>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<%@ 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="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||||
<!-- %@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %-->
|
<!-- %@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %-->
|
||||||
|
|
||||||
<petclinic: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,9 +14,10 @@
|
||||||
<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>
|
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||||
|
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
|
||||||
|
<fmt:message key="listOffers"/> </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</petclinic:layout>
|
</cheapy:layout>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
<%@ attribute name="menuName" required="true" rtexprvalue="true"
|
<%@ attribute name="menuName" required="true" rtexprvalue="true"
|
||||||
description="Name of the active menu: home, owners, vets or error" %>
|
description="Name of the active menu: home, ofertas, contactanos, login" %>
|
||||||
|
|
||||||
<petclinic:menu name="${menuName}"/>
|
<cheapy:menu name="${menuName}"/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
|
|
||||||
<%--
|
<%--
|
||||||
PetClinic :: a Spring Framework demonstration
|
Cheapy :: a Spring Framework demonstration
|
||||||
--%>
|
--%>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
@ -17,8 +17,8 @@ PetClinic :: a Spring Framework demonstration
|
||||||
<title>Cheapy : eat fast, eat cheapy</title>
|
<title>Cheapy : eat fast, eat cheapy</title>
|
||||||
|
|
||||||
<%-- CSS generated from LESS --%>
|
<%-- CSS generated from LESS --%>
|
||||||
<spring:url value="/resources/css/petclinic.css" var="petclinicCss"/>
|
<spring:url value="/resources/css/cheapy.css" var="cheapyCss"/>
|
||||||
<link href="${petclinicCss}" rel="stylesheet"/>
|
<link href="${cheapyCss}" rel="stylesheet"/>
|
||||||
|
|
||||||
|
|
||||||
<%-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --%>
|
<%-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --%>
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
<%@ tag trimDirectiveWhitespaces="true" %>
|
<%@ tag trimDirectiveWhitespaces="true" %>
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
<%@ attribute name="pageName" required="true" %>
|
<%@ attribute name="pageName" required="true" %>
|
||||||
<%@ attribute name="customScript" required="false" fragment="true"%>
|
<%@ attribute name="customScript" required="false" fragment="true"%>
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<petclinic:htmlHeader/>
|
<cheapy:htmlHeader/>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<petclinic:bodyHeader menuName="${pageName}"/>
|
<cheapy:bodyHeader menuName="${pageName}"/>
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="container xd-container">
|
<div class="container xd-container">
|
||||||
|
|
||||||
<jsp:doBody/>
|
<jsp:doBody/>
|
||||||
|
|
||||||
<petclinic:pivotal/>
|
<cheapy:pivotal/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<petclinic:footer/>
|
<cheapy:footer/>
|
||||||
<jsp:invoke fragment="customScript" />
|
<jsp:invoke fragment="customScript" />
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||||
<%@ taglib prefix="petclinic" 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"%-->
|
||||||
<%@ attribute name="name" required="true" rtexprvalue="true"
|
<%@ attribute name="name" required="true" rtexprvalue="true"
|
||||||
description="Name of the active menu: home, owners, vets or error"%>
|
description="Name of the active menu: home, ofertas, contactanos, login"%>
|
||||||
|
|
||||||
<nav class="navbar navbar-default" role="navigation">
|
<nav class="navbar navbar-default" role="navigation">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -22,30 +22,26 @@
|
||||||
<div class="navbar-collapse collapse" id="main-navbar">
|
<div class="navbar-collapse collapse" id="main-navbar">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
|
|
||||||
<petclinic:menuItem active="${name eq 'home'}" url="/"
|
<cheapy:menuItem active="${name eq 'home'}" url="/"
|
||||||
title="home page">
|
title="home page">
|
||||||
<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
|
||||||
<span>Home</span>
|
<span>Home</span>
|
||||||
</petclinic:menuItem>
|
</cheapy:menuItem>
|
||||||
|
|
||||||
<petclinic:menuItem active="${name eq 'ofertas'}" url="/ofertas"
|
<cheapy:menuItem active="${name eq 'ofertas'}" url="/offers"
|
||||||
title="ofertas">
|
title="ofertas">
|
||||||
<span class="glyphicon glyphicon-cutlery" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-cutlery" aria-hidden="true"></span>
|
||||||
<span>Ver ofertas</span>
|
<span>Ver ofertas</span>
|
||||||
</petclinic:menuItem>
|
</cheapy:menuItem>
|
||||||
|
|
||||||
<petclinic:menuItem active="${name eq 'contactanos'}" url="/contactanos"
|
<!--
|
||||||
|
<cheapy:menuItem active="${name eq 'contactanos'}" url="/contactanos"
|
||||||
title="contactanos">
|
title="contactanos">
|
||||||
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
|
||||||
<span>Contáctanos</span>
|
<span>Contáctanos</span>
|
||||||
</petclinic:menuItem>
|
</cheapy:menuItem>
|
||||||
|
-->
|
||||||
|
|
||||||
<petclinic:menuItem active="${name eq 'login'}" url="/login"
|
|
||||||
title="login">
|
|
||||||
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
|
|
||||||
<span>Login</span>
|
|
||||||
</petclinic:menuItem>
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -53,7 +49,7 @@
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<sec:authorize access="!isAuthenticated()">
|
<sec:authorize access="!isAuthenticated()">
|
||||||
<li><a href="<c:url value="/login" />">Login</a></li>
|
<li><a href="<c:url value="/login" />">Login</a></li>
|
||||||
<li><a href="<c:url value="/users/new" />">Register</a></li>
|
<!--<li><a href="<c:url value="/users/new" />">Register</a></li>-->
|
||||||
</sec:authorize>
|
</sec:authorize>
|
||||||
<sec:authorize access="isAuthenticated()">
|
<sec:authorize access="isAuthenticated()">
|
||||||
<li class="dropdown"><a href="#" class="dropdown-toggle"
|
<li class="dropdown"><a href="#" class="dropdown-toggle"
|
||||||
|
@ -64,20 +60,20 @@
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<div class="navbar-login">
|
<div class="navbar-login">
|
||||||
<div class="row">
|
<div class="row" >
|
||||||
<div class="col-lg-4">
|
<div class="col-lg-4" style="">
|
||||||
<p class="text-center">
|
<p class="text-center">
|
||||||
<span class="glyphicon glyphicon-user icon-size"></span>
|
<span class="glyphicon glyphicon-user icon-size" ></span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-8">
|
<div class="col-lg-8">
|
||||||
<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" style="align-content:center;color:white;background-color:#004080;padding:10px; border:none; text-align:center">
|
||||||
</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" />"
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 text-center"><img src="<spring:url value="/resources/images/eslogan.png" htmlEscape="true" />"
|
<div class="col-12 text-center"><img src="<spring:url value="/resources/images/eslogan.png" htmlEscape="true" />"
|
||||||
alt="Sponsored by Pivotal"/></div>
|
alt="Eat fast, eat cheapy"/></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<groups xmlns="http://www.isdc.ro/wro">
|
<groups xmlns="http://www.isdc.ro/wro">
|
||||||
<group name="petclinic">
|
<group name="cheapy">
|
||||||
<css>classpath:META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less</css>
|
<css>classpath:META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less</css>
|
||||||
<css>/petclinic.less</css>
|
<css>/cheapy.less</css>
|
||||||
</group>
|
</group>
|
||||||
</groups>
|
</groups>
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class PetclinicIntegrationTests {
|
class CheapyIntegrationTests {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.BDDMockito;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
import org.springframework.cheapy.configuration.SecurityConfiguration;
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.model.FoodOffer;
|
||||||
|
import org.springframework.cheapy.model.User;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
|
import org.springframework.cheapy.service.FoodOfferService;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.FilterType;
|
||||||
|
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
|
||||||
|
import org.springframework.security.test.context.support.WithMockUser;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@WebMvcTest(value = FoodOfferController.class,
|
||||||
|
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = WebSecurityConfigurer.class),
|
||||||
|
excludeAutoConfiguration = SecurityConfiguration.class)
|
||||||
|
class FoodOfferControllerTest {
|
||||||
|
|
||||||
|
private static final int TEST_CLIENT_ID = 1;
|
||||||
|
private static final int TEST_FOODOFFER_ID = 1;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private FoodOfferService foodOfferService;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private ClientService clientService;
|
||||||
|
|
||||||
|
private FoodOffer fo1;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setup() {
|
||||||
|
User user1 = new User();
|
||||||
|
user1.setUsername("user1");
|
||||||
|
user1.setPassword("user1");
|
||||||
|
Client client1 = new Client();;
|
||||||
|
client1.setId(TEST_CLIENT_ID);
|
||||||
|
client1.setName("client1");
|
||||||
|
client1.setEmail("client1");
|
||||||
|
client1.setAddress("client1");
|
||||||
|
client1.setInit("01:00");
|
||||||
|
client1.setFinish("01:01");
|
||||||
|
client1.setTelephone("123456789");
|
||||||
|
client1.setDescription("client1");
|
||||||
|
client1.setCode("client1");
|
||||||
|
client1.setFood("client1");
|
||||||
|
client1.setUsuar(user1);
|
||||||
|
BDDMockito.given(this.clientService.getCurrentClient()).willReturn(client1);
|
||||||
|
|
||||||
|
FoodOffer fo1test = new FoodOffer();
|
||||||
|
fo1test.setId(TEST_FOODOFFER_ID);
|
||||||
|
fo1test.setStart(LocalDateTime.of(2021, 12, 23, 12, 30));
|
||||||
|
fo1test.setEnd(LocalDateTime.of(2022, 12, 23, 12, 30));
|
||||||
|
fo1test.setFood("fo1test");
|
||||||
|
fo1test.setDiscount(1);
|
||||||
|
fo1test.setClient(client1);
|
||||||
|
this.fo1 = fo1test;
|
||||||
|
BDDMockito.given(this.foodOfferService.findFoodOfferById(TEST_FOODOFFER_ID)).willReturn(this.fo1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testInitCreationForm() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/food/new"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(model().attributeExists("foodOffer"))
|
||||||
|
.andExpect(view().name("offers/food/createOrUpdateFoodOfferForm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testProcessCreationFormSuccess() throws Exception {
|
||||||
|
mockMvc.perform(post("/offers/food/new")
|
||||||
|
.with(csrf())
|
||||||
|
.param("start", "23/12/2021 12:30")
|
||||||
|
.param("end", "23/12/2022 12:30")
|
||||||
|
.param("food", "food")
|
||||||
|
.param("discount", "10"))
|
||||||
|
.andExpect(status().is3xxRedirection());
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testProcessCreationFormHasErrors() throws Exception {
|
||||||
|
mockMvc.perform(post("/offers/food/new")
|
||||||
|
.with(csrf())
|
||||||
|
.param("start", "lsqdufhlqhf")
|
||||||
|
.param("end", "")
|
||||||
|
.param("food", "")
|
||||||
|
.param("discount", ""))
|
||||||
|
.andExpect(model().attributeHasErrors("foodOffer"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("foodOffer", "start"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("foodOffer", "end"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("foodOffer", "food"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("foodOffer", "discount"))
|
||||||
|
.andExpect(view().name("offers/food/createOrUpdateFoodOfferForm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "user1", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testActivateSuccess() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/food/{foodOfferId}/activate", TEST_FOODOFFER_ID))
|
||||||
|
.andExpect(status().is3xxRedirection())
|
||||||
|
.andExpect(view().name("redirect:/offers/food/"+TEST_FOODOFFER_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "user1", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testActivateHasErrors() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/food/{foodOfferId}/activate", TEST_FOODOFFER_ID+1))
|
||||||
|
.andExpect(view().name("exception"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.BDDMockito;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
import org.springframework.cheapy.configuration.SecurityConfiguration;
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.model.NuOffer;
|
||||||
|
import org.springframework.cheapy.model.User;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
|
import org.springframework.cheapy.service.NuOfferService;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.FilterType;
|
||||||
|
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
|
||||||
|
import org.springframework.security.test.context.support.WithMockUser;
|
||||||
|
import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
|
@WebMvcTest(value = NuOfferController.class,
|
||||||
|
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = WebSecurityConfigurer.class),
|
||||||
|
excludeAutoConfiguration = SecurityConfiguration.class)
|
||||||
|
class NuOfferControllerTest {
|
||||||
|
|
||||||
|
private static final int TEST_CLIENT_ID = 1;
|
||||||
|
private static final int TEST_NUOFFER_ID = 1;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private NuOfferService nuOfferService;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private ClientService clientService;
|
||||||
|
|
||||||
|
private NuOffer nu1;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setup() {
|
||||||
|
User user1 = new User();
|
||||||
|
user1.setUsername("user1");
|
||||||
|
user1.setPassword("user1");
|
||||||
|
Client client1 = new Client();
|
||||||
|
client1.setId(TEST_CLIENT_ID);
|
||||||
|
client1.setName("client1");
|
||||||
|
client1.setEmail("client1");
|
||||||
|
client1.setAddress("client1");
|
||||||
|
client1.setInit("01:00");
|
||||||
|
client1.setFinish("01:01");
|
||||||
|
client1.setTelephone("123456789");
|
||||||
|
client1.setDescription("client1");
|
||||||
|
client1.setCode("client1");
|
||||||
|
client1.setFood("client1");
|
||||||
|
client1.setUsuar(user1);
|
||||||
|
BDDMockito.given(this.clientService.getCurrentClient()).willReturn(client1);
|
||||||
|
|
||||||
|
NuOffer nu1test = new NuOffer();
|
||||||
|
nu1test.setId(TEST_NUOFFER_ID);
|
||||||
|
nu1test.setStart(LocalDateTime.of(2021, 12, 23, 12, 30));
|
||||||
|
nu1test.setEnd(LocalDateTime.of(2022, 12, 23, 12, 30));
|
||||||
|
nu1test.setGold(5);
|
||||||
|
nu1test.setDiscountGold(15);
|
||||||
|
nu1test.setSilver(10);
|
||||||
|
nu1test.setDiscountSilver(10);
|
||||||
|
nu1test.setBronze(15);
|
||||||
|
nu1test.setDiscountBronze(5);
|
||||||
|
nu1test.setClient(client1);
|
||||||
|
this.nu1 = nu1test;
|
||||||
|
BDDMockito.given(this.nuOfferService.findNuOfferById(TEST_NUOFFER_ID)).willReturn(this.nu1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testInitCreationForm() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/nu/new"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(model().attributeExists("nuOffer"))
|
||||||
|
.andExpect(view().name("offers/nu/createOrUpdateNuOfferForm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testProcessCreationFormSuccess() throws Exception {
|
||||||
|
mockMvc.perform(post("/offers/nu/new")
|
||||||
|
.with(SecurityMockMvcRequestPostProcessors.csrf())
|
||||||
|
.param("start", "23/12/2021 12:30")
|
||||||
|
.param("end", "23/12/2022 12:30")
|
||||||
|
.param("gold", "5")
|
||||||
|
.param("discountGold", "15")
|
||||||
|
.param("silver", "10")
|
||||||
|
.param("discountSilver", "10")
|
||||||
|
.param("bronze", "15")
|
||||||
|
.param("discountBronze", "5"))
|
||||||
|
.andExpect(status().is3xxRedirection());
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testProcessCreationFormHasErrors() throws Exception {
|
||||||
|
mockMvc.perform(post("/offers/nu/new")
|
||||||
|
.with(csrf())
|
||||||
|
.param("start", "lsqdufhlqhf")
|
||||||
|
.param("end", "")
|
||||||
|
.param("gold", "gold")
|
||||||
|
.param("discountGold", "")
|
||||||
|
.param("silver", "")
|
||||||
|
.param("discountSilver", "")
|
||||||
|
.param("bronze", "")
|
||||||
|
.param("discountBronze", ""))
|
||||||
|
.andExpect(model().attributeHasErrors("nuOffer"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("nuOffer", "start"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("nuOffer", "end"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("nuOffer", "gold"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("nuOffer", "discountGold"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("nuOffer", "silver"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("nuOffer", "discountSilver"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("nuOffer", "bronze"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("nuOffer", "discountBronze"))
|
||||||
|
.andExpect(view().name("offers/nu/createOrUpdateNuOfferForm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "user1", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testActivateSuccess() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/nu/{nuOfferId}/activate", TEST_NUOFFER_ID))
|
||||||
|
.andExpect(status().is3xxRedirection())
|
||||||
|
.andExpect(view().name("redirect:/offers/nu/"+TEST_NUOFFER_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "user1", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testActivateHasErrors() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/nu/{nuOfferId}/activate", TEST_NUOFFER_ID+1))
|
||||||
|
.andExpect(view().name("exception"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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"));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,150 @@
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.BDDMockito;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
import org.springframework.cheapy.configuration.SecurityConfiguration;
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
|
import org.springframework.cheapy.model.User;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
|
import org.springframework.cheapy.service.SpeedOfferService;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.FilterType;
|
||||||
|
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
|
||||||
|
import org.springframework.security.test.context.support.WithMockUser;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@WebMvcTest(value = SpeedOfferController.class,
|
||||||
|
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = WebSecurityConfigurer.class),
|
||||||
|
excludeAutoConfiguration = SecurityConfiguration.class)
|
||||||
|
class SpeedOfferControllerTest {
|
||||||
|
|
||||||
|
private static final int TEST_CLIENT_ID = 1;
|
||||||
|
private static final int TEST_SPEEDOFFER_ID = 1;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private SpeedOfferService speedOfferService;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private ClientService clientService;
|
||||||
|
|
||||||
|
private SpeedOffer sp1;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setup() {
|
||||||
|
User user1 = new User();
|
||||||
|
user1.setUsername("user1");
|
||||||
|
user1.setPassword("user1");
|
||||||
|
Client client1 = new Client();
|
||||||
|
client1.setId(TEST_CLIENT_ID);
|
||||||
|
client1.setName("client1");
|
||||||
|
client1.setEmail("client1");
|
||||||
|
client1.setAddress("client1");
|
||||||
|
client1.setInit("01:00");
|
||||||
|
client1.setFinish("01:01");
|
||||||
|
client1.setTelephone("123456789");
|
||||||
|
client1.setDescription("client1");
|
||||||
|
client1.setCode("client1");
|
||||||
|
client1.setFood("client1");
|
||||||
|
client1.setUsuar(user1);
|
||||||
|
BDDMockito.given(this.clientService.getCurrentClient()).willReturn(client1);
|
||||||
|
|
||||||
|
SpeedOffer sp1test = new SpeedOffer();
|
||||||
|
sp1test.setId(TEST_SPEEDOFFER_ID);
|
||||||
|
sp1test.setStart(LocalDateTime.of(2021, 12, 23, 12, 30));
|
||||||
|
sp1test.setEnd(LocalDateTime.of(2022, 12, 23, 12, 30));
|
||||||
|
sp1test.setGold(5);
|
||||||
|
sp1test.setDiscountGold(15);
|
||||||
|
sp1test.setSilver(10);
|
||||||
|
sp1test.setDiscountSilver(10);
|
||||||
|
sp1test.setBronze(15);
|
||||||
|
sp1test.setDiscountBronze(5);
|
||||||
|
sp1test.setClient(client1);
|
||||||
|
this.sp1 = sp1test;
|
||||||
|
BDDMockito.given(this.speedOfferService.findSpeedOfferById(TEST_SPEEDOFFER_ID)).willReturn(this.sp1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testInitCreationForm() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/speed/new"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(model().attributeExists("speedOffer"))
|
||||||
|
.andExpect(view().name("offers/speed/createOrUpdateSpeedOfferForm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testProcessCreationFormSuccess() throws Exception {
|
||||||
|
mockMvc.perform(post("/offers/speed/new")
|
||||||
|
.with(csrf())
|
||||||
|
.param("start", "23/12/2021 12:30")
|
||||||
|
.param("end", "23/12/2022 12:30")
|
||||||
|
.param("gold", "5")
|
||||||
|
.param("discountGold", "15")
|
||||||
|
.param("silver", "10")
|
||||||
|
.param("discountSilver", "10")
|
||||||
|
.param("bronze", "15")
|
||||||
|
.param("discountBronze", "5"))
|
||||||
|
.andExpect(status().is3xxRedirection());
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testProcessCreationFormHasErrors() throws Exception {
|
||||||
|
mockMvc.perform(post("/offers/speed/new")
|
||||||
|
.with(csrf())
|
||||||
|
.param("start", "lsqdufhlqhf")
|
||||||
|
.param("end", "")
|
||||||
|
.param("gold", "gold")
|
||||||
|
.param("discountGold", "")
|
||||||
|
.param("silver", "")
|
||||||
|
.param("discountSilver", "")
|
||||||
|
.param("bronze", "")
|
||||||
|
.param("discountBronze", ""))
|
||||||
|
.andExpect(model().attributeHasErrors("speedOffer"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("speedOffer", "start"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("speedOffer", "end"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("speedOffer", "gold"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("speedOffer", "discountGold"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("speedOffer", "silver"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("speedOffer", "discountSilver"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("speedOffer", "bronze"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("speedOffer", "discountBronze"))
|
||||||
|
.andExpect(view().name("offers/speed/createOrUpdateSpeedOfferForm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "user1", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testActivateSuccess() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/speed/{speedOfferId}/activate", TEST_SPEEDOFFER_ID))
|
||||||
|
.andExpect(status().is3xxRedirection())
|
||||||
|
.andExpect(view().name("redirect:/offers/speed/"+TEST_SPEEDOFFER_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "user1", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testActivateHasErrors() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/speed/{speedOfferId}/activate", TEST_SPEEDOFFER_ID+1))
|
||||||
|
.andExpect(view().name("exception"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
package org.springframework.cheapy.web;
|
||||||
|
|
||||||
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.BDDMockito;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
import org.springframework.cheapy.configuration.SecurityConfiguration;
|
||||||
|
import org.springframework.cheapy.model.Client;
|
||||||
|
import org.springframework.cheapy.model.TimeOffer;
|
||||||
|
import org.springframework.cheapy.model.User;
|
||||||
|
import org.springframework.cheapy.service.ClientService;
|
||||||
|
import org.springframework.cheapy.service.TimeOfferService;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.FilterType;
|
||||||
|
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
|
||||||
|
import org.springframework.security.test.context.support.WithMockUser;
|
||||||
|
import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
|
@WebMvcTest(value = TimeOfferController.class,
|
||||||
|
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = WebSecurityConfigurer.class),
|
||||||
|
excludeAutoConfiguration = SecurityConfiguration.class)
|
||||||
|
class TimeOfferControllerTest {
|
||||||
|
|
||||||
|
private static final int TEST_CLIENT_ID = 1;
|
||||||
|
private static final int TEST_TIMEOFFER_ID = 1;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private TimeOfferService timeOfferService;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private ClientService clientService;
|
||||||
|
|
||||||
|
private TimeOffer time1;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setup() {
|
||||||
|
User user1 = new User();
|
||||||
|
user1.setUsername("user1");
|
||||||
|
user1.setPassword("user1");
|
||||||
|
Client client1 = new Client();
|
||||||
|
client1.setId(TEST_CLIENT_ID);
|
||||||
|
client1.setName("client1");
|
||||||
|
client1.setEmail("client1");
|
||||||
|
client1.setAddress("client1");
|
||||||
|
client1.setInit("01:00");
|
||||||
|
client1.setFinish("01:01");
|
||||||
|
client1.setTelephone("123456789");
|
||||||
|
client1.setDescription("client1");
|
||||||
|
client1.setCode("client1");
|
||||||
|
client1.setFood("client1");
|
||||||
|
client1.setUsuar(user1);
|
||||||
|
BDDMockito.given(this.clientService.getCurrentClient()).willReturn(client1);
|
||||||
|
|
||||||
|
TimeOffer time1test = new TimeOffer();
|
||||||
|
time1test.setId(TEST_TIMEOFFER_ID);
|
||||||
|
time1test.setStart(LocalDateTime.of(2021, 12, 23, 12, 30));
|
||||||
|
time1test.setEnd(LocalDateTime.of(2022, 12, 23, 12, 30));
|
||||||
|
time1test.setInit(LocalTime.of(12, 00));
|
||||||
|
time1test.setFinish(LocalTime.of(13, 00));
|
||||||
|
time1test.setDiscount(10);
|
||||||
|
time1test.setClient(client1);
|
||||||
|
this.time1 = time1test;
|
||||||
|
BDDMockito.given(this.timeOfferService.findTimeOfferById(TEST_TIMEOFFER_ID)).willReturn(this.time1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testInitCreationForm() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/time/new"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(model().attributeExists("timeOffer"))
|
||||||
|
.andExpect(view().name("offers/time/createOrUpdateTimeOfferForm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testProcessCreationFormSuccess() throws Exception {
|
||||||
|
mockMvc.perform(post("/offers/time/new")
|
||||||
|
.with(SecurityMockMvcRequestPostProcessors.csrf())
|
||||||
|
.param("start", "23/12/2021 12:30")
|
||||||
|
.param("end", "23/12/2022 12:30")
|
||||||
|
.param("init", "12:30")
|
||||||
|
.param("finish", "13:30")
|
||||||
|
.param("discount", "10"))
|
||||||
|
.andExpect(status().is3xxRedirection());
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "spring", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testProcessCreationFormHasErrors() throws Exception {
|
||||||
|
mockMvc.perform(post("/offers/time/new")
|
||||||
|
.with(csrf())
|
||||||
|
.param("start", "lsqdufhlqhf")
|
||||||
|
.param("end", "")
|
||||||
|
.param("init", "gold")
|
||||||
|
.param("finish", "")
|
||||||
|
.param("discount", ""))
|
||||||
|
.andExpect(model().attributeHasErrors("timeOffer"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("timeOffer", "start"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("timeOffer", "end"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("timeOffer", "init"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("timeOffer", "finish"))
|
||||||
|
.andExpect(model().attributeHasFieldErrors("timeOffer", "discount"))
|
||||||
|
.andExpect(view().name("offers/time/createOrUpdateTimeOfferForm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "user1", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testActivateSuccess() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/time/{timeOfferId}/activate", TEST_TIMEOFFER_ID))
|
||||||
|
.andExpect(status().is3xxRedirection())
|
||||||
|
.andExpect(view().name("redirect:/offers/time/"+TEST_TIMEOFFER_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithMockUser(value = "user1", authorities = "client")
|
||||||
|
@Test
|
||||||
|
void testActivateHasErrors() throws Exception {
|
||||||
|
mockMvc.perform(get("/offers/time/{timeOfferId}/activate", TEST_TIMEOFFER_ID+1))
|
||||||
|
.andExpect(view().name("exception"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -7,13 +7,13 @@
|
||||||
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
|
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
|
||||||
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
|
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
|
||||||
<collectionProp name="Arguments.arguments">
|
<collectionProp name="Arguments.arguments">
|
||||||
<elementProp name="PETCLINIC_HOST" elementType="Argument">
|
<elementProp name="CHEAPY_HOST" elementType="Argument">
|
||||||
<stringProp name="Argument.name">PETCLINIC_HOST</stringProp>
|
<stringProp name="Argument.name">CHEAPY_HOST</stringProp>
|
||||||
<stringProp name="Argument.value">localhost</stringProp>
|
<stringProp name="Argument.value">localhost</stringProp>
|
||||||
<stringProp name="Argument.metadata">=</stringProp>
|
<stringProp name="Argument.metadata">=</stringProp>
|
||||||
</elementProp>
|
</elementProp>
|
||||||
<elementProp name="PETCLINIC_PORT" elementType="Argument">
|
<elementProp name="CHEAPY_PORT" elementType="Argument">
|
||||||
<stringProp name="Argument.name">PETCLINIC_PORT</stringProp>
|
<stringProp name="Argument.name">CHEAPY_PORT</stringProp>
|
||||||
<stringProp name="Argument.value">8080</stringProp>
|
<stringProp name="Argument.value">8080</stringProp>
|
||||||
<stringProp name="Argument.metadata">=</stringProp>
|
<stringProp name="Argument.metadata">=</stringProp>
|
||||||
</elementProp>
|
</elementProp>
|
||||||
|
@ -52,8 +52,8 @@
|
||||||
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
|
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
|
||||||
<collectionProp name="Arguments.arguments"/>
|
<collectionProp name="Arguments.arguments"/>
|
||||||
</elementProp>
|
</elementProp>
|
||||||
<stringProp name="HTTPSampler.domain">${PETCLINIC_HOST}</stringProp>
|
<stringProp name="HTTPSampler.domain">${CHEAPY_HOST}</stringProp>
|
||||||
<stringProp name="HTTPSampler.port">${PETCLINIC_PORT}</stringProp>
|
<stringProp name="HTTPSampler.port">${CHEAPY_PORT}</stringProp>
|
||||||
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
||||||
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||||
<stringProp name="HTTPSampler.protocol"></stringProp>
|
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||||
<stringProp name="HTTPSampler.protocol"></stringProp>
|
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||||
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
||||||
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/resources/css/petclinic.css</stringProp>
|
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/resources/css/cheapy.css</stringProp>
|
||||||
<stringProp name="HTTPSampler.method">GET</stringProp>
|
<stringProp name="HTTPSampler.method">GET</stringProp>
|
||||||
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
|
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
|
||||||
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
Loading…
Reference in a new issue