diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 5166fe90f..000000000 --- a/docker-compose.yml +++ /dev/null @@ -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" diff --git a/pom.xml b/pom.xml index 60be53522..c0ab78aad 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,11 @@ org.springframework.security spring-security-taglibs + + org.springframework.security + spring-security-test + test + org.springframework.boot spring-boot-starter-security @@ -135,7 +140,10 @@ spring-boot-devtools true + + + diff --git a/src/main/java/org/springframework/cheapy/CheapyApplication.java b/src/main/java/org/springframework/cheapy/CheapyApplication.java index 2912ee3d8..3df17e2bb 100644 --- a/src/main/java/org/springframework/cheapy/CheapyApplication.java +++ b/src/main/java/org/springframework/cheapy/CheapyApplication.java @@ -20,7 +20,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** - * PetClinic Spring Boot Application. + * Cheapy Spring Boot Application. * * @author Dave Syer * diff --git a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java index 2fbdc84ad..7189740f2 100644 --- a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java +++ b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java @@ -20,9 +20,7 @@ import org.springframework.security.crypto.password.PasswordEncoder; * and open the template in the editor. */ -/** - * @author japarejo - */ + @Configuration @EnableWebSecurity public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @@ -37,19 +35,32 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { http.authorizeRequests().antMatchers("/resources/**", "/webjars/**", "/h2-console/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/oups").permitAll() .antMatchers("/users/new").permitAll() + + .antMatchers("/login/**").anonymous() + .antMatchers("/logout").permitAll() + .antMatchers("/usuarios/new").permitAll() .antMatchers("/admin/**").hasAnyAuthority("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() - /* .loginPage("/login") */ - .failureUrl("/login-error").and().logout().logoutSuccessUrl("/"); + .loginPage("/login").permitAll() + .failureUrl("/login?error") + .and().logout().logoutSuccessUrl("/login"); // Configuración para que funcione la consola de administración // de la BD H2 (deshabilitar las cabeceras de protección contra // ataques de tipo csrf y habilitar los framesets si su contenido // se sirve desde esta misma página. - http.csrf().ignoringAntMatchers("/h2-console/**"); + //http.csrf().ignoringAntMatchers("/h2-console/**"); http.headers().frameOptions().sameOrigin(); } @@ -58,7 +69,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { public void configure(final AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().dataSource(this.dataSource) //[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()); } diff --git a/src/main/java/org/springframework/cheapy/model/Administrator.java b/src/main/java/org/springframework/cheapy/model/Administrator.java index 736908254..44a3ffdf6 100644 --- a/src/main/java/org/springframework/cheapy/model/Administrator.java +++ b/src/main/java/org/springframework/cheapy/model/Administrator.java @@ -6,5 +6,10 @@ import javax.persistence.Table; @Entity @Table(name = "administrators") public class Administrator extends User{ + + /** + * + */ + private static final long serialVersionUID = 1L; } diff --git a/src/main/java/org/springframework/cheapy/model/Authorities.java b/src/main/java/org/springframework/cheapy/model/Authorities.java index 7ec1f6666..3bcfbbb35 100644 --- a/src/main/java/org/springframework/cheapy/model/Authorities.java +++ b/src/main/java/org/springframework/cheapy/model/Authorities.java @@ -1,47 +1,58 @@ package org.springframework.cheapy.model; import javax.persistence.Entity; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import javax.persistence.Id; import javax.persistence.Table; -import javax.validation.constraints.Size; @Entity @Table(name = "authorities") -public class Authorities extends BaseEntity{ +public class Authorities{ + @Id + String username; - /** - * - */ - private static final long serialVersionUID = 1L; - - @ManyToOne - @JoinColumn(name = "username") - private Usuario user; - - @Size(min = 3, max = 50) - private String authority; - - public Usuario getUser() { - return user; + String authority; + + public String getUsername() { + return username; } - - public void setUser(Usuario usern) { - this.user = usern; + public void setUsername(String username) { + this.username = username; } - public String getAuthority() { return authority; } - public void setAuthority(String 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; +// } } diff --git a/src/main/java/org/springframework/cheapy/model/BaseEntity.java b/src/main/java/org/springframework/cheapy/model/BaseEntity.java index 21aab45b7..95e0b3338 100644 --- a/src/main/java/org/springframework/cheapy/model/BaseEntity.java +++ b/src/main/java/org/springframework/cheapy/model/BaseEntity.java @@ -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; import java.io.Serializable; @@ -22,16 +7,14 @@ import javax.persistence.GenerationType; import javax.persistence.Id; 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 public class BaseEntity implements Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; diff --git a/src/main/java/org/springframework/cheapy/model/Client.java b/src/main/java/org/springframework/cheapy/model/Client.java index b249311ff..23fa89b80 100644 --- a/src/main/java/org/springframework/cheapy/model/Client.java +++ b/src/main/java/org/springframework/cheapy/model/Client.java @@ -2,24 +2,41 @@ package org.springframework.cheapy.model; import java.util.Set; +import javax.persistence.CascadeType; import javax.persistence.Entity; +import javax.persistence.JoinColumn; import javax.persistence.OneToMany; +import javax.persistence.OneToOne; import javax.persistence.Table; import javax.validation.constraints.Digits; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; @Entity @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 private String email; - + @NotEmpty private String address; - @NotEmpty - private String timetable; + // Hora de apertura del local + @NotBlank + private String init; + + // Hora de cierre del local + @NotBlank + private String finish; @NotEmpty @Digits(fraction = 0, integer = 10) @@ -28,32 +45,45 @@ public class Client extends User { @NotEmpty private String description; + // Codigo de activacion de cuenta @NotEmpty private String code; @NotEmpty private String food; - + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "username", referencedColumnName = "username") + private User usuar; + @OneToMany private Set foodOffers; - + @OneToMany private Set nuOffers; - + @OneToMany private Set speedOffers; - + @OneToMany private Set timeOffers; - + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public String getEmail() { return email; } - + public void setEmail(String email) { this.email = email; } - + public String getAddress() { return address; } @@ -62,12 +92,20 @@ public class Client extends User { this.address = address; } - public String getTimetable() { - return timetable; + public String getInit() { + return init; } - public void setTimetable(String timetable) { - this.timetable = timetable; + public void setInit(String init) { + this.init = init; + } + + public String getFinish() { + return finish; + } + + public void setFinish(String finish) { + this.finish = finish; } public String getTelephone() { @@ -101,4 +139,45 @@ public class Client extends User { public void setFood(String food) { this.food = food; } + + public User getUsuar() { + return usuar; + } + + public void setUsuar(User usuar) { + this.usuar = usuar; + } + + public Set getFoodOffers() { + return foodOffers; + } + + public void setFoodOffers(Set foodOffers) { + this.foodOffers = foodOffers; + } + + public Set getNuOffers() { + return nuOffers; + } + + public void setNuOffers(Set nuOffers) { + this.nuOffers = nuOffers; + } + + public Set getSpeedOffers() { + return speedOffers; + } + + public void setSpeedOffers(Set speedOffers) { + this.speedOffers = speedOffers; + } + + public Set getTimeOffers() { + return timeOffers; + } + + public void setTimeOffers(Set timeOffers) { + this.timeOffers = timeOffers; + } + } \ No newline at end of file diff --git a/src/main/java/org/springframework/cheapy/model/FoodOffer.java b/src/main/java/org/springframework/cheapy/model/FoodOffer.java index b82fed73b..3cb6a1e56 100644 --- a/src/main/java/org/springframework/cheapy/model/FoodOffer.java +++ b/src/main/java/org/springframework/cheapy/model/FoodOffer.java @@ -17,20 +17,23 @@ package org.springframework.cheapy.model; import javax.persistence.Entity; import javax.persistence.Table; +import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; @Entity @Table(name = "food_offers") public class FoodOffer extends Offer { + + private static final long serialVersionUID = 1L; + //Plato específico @NotBlank private String food; - @NotBlank - private String discount; - - @NotBlank - private Integer units; // revisar + @NotNull + @Min(0) + private Integer discount; public String getFood() { return food; @@ -40,20 +43,12 @@ public class FoodOffer extends Offer { this.food = food; } - public String getDiscount() { + public Integer getDiscount() { return discount; } - public void setDiscount(String discount) { + public void setDiscount(Integer discount) { this.discount = discount; } - public Integer getUnits() { - return units; - } - - public void setUnits(Integer units) { - this.units = units; - } - } \ No newline at end of file diff --git a/src/main/java/org/springframework/cheapy/model/NamedEntity.java b/src/main/java/org/springframework/cheapy/model/NamedEntity.java index 0f00a5e9c..3d777b298 100644 --- a/src/main/java/org/springframework/cheapy/model/NamedEntity.java +++ b/src/main/java/org/springframework/cheapy/model/NamedEntity.java @@ -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; import javax.persistence.Column; import javax.persistence.MappedSuperclass; -/** - * Simple JavaBean domain object adds a name property to BaseEntity. Used as - * a base class for objects needing these properties. - * - * @author Ken Krebs - * @author Juergen Hoeller - */ @MappedSuperclass public class NamedEntity extends BaseEntity { + /** + * + */ + private static final long serialVersionUID = 1L; + @Column(name = "name") private String name; diff --git a/src/main/java/org/springframework/cheapy/model/NuOffer.java b/src/main/java/org/springframework/cheapy/model/NuOffer.java index 05d66a688..6f250737d 100644 --- a/src/main/java/org/springframework/cheapy/model/NuOffer.java +++ b/src/main/java/org/springframework/cheapy/model/NuOffer.java @@ -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; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; -import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; @Entity @Table(name = "nu_offers") public class NuOffer extends Offer { - @NotBlank - private Integer gold; + //Oferta por numero de comensales + private static final long serialVersionUID = 1L; + + @NotNull + @Min(1) + private Integer gold; @Column(name = "discount_gold") - @NotBlank - private String discountGold; + @NotNull + @Min(0) + private Integer discountGold; - @NotBlank - private Integer silver; + @NotNull + @Min(1) + private Integer silver; @Column(name = "discount_silver") - @NotBlank - private String discountSilver; + @NotNull + @Min(0) + private Integer discountSilver; - @NotBlank - private Integer bronze; + @NotNull + @Min(1) + private Integer bronze; @Column(name = "discount_bronze") - @NotBlank - private String discountBronze; + @NotNull + @Min(0) + private Integer discountBronze; public Integer getGold() { return gold; @@ -53,11 +48,11 @@ public class NuOffer extends Offer { this.gold = gold; } - public String getDiscountGold() { + public Integer getDiscountGold() { return discountGold; } - public void setDiscountGold(String discountGold) { + public void setDiscountGold(Integer discountGold) { this.discountGold = discountGold; } @@ -69,11 +64,11 @@ public class NuOffer extends Offer { this.silver = silver; } - public String getDiscountSilver() { + public Integer getDiscountSilver() { return discountSilver; } - public void setDiscountSilver(String discountSilver) { + public void setDiscountSilver(Integer discountSilver) { this.discountSilver = discountSilver; } @@ -85,12 +80,12 @@ public class NuOffer extends Offer { this.bronze = bronze; } - public String getDiscountBronze() { + public Integer getDiscountBronze() { return discountBronze; } - public void setDiscountBronze(String discountBronze) { + public void setDiscountBronze(Integer discountBronze) { this.discountBronze = discountBronze; } -} \ No newline at end of file +} diff --git a/src/main/java/org/springframework/cheapy/model/Offer.java b/src/main/java/org/springframework/cheapy/model/Offer.java index 4c3921b1b..5ae64feba 100644 --- a/src/main/java/org/springframework/cheapy/model/Offer.java +++ b/src/main/java/org/springframework/cheapy/model/Offer.java @@ -17,39 +17,40 @@ package org.springframework.cheapy.model; import java.time.LocalDateTime; -import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.MappedSuperclass; -import javax.persistence.Table; import javax.validation.constraints.Future; -import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import org.springframework.format.annotation.DateTimeFormat; @MappedSuperclass public class Offer extends BaseEntity { + private static final long serialVersionUID = 1L; + + // Clase padre + @DateTimeFormat(pattern = "dd/MM/yyyy HH:mm") - @NotBlank + @NotNull @Future private LocalDateTime start; @DateTimeFormat(pattern = "dd/MM/yyyy HH:mm") - @NotBlank + @NotNull @Future private LocalDateTime end; - @NotBlank private String code; @Enumerated(value = EnumType.STRING) - private StatusOffer type; - + private StatusOffer status; + @ManyToOne - @JoinColumn(name="client_id") + @JoinColumn(name = "client_id") private Client client; public LocalDateTime getStart() { @@ -76,12 +77,20 @@ public class Offer extends BaseEntity { this.code = code; } - public StatusOffer getType() { - return type; + public StatusOffer getStatus() { + return status; } - public void setType(StatusOffer type) { - this.type = type; + public void setStatus(StatusOffer type) { + this.status = type; + } + + public Client getClient() { + return client; + } + + public void setClient(Client client) { + this.client = client; } } diff --git a/src/main/java/org/springframework/cheapy/model/Owner.java b/src/main/java/org/springframework/cheapy/model/Owner.java index 792f42753..7a04f3434 100644 --- a/src/main/java/org/springframework/cheapy/model/Owner.java +++ b/src/main/java/org/springframework/cheapy/model/Owner.java @@ -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; -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.Entity; -import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotEmpty; -import org.springframework.beans.support.MutableSortDefinition; -import org.springframework.beans.support.PropertyComparator; 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 @Table(name = "owners") public class Owner extends Person { + /** + * + */ + private static final long serialVersionUID = 1L; + @Column(name = "address") @NotEmpty private String address; diff --git a/src/main/java/org/springframework/cheapy/model/Person.java b/src/main/java/org/springframework/cheapy/model/Person.java index 7e8d87c0c..8758455db 100644 --- a/src/main/java/org/springframework/cheapy/model/Person.java +++ b/src/main/java/org/springframework/cheapy/model/Person.java @@ -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; import javax.persistence.Column; import javax.persistence.MappedSuperclass; import javax.validation.constraints.NotEmpty; -/** - * Simple JavaBean domain object representing an person. - * - * @author Ken Krebs - */ @MappedSuperclass public class Person extends BaseEntity { + /** + * + */ + private static final long serialVersionUID = 1L; + @Column(name = "first_name") @NotEmpty private String firstName; diff --git a/src/main/java/org/springframework/cheapy/model/SpeedOffer.java b/src/main/java/org/springframework/cheapy/model/SpeedOffer.java index 0399d4baf..84b551829 100644 --- a/src/main/java/org/springframework/cheapy/model/SpeedOffer.java +++ b/src/main/java/org/springframework/cheapy/model/SpeedOffer.java @@ -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; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; -import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; @Entity @Table(name = "speed_offers") public class SpeedOffer extends Offer { - @NotBlank - private Integer gold; // x minutos + // Ofertar por rapidez comiendo + private static final long serialVersionUID = 1L; + + @NotNull + @Min(0) + private Integer gold; @Column(name = "discount_gold") - @NotBlank - private String discountGold; + @NotNull + @Min(0) + private Integer discountGold; - @NotBlank + @NotNull + @Min(0) private Integer silver; @Column(name = "discount_silver") - @NotBlank - private String discountSilver; + @NotNull + @Min(0) + private Integer discountSilver; - @NotBlank + @NotNull + @Min(0) private Integer bronze; @Column(name = "discount_bronze") - @NotBlank - private String discountBronze; + @NotNull + @Min(0) + private Integer discountBronze; public Integer getGold() { return gold; @@ -53,11 +48,11 @@ public class SpeedOffer extends Offer { this.gold = gold; } - public String getDiscountGold() { + public Integer getDiscountGold() { return discountGold; } - public void setDiscountGold(String discountGold) { + public void setDiscountGold(Integer discountGold) { this.discountGold = discountGold; } @@ -69,11 +64,11 @@ public class SpeedOffer extends Offer { this.silver = silver; } - public String getDiscountSilver() { + public Integer getDiscountSilver() { return discountSilver; } - public void setDiscountSilver(String discountSilver) { + public void setDiscountSilver(Integer discountSilver) { this.discountSilver = discountSilver; } @@ -85,12 +80,12 @@ public class SpeedOffer extends Offer { this.bronze = bronze; } - public String getDiscountBronze() { + public Integer getDiscountBronze() { return discountBronze; } - public void setDiscountBronze(String discountBronze) { + public void setDiscountBronze(Integer discountBronze) { this.discountBronze = discountBronze; } -} \ No newline at end of file +} diff --git a/src/main/java/org/springframework/cheapy/model/TimeOffer.java b/src/main/java/org/springframework/cheapy/model/TimeOffer.java index 7f1d3cc6d..44ae5e3d6 100644 --- a/src/main/java/org/springframework/cheapy/model/TimeOffer.java +++ b/src/main/java/org/springframework/cheapy/model/TimeOffer.java @@ -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; -import java.time.LocalDateTime; import java.time.LocalTime; import javax.persistence.Entity; import javax.persistence.Table; -import javax.validation.constraints.Future; -import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import org.springframework.format.annotation.DateTimeFormat; @@ -29,24 +12,42 @@ import org.springframework.format.annotation.DateTimeFormat; @Table(name = "time_offers") public class TimeOffer extends Offer { + private static final long serialVersionUID = 1L; + + // Oferta por franja horaria + @DateTimeFormat(pattern = "HH:mm") - @NotBlank + @NotNull private LocalTime init; @DateTimeFormat(pattern = "HH:mm") - @NotBlank + @NotNull private LocalTime finish; - @NotBlank - private String discount; + @NotNull + 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; } - public void setDiscount(String discount) { + public void setDiscount(Integer discount) { this.discount = discount; } diff --git a/src/main/java/org/springframework/cheapy/model/User.java b/src/main/java/org/springframework/cheapy/model/User.java index 36d495444..e9c232562 100644 --- a/src/main/java/org/springframework/cheapy/model/User.java +++ b/src/main/java/org/springframework/cheapy/model/User.java @@ -1,23 +1,12 @@ package org.springframework.cheapy.model; -import java.util.List; -import java.util.Set; - -import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.Id; -import javax.persistence.MappedSuperclass; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; import javax.persistence.Table; -import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -//@Entity -//@Table(name = "users") -@MappedSuperclass +@Entity +@Table(name = "users") public class User{ @Id @@ -27,7 +16,8 @@ public class User{ private String password; boolean enabled; - + + private static final long serialVersionUID = 1L; public String getUsername() { @@ -46,11 +36,4 @@ public class User{ this.password = password; } -// public Set getAuthority() { -// return authorities; -// } -// -// public void setAuthorities(Set authorities) { -// this.authorities = authorities; -// } } diff --git a/src/main/java/org/springframework/cheapy/model/Usuario.java b/src/main/java/org/springframework/cheapy/model/Usuario.java index 3556ff16c..9079bc72e 100644 --- a/src/main/java/org/springframework/cheapy/model/Usuario.java +++ b/src/main/java/org/springframework/cheapy/model/Usuario.java @@ -1,26 +1,101 @@ package org.springframework.cheapy.model; -import java.util.Set; - import javax.persistence.CascadeType; import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.OneToMany; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; import javax.persistence.Table; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; @Entity -@Table(name = "users") -public class Usuario extends User{ +@Table(name = "usuarios") +public class Usuario extends BaseEntity{ - @OneToMany(cascade = CascadeType.ALL, mappedBy = "user") - private Set authorities; + /** nombre, apellidos, dni, direccion, telefono, email, username + * (id,nombre, apellidos, dni, direccion, telefono, email, usuar) + */ + private static final long serialVersionUID = 1L; - public Set getAuthorities() { - return authorities; + @NotBlank + 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) { - this.authorities = authorities; + public void setNombre(String nombre) { + 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; + } + } diff --git a/src/main/java/org/springframework/cheapy/model/package-info.java b/src/main/java/org/springframework/cheapy/model/package-info.java index 620e13c68..1bc54373f 100644 --- a/src/main/java/org/springframework/cheapy/model/package-info.java +++ b/src/main/java/org/springframework/cheapy/model/package-info.java @@ -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; diff --git a/src/main/java/org/springframework/cheapy/repository/AuthoritiesRepository.java b/src/main/java/org/springframework/cheapy/repository/AuthoritiesRepository.java index a8adee7f7..8d5f6317c 100644 --- a/src/main/java/org/springframework/cheapy/repository/AuthoritiesRepository.java +++ b/src/main/java/org/springframework/cheapy/repository/AuthoritiesRepository.java @@ -2,8 +2,6 @@ package org.springframework.cheapy.repository; import org.springframework.data.repository.CrudRepository; import org.springframework.cheapy.model.Authorities; -import org.springframework.cheapy.model.User; - public interface AuthoritiesRepository extends CrudRepository{ diff --git a/src/main/java/org/springframework/cheapy/repository/ClientRepository.java b/src/main/java/org/springframework/cheapy/repository/ClientRepository.java new file mode 100644 index 000000000..1e04f6f3a --- /dev/null +++ b/src/main/java/org/springframework/cheapy/repository/ClientRepository.java @@ -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 { + + @Query("SELECT client FROM Client client WHERE username =:username") + @Transactional(readOnly = true) + Client findByUsername(String username); + +} diff --git a/src/main/java/org/springframework/cheapy/repository/FoodOfferRepository.java b/src/main/java/org/springframework/cheapy/repository/FoodOfferRepository.java new file mode 100644 index 000000000..80fadc686 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/repository/FoodOfferRepository.java @@ -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 { + + @Query("SELECT foodOffer FROM FoodOffer foodOffer") + @Transactional(readOnly = true) + List findAllFoodOffer(); + + @Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE id =:id") + @Transactional(readOnly = true) + FoodOffer findById(@Param("id") Integer id); + + void save(FoodOffer foodOffer); + +} diff --git a/src/main/java/org/springframework/cheapy/repository/NuOfferRepository.java b/src/main/java/org/springframework/cheapy/repository/NuOfferRepository.java new file mode 100644 index 000000000..42d437fdb --- /dev/null +++ b/src/main/java/org/springframework/cheapy/repository/NuOfferRepository.java @@ -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 findNuOfferById(int nuOfferId); + + @Query("SELECT nuOffer FROM NuOffer nuOffer") + @Transactional(readOnly = true) + List findAllNuOffer(); + + void save(NuOffer nuOffer); + +} diff --git a/src/main/java/org/springframework/cheapy/repository/SpeedOfferRepository.java b/src/main/java/org/springframework/cheapy/repository/SpeedOfferRepository.java new file mode 100644 index 000000000..aef04d36d --- /dev/null +++ b/src/main/java/org/springframework/cheapy/repository/SpeedOfferRepository.java @@ -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 { + + @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 findAllSpeedOffer(); + + void save(SpeedOffer speedOffer); + +} diff --git a/src/main/java/org/springframework/cheapy/repository/TimeOfferRepository.java b/src/main/java/org/springframework/cheapy/repository/TimeOfferRepository.java new file mode 100644 index 000000000..b663057a7 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/repository/TimeOfferRepository.java @@ -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 findTimeOfferById(int timeOfferId); + + @Query("SELECT timeOffer FROM TimeOffer timeOffer") + @Transactional(readOnly = true) + List findAllTimeOffer(); + + void save(TimeOffer timeOffer); + +} diff --git a/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java b/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java index 3b5ffc987..1bd7c8ee2 100644 --- a/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java +++ b/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java @@ -2,11 +2,10 @@ package org.springframework.cheapy.repository; import org.springframework.data.repository.CrudRepository; -import org.springframework.cheapy.model.User; import org.springframework.cheapy.model.Usuario; public interface UsuarioRepository extends CrudRepository { - Usuario findByUsername(String currentPrincipalName); + //Usuario findByUsername(String currentPrincipalName); } diff --git a/src/main/java/org/springframework/cheapy/service/ClientService.java b/src/main/java/org/springframework/cheapy/service/ClientService.java new file mode 100644 index 000000000..d65649680 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/service/ClientService.java @@ -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); + } + +} diff --git a/src/main/java/org/springframework/cheapy/service/FoodOfferService.java b/src/main/java/org/springframework/cheapy/service/FoodOfferService.java new file mode 100644 index 000000000..d23ffc321 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/service/FoodOfferService.java @@ -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 findAllFoodOffer() { // + return this.foodOfferRepository.findAllFoodOffer(); + } + + public void saveFoodOffer(final FoodOffer foodOffer) throws DataAccessException { + this.foodOfferRepository.save(foodOffer); + + } +} diff --git a/src/main/java/org/springframework/cheapy/service/NuOfferService.java b/src/main/java/org/springframework/cheapy/service/NuOfferService.java new file mode 100644 index 000000000..d09255d64 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/service/NuOfferService.java @@ -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 findAllNuOffer() { + return this.nuOfferRepository.findAllNuOffer(); + } + + @Transactional + public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException { + this.nuOfferRepository.save(nuOffer); + } +} diff --git a/src/main/java/org/springframework/cheapy/service/SpeedOfferService.java b/src/main/java/org/springframework/cheapy/service/SpeedOfferService.java new file mode 100644 index 000000000..121874247 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/service/SpeedOfferService.java @@ -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 findAllSpeedOffer() { // + return this.speedOfferRepository.findAllSpeedOffer(); + } + + @Transactional + public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { // + this.speedOfferRepository.save(speedOffer); + } +} diff --git a/src/main/java/org/springframework/cheapy/service/TimeOfferService.java b/src/main/java/org/springframework/cheapy/service/TimeOfferService.java new file mode 100644 index 000000000..b7d5904ef --- /dev/null +++ b/src/main/java/org/springframework/cheapy/service/TimeOfferService.java @@ -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 findAllTimeOffer() { + return this.timeOfferRepository.findAllTimeOffer(); + } + + + public void saveTimeOffer(final TimeOffer TimeOffer) throws DataAccessException { + this.timeOfferRepository.save(TimeOffer); + + + } +} diff --git a/src/main/java/org/springframework/cheapy/service/UserService.java b/src/main/java/org/springframework/cheapy/service/UserService.java deleted file mode 100644 index d719f8b47..000000000 --- a/src/main/java/org/springframework/cheapy/service/UserService.java +++ /dev/null @@ -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 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 - } - */ -} diff --git a/src/main/java/org/springframework/cheapy/system/CacheConfiguration.java b/src/main/java/org/springframework/cheapy/system/CacheConfiguration.java index d5df44632..e52087fb7 100755 --- a/src/main/java/org/springframework/cheapy/system/CacheConfiguration.java +++ b/src/main/java/org/springframework/cheapy/system/CacheConfiguration.java @@ -33,7 +33,7 @@ import org.springframework.context.annotation.Configuration; class CacheConfiguration { @Bean - public JCacheManagerCustomizer petclinicCacheConfigurationCustomizer() { + public JCacheManagerCustomizer cheapyCacheConfigurationCustomizer() { return cm -> { cm.createCache("vets", cacheConfiguration()); }; diff --git a/src/main/java/org/springframework/cheapy/system/CrashController.java b/src/main/java/org/springframework/cheapy/system/CrashController.java index 4fb7e15f5..fe9c6d322 100644 --- a/src/main/java/org/springframework/cheapy/system/CrashController.java +++ b/src/main/java/org/springframework/cheapy/system/CrashController.java @@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.GetMapping; @Controller public class CrashController { - @GetMapping("/oups") + @GetMapping(value="/oups") public String triggerException() { throw new RuntimeException( "Expected: controller used to showcase what " + "happens when an exception is thrown"); diff --git a/src/main/java/org/springframework/cheapy/system/LoginController.java b/src/main/java/org/springframework/cheapy/system/LoginController.java new file mode 100644 index 000000000..e26025570 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/system/LoginController.java @@ -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:/"; + } + + + +} diff --git a/src/main/java/org/springframework/cheapy/system/WelcomeController.java b/src/main/java/org/springframework/cheapy/system/WelcomeController.java index 85782e967..1f3b04637 100644 --- a/src/main/java/org/springframework/cheapy/system/WelcomeController.java +++ b/src/main/java/org/springframework/cheapy/system/WelcomeController.java @@ -27,4 +27,6 @@ class WelcomeController { return "welcome"; } + + } diff --git a/src/main/java/org/springframework/cheapy/web/FoodOfferController.java b/src/main/java/org/springframework/cheapy/web/FoodOfferController.java new file mode 100644 index 000000000..b2870d93b --- /dev/null +++ b/src/main/java/org/springframework/cheapy/web/FoodOfferController.java @@ -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 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 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"; + + } +} diff --git a/src/main/java/org/springframework/cheapy/web/NuOfferController.java b/src/main/java/org/springframework/cheapy/web/NuOfferController.java new file mode 100644 index 000000000..d8533842d --- /dev/null +++ b/src/main/java/org/springframework/cheapy/web/NuOfferController.java @@ -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 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 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"; + + } + +} diff --git a/src/main/java/org/springframework/cheapy/web/OfertaController.java b/src/main/java/org/springframework/cheapy/web/OfertaController.java new file mode 100644 index 000000000..c7cb3de71 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/web/OfertaController.java @@ -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 model) { + + List foodOfferLs=this.foodOfferService.findAllFoodOffer(); + List nuOfferLs=this.nuOfferService.findAllNuOffer(); + List speedOfferLs=this.speedOfferService.findAllSpeedOffer(); + List 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; +// } + + +} diff --git a/src/main/java/org/springframework/cheapy/web/OwnerController.java b/src/main/java/org/springframework/cheapy/web/OwnerController.java index d95e5d120..229693415 100644 --- a/src/main/java/org/springframework/cheapy/web/OwnerController.java +++ b/src/main/java/org/springframework/cheapy/web/OwnerController.java @@ -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; import java.util.Collection; @@ -21,7 +6,6 @@ import java.util.Map; import javax.validation.Valid; import org.springframework.cheapy.model.Owner; -import org.springframework.cheapy.repository.OwnerRepository; import org.springframework.cheapy.service.OwnerService; import org.springframework.stereotype.Controller; 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.servlet.ModelAndView; -/** - * @author Juergen Hoeller - * @author Ken Krebs - * @author Arjen Poutsma - * @author Michael Isvy - */ @Controller public class OwnerController { @@ -137,5 +115,4 @@ public class OwnerController { return mav; } - } diff --git a/src/main/java/org/springframework/cheapy/web/SpeedOfferController.java b/src/main/java/org/springframework/cheapy/web/SpeedOfferController.java new file mode 100644 index 000000000..2162e8558 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/web/SpeedOfferController.java @@ -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 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 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"; + + } +} diff --git a/src/main/java/org/springframework/cheapy/web/TimeOfferController.java b/src/main/java/org/springframework/cheapy/web/TimeOfferController.java new file mode 100644 index 000000000..41fcb27ce --- /dev/null +++ b/src/main/java/org/springframework/cheapy/web/TimeOfferController.java @@ -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 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 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"; + + + } + +} diff --git a/src/main/java/org/springframework/cheapy/web/UserController.java b/src/main/java/org/springframework/cheapy/web/UserController.java deleted file mode 100644 index 97e921a75..000000000 --- a/src/main/java/org/springframework/cheapy/web/UserController.java +++ /dev/null @@ -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"; -// } -// } -// } -} diff --git a/src/main/less/petclinic.less b/src/main/less/cheapy.less similarity index 71% rename from src/main/less/petclinic.less rename to src/main/less/cheapy.less index 0f326f7ed..2ad446686 100644 --- a/src/main/less/petclinic.less +++ b/src/main/less/cheapy.less @@ -47,10 +47,10 @@ @pagination-active-bg: @spring-brown; @pagination-active-border: @spring-blue; -@table-border-color: @spring-brown; +@table-border-color: rgb(0, 64, 128); -.table > thead > tr > th { - background-color: lighten(@spring-brown, 3%); + .table > thead > tr > th { + background-color: rgb(40, 140, 215); color: @spring-light-grey; } @@ -237,7 +237,131 @@ img.img-responsive{ .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 { diff --git a/src/main/resources/db/mysql/cheapy_db_setup_mysql.txt b/src/main/resources/db/mysql/cheapy_db_setup_mysql.txt index 29bb601fe..d1ec8149b 100644 --- a/src/main/resources/db/mysql/cheapy_db_setup_mysql.txt +++ b/src/main/resources/db/mysql/cheapy_db_setup_mysql.txt @@ -1,5 +1,5 @@ ================================================================================ -=== Spring PetClinic sample application - MySQL Configuration === +=== Spring Cheapy sample application - MySQL Configuration === ================================================================================ @author Sam Brannen @@ -18,15 +18,15 @@ 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 `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 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 docker-compose configuration provided, or by the `user.sql` script if you run that as root. diff --git a/src/main/resources/db/mysql/data.sql b/src/main/resources/db/mysql/data.sql index 3dd3b74c7..baa9d8384 100644 --- a/src/main/resources/db/mysql/data.sql +++ b/src/main/resources/db/mysql/data.sql @@ -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 (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 authorities(id ,usuario, authority) values (42,'admin3', 'admin'); +INSERT INTO usuarios VALUES (1, 'admin', 'admin', 'admin', 'C/admin', '000000000', 'admin@gmail.com','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 authorities(id,username,authority) VALUES (1,'admin1','admin'); +INSERT INTO clients (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (1,'bar manoli','manoli@gmail.com','C/Betis','10:00','22:00','608726190', 'description 1', 'code1', 'ESPAÑOLA','manoli'); +INSERT INTO clients (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (2,'bar david','david@gmail.com','C/Sevilla','09:30','22:00','608726190', 'description 2', 'code2', 'americana','david'); + +INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'FO-1', '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); diff --git a/src/main/resources/messages/messages.properties b/src/main/resources/messages/messages.properties index 173417a10..1947d786c 100644 --- a/src/main/resources/messages/messages.properties +++ b/src/main/resources/messages/messages.properties @@ -1,4 +1,6 @@ -welcome=Welcome +welcome=Welcome to +listOffers=List Offers + required=is required notFound=has not been found duplicate=is already in use diff --git a/src/main/resources/messages/messages_es.properties b/src/main/resources/messages/messages_es.properties index bdf81dae7..81b71314d 100644 --- a/src/main/resources/messages/messages_es.properties +++ b/src/main/resources/messages/messages_es.properties @@ -1,8 +1,34 @@ 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 duplicate=Ya se encuentra en uso nonNumeric=Sólo debe contener numeros duplicateFormSubmission=No se permite el envío de formularios duplicados typeMismatch.date=Fecha invalida -typeMismatch.birthDate=Fecha invalida +typeMismatch.birthDate=Fecha invalida \ No newline at end of file diff --git a/src/main/resources/static/resources/images/bar3.jpg b/src/main/resources/static/resources/images/bar3.jpg new file mode 100644 index 000000000..d1b62b01e Binary files /dev/null and b/src/main/resources/static/resources/images/bar3.jpg differ diff --git a/src/main/webapp/WEB-INF/jsp/error.jsp b/src/main/webapp/WEB-INF/jsp/error.jsp new file mode 100644 index 000000000..a1fcc6296 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/error.jsp @@ -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" %> + + + + +

Algo malo ha pasado...

+ + + + +

${exception.message}

+ +
diff --git a/src/main/webapp/WEB-INF/jsp/exception.jsp b/src/main/webapp/WEB-INF/jsp/exception.jsp deleted file mode 100644 index d030d595d..000000000 --- a/src/main/webapp/WEB-INF/jsp/exception.jsp +++ /dev/null @@ -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" %> - - - - - - -

Something happened...

- -

${exception.message}

- -
diff --git a/src/main/webapp/WEB-INF/jsp/login.jsp b/src/main/webapp/WEB-INF/jsp/login.jsp new file mode 100644 index 000000000..796cdceeb --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/login.jsp @@ -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" %> + + + + + + + + + + +
+
+ + + +
+ +
+
+

Invalid username or password

+
+ +
+
+ +
diff --git a/src/main/webapp/WEB-INF/jsp/offers/food/createOrUpdateFoodOfferForm.jsp b/src/main/webapp/WEB-INF/jsp/offers/food/createOrUpdateFoodOfferForm.jsp new file mode 100644 index 000000000..daeeec363 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/food/createOrUpdateFoodOfferForm.jsp @@ -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" %> + + +

+ New FoodOffer +

+ +
+ + + + + + + +
+
+
+ + + + + + + + +
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/offers/food/foodOffersDisable.jsp b/src/main/webapp/WEB-INF/jsp/offers/food/foodOffersDisable.jsp new file mode 100644 index 000000000..14a7519e0 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/food/foodOffersDisable.jsp @@ -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"%> + + + + +

¿Esta seguro de que quiere eliminar su oferta?

+ + + + + + + + + Volver + +
+
diff --git a/src/main/webapp/WEB-INF/jsp/offers/food/foodOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/offers/food/foodOffersShow.jsp new file mode 100644 index 000000000..44b10a7f0 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/food/foodOffersShow.jsp @@ -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" %> + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + Editar oferta + + + + + Desactivar oferta + +
diff --git a/src/main/webapp/WEB-INF/jsp/offers/nu/createOrUpdateNuOfferForm.jsp b/src/main/webapp/WEB-INF/jsp/offers/nu/createOrUpdateNuOfferForm.jsp new file mode 100644 index 000000000..904bbfffb --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/nu/createOrUpdateNuOfferForm.jsp @@ -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" %> + + +

+ New NuOffer +

+ +
+ + + + + + + + + + + + + +
+
+
+ + + + + + + + +
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersDisable.jsp b/src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersDisable.jsp new file mode 100644 index 000000000..83fa94c10 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersDisable.jsp @@ -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"%> + + + + +

¿Esta seguro de que quiere dar de baja su offer?

+ + + + + + + + + + + + + Volver + +
+
diff --git a/src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersShow.jsp new file mode 100644 index 000000000..f5a351168 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersShow.jsp @@ -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" %> + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Meta bronce
+ +
+ +
+ + + + + Editar oferta + + + + + Desactivar oferta + +
diff --git a/src/main/webapp/WEB-INF/jsp/offers/offersList.jsp b/src/main/webapp/WEB-INF/jsp/offers/offersList.jsp new file mode 100644 index 000000000..30ee72a07 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/offersList.jsp @@ -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" %> + + + +

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ +
+
+ +

+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ +
+
+

+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ +
+
+

+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ +
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/offers/speed/createOrUpdateSpeedOfferForm.jsp b/src/main/webapp/WEB-INF/jsp/offers/speed/createOrUpdateSpeedOfferForm.jsp new file mode 100644 index 000000000..3327373db --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/speed/createOrUpdateSpeedOfferForm.jsp @@ -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" %> + + +

+ New SpeedOffer +

+ +
+ + + + + + + + + + + +
+
+
+ + + + + + + + +
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/offers/speed/speedOffersDisable.jsp b/src/main/webapp/WEB-INF/jsp/offers/speed/speedOffersDisable.jsp new file mode 100644 index 000000000..0e2febbf0 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/speed/speedOffersDisable.jsp @@ -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"%> + + + + +

¿Esta seguro de que quiere dar de baja su offer?

+ + + + + + + + + + + + + Volver + +
+
diff --git a/src/main/webapp/WEB-INF/jsp/offers/speed/speedOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/offers/speed/speedOffersShow.jsp new file mode 100644 index 000000000..de2a32a80 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/speed/speedOffersShow.jsp @@ -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" %> + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + Editar oferta + + + + + Desactivar oferta + +
diff --git a/src/main/webapp/WEB-INF/jsp/offers/time/createOrUpdateTimeOfferForm.jsp b/src/main/webapp/WEB-INF/jsp/offers/time/createOrUpdateTimeOfferForm.jsp new file mode 100644 index 000000000..cd12ad6fc --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/time/createOrUpdateTimeOfferForm.jsp @@ -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" %> + + +

+ New TimeOffer +

+ +
+ + + + + + + + + + + +
+
+
+ + + + + + + + +
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/offers/time/timeOffersDisable.jsp b/src/main/webapp/WEB-INF/jsp/offers/time/timeOffersDisable.jsp new file mode 100644 index 000000000..0baaaabcc --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/time/timeOffersDisable.jsp @@ -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"%> + + + + +

¿Esta seguro de que quiere eliminar su oferta?

+ + + + + + + + + + Volver + +
+
diff --git a/src/main/webapp/WEB-INF/jsp/offers/time/timeOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/offers/time/timeOffersShow.jsp new file mode 100644 index 000000000..3db0c885a --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/time/timeOffersShow.jsp @@ -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" %> + + + + +

+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + Editar oferta + + + + + Desactivar oferta + +
+ +
+ +
diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp index d7e9e1ab9..970f56781 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp @@ -2,21 +2,20 @@ <%@ 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" %> - - +<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +

New Owner

- - - - - + + + + +
@@ -31,4 +30,4 @@
-
+ diff --git a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp index 4c93fb198..c68c500ab 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp @@ -2,13 +2,12 @@ <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> -<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> -<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> +<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> - - +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +

Find Owners

@@ -37,4 +36,4 @@ Add Owner -
+ diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp index 375906c45..26c556611 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp @@ -1,10 +1,9 @@ <%@ 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="petclinic" tagdir="/WEB-INF/tags" %> - - +<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +

Owner Information

@@ -33,4 +32,4 @@ Edit Owner -
+ diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index a4b161b9d..78817241e 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp @@ -2,10 +2,9 @@ <%@ 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="cheapy" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> -<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - - +

Owners

@@ -41,4 +40,4 @@
-
+ diff --git a/src/main/webapp/WEB-INF/jsp/users/createOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/users/createOwnerForm.jsp index 941156611..e01e1c527 100644 --- a/src/main/webapp/WEB-INF/jsp/users/createOwnerForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/users/createOwnerForm.jsp @@ -2,23 +2,22 @@ <%@ 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" %> - - +<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +

New Owner

- - - - - - - + + + + + + +
@@ -33,4 +32,4 @@
-
+ diff --git a/src/main/webapp/WEB-INF/jsp/welcome.jsp b/src/main/webapp/WEB-INF/jsp/welcome.jsp index 0cae0d52e..95c506f42 100644 --- a/src/main/webapp/WEB-INF/jsp/welcome.jsp +++ b/src/main/webapp/WEB-INF/jsp/welcome.jsp @@ -1,12 +1,12 @@ <%@ 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="petclinic" tagdir="/WEB-INF/tags" %> +<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> - -

+ +

@@ -14,9 +14,10 @@
- - +
-
+ diff --git a/src/main/webapp/WEB-INF/tags/bodyHeader.tag b/src/main/webapp/WEB-INF/tags/bodyHeader.tag index cd14d874c..db45d11d0 100644 --- a/src/main/webapp/WEB-INF/tags/bodyHeader.tag +++ b/src/main/webapp/WEB-INF/tags/bodyHeader.tag @@ -1,7 +1,7 @@ <%@ 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" - description="Name of the active menu: home, owners, vets or error" %> + description="Name of the active menu: home, ofertas, contactanos, login" %> - + diff --git a/src/main/webapp/WEB-INF/tags/htmlHeader.tag b/src/main/webapp/WEB-INF/tags/htmlHeader.tag index 2417673ea..a259211ab 100644 --- a/src/main/webapp/WEB-INF/tags/htmlHeader.tag +++ b/src/main/webapp/WEB-INF/tags/htmlHeader.tag @@ -1,7 +1,7 @@ <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%-- -PetClinic :: a Spring Framework demonstration +Cheapy :: a Spring Framework demonstration --%> @@ -17,8 +17,8 @@ PetClinic :: a Spring Framework demonstration Cheapy : eat fast, eat cheapy <%-- CSS generated from LESS --%> - - + + <%-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --%> diff --git a/src/main/webapp/WEB-INF/tags/layout.tag b/src/main/webapp/WEB-INF/tags/layout.tag index 870c735b2..b5b93d21e 100644 --- a/src/main/webapp/WEB-INF/tags/layout.tag +++ b/src/main/webapp/WEB-INF/tags/layout.tag @@ -1,25 +1,25 @@ <%@ tag trimDirectiveWhitespaces="true" %> -<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> +<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> <%@ attribute name="pageName" required="true" %> <%@ attribute name="customScript" required="false" fragment="true"%> - + - +
- +
- + diff --git a/src/main/webapp/WEB-INF/tags/menu.tag b/src/main/webapp/WEB-INF/tags/menu.tag index 2d0eeff56..daa63faa2 100644 --- a/src/main/webapp/WEB-INF/tags/menu.tag +++ b/src/main/webapp/WEB-INF/tags/menu.tag @@ -1,11 +1,11 @@ <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ 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" uri="http://www.springframework.org/security/tags"%> <%@ 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"%>