diff --git a/pom.xml b/pom.xml index 38e0cd40b..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 diff --git a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java index 4c119fe2c..7189740f2 100644 --- a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java +++ b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java @@ -36,20 +36,20 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET, "/", "/oups").permitAll() .antMatchers("/users/new").permitAll() - .antMatchers("/nuOffers/**").hasAnyAuthority("admin","client") - .antMatchers("/timeOffers/**").hasAnyAuthority("admin","client") - .antMatchers("/login/**").anonymous() .antMatchers("/logout").permitAll() .antMatchers("/usuarios/new").permitAll() .antMatchers("/admin/**").hasAnyAuthority("admin") - .antMatchers("/speedOffers/**").hasAnyAuthority("admin", "client") - .antMatchers("/foodOffers/**").hasAnyAuthority("admin", "client") + .antMatchers("/owners/**").hasAnyAuthority("owner", "admin") + .antMatchers("/offers/**/new").hasAnyAuthority("admin", "client") + .antMatchers("/offers/**/activate").hasAnyAuthority("admin","client") + .antMatchers("/clients/new").permitAll() - .antMatchers("/offers/**").hasAnyAuthority("admin") + .antMatchers("/offers/**").permitAll() + .and().formLogin() .loginPage("/login").permitAll() 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 39a398df5..e3f939728 100644 --- a/src/main/java/org/springframework/cheapy/model/Client.java +++ b/src/main/java/org/springframework/cheapy/model/Client.java @@ -1,6 +1,6 @@ package org.springframework.cheapy.model; -import java.time.LocalTime; +import java.util.List; import java.util.Set; import javax.persistence.CascadeType; @@ -13,31 +13,31 @@ import javax.validation.constraints.Digits; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; -import org.springframework.format.annotation.DateTimeFormat; - @Entity @Table(name = "clients") -public class Client extends BaseEntity{ - /** - * - */ +public class Client extends BaseEntity { + private static final long serialVersionUID = 1L; - // (id, email, address, init, finish, telephone, description, code, food, usuar) + // (id, name, email, address, init, finish, telephone, description, code, food, + // usuar) + + @NotEmpty + private String name; @NotEmpty private String email; - + @NotEmpty private String address; - //@DateTimeFormat(pattern = "HH:mm") - @NotBlank - private String init; + // Hora de apertura del local + @NotBlank + private String init; - //@DateTimeFormat(pattern = "HH:mm") - @NotBlank - private String finish; + // Hora de cierre del local + @NotBlank + private String finish; @NotEmpty @Digits(fraction = 0, integer = 10) @@ -46,38 +46,45 @@ public class Client extends BaseEntity{ @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; - + private List foodOffers; + @OneToMany - private Set nuOffers; - + private List nuOffers; + @OneToMany - private Set speedOffers; - + private List speedOffers; + @OneToMany - private Set timeOffers; - - - + private List 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; } @@ -86,7 +93,6 @@ public class Client extends BaseEntity{ this.address = address; } - public String getInit() { return init; } @@ -103,14 +109,6 @@ public class Client extends BaseEntity{ this.finish = finish; } - public User getUsername() { - return usuar; - } - - public void setUsername(User username) { - this.usuar = username; - } - public String getTelephone() { return telephone; } @@ -143,35 +141,43 @@ public class Client extends BaseEntity{ this.food = food; } - public Set getFoodOffers() { + public User getUsuar() { + return usuar; + } + + public void setUsuar(User usuar) { + this.usuar = usuar; + } + + public List getFoodOffers() { return foodOffers; } - public void setFoodOffers(Set foodOffers) { + public void setFoodOffers(List foodOffers) { this.foodOffers = foodOffers; } - public Set getNuOffers() { + public List getNuOffers() { return nuOffers; } - public void setNuOffers(Set nuOffers) { + public void setNuOffers(List nuOffers) { this.nuOffers = nuOffers; } - public Set getSpeedOffers() { + public List getSpeedOffers() { return speedOffers; } - public void setSpeedOffers(Set speedOffers) { + public void setSpeedOffers(List speedOffers) { this.speedOffers = speedOffers; } - public Set getTimeOffers() { + public List getTimeOffers() { return timeOffers; } - public void setTimeOffers(Set timeOffers) { + public void setTimeOffers(List timeOffers) { this.timeOffers = timeOffers; } diff --git a/src/main/java/org/springframework/cheapy/model/FoodOffer.java b/src/main/java/org/springframework/cheapy/model/FoodOffer.java index d6a7d8e3d..3cb6a1e56 100644 --- a/src/main/java/org/springframework/cheapy/model/FoodOffer.java +++ b/src/main/java/org/springframework/cheapy/model/FoodOffer.java @@ -17,21 +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 { -//Plato específico + + private static final long serialVersionUID = 1L; + + //Plato específico @NotBlank private String food; - @NotBlank - private String discount; - @NotNull - private Integer units; // revisar + @Min(0) + private Integer discount; public String getFood() { return food; @@ -41,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 fbb884f5d..6f250737d 100644 --- a/src/main/java/org/springframework/cheapy/model/NuOffer.java +++ b/src/main/java/org/springframework/cheapy/model/NuOffer.java @@ -3,33 +3,42 @@ 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 { + //Oferta por numero de comensales + private static final long serialVersionUID = 1L; + @NotNull - private Integer gold; + @Min(1) + private Integer gold; @Column(name = "discount_gold") - @NotBlank - private String discountGold; + @NotNull + @Min(0) + private Integer discountGold; @NotNull - private Integer silver; + @Min(1) + private Integer silver; @Column(name = "discount_silver") - @NotBlank - private String discountSilver; + @NotNull + @Min(0) + private Integer discountSilver; @NotNull - private Integer bronze; + @Min(1) + private Integer bronze; @Column(name = "discount_bronze") - @NotBlank - private String discountBronze; + @NotNull + @Min(0) + private Integer discountBronze; public Integer getGold() { return gold; @@ -39,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; } @@ -55,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; } @@ -71,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 b26ea57bf..5ae64feba 100644 --- a/src/main/java/org/springframework/cheapy/model/Offer.java +++ b/src/main/java/org/springframework/cheapy/model/Offer.java @@ -29,7 +29,11 @@ import org.springframework.format.annotation.DateTimeFormat; @MappedSuperclass public class Offer extends BaseEntity { -//Clase padre + + private static final long serialVersionUID = 1L; + + // Clase padre + @DateTimeFormat(pattern = "dd/MM/yyyy HH:mm") @NotNull @Future @@ -40,15 +44,13 @@ public class Offer extends BaseEntity { @Future private LocalDateTime end; - 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() { @@ -75,14 +77,14 @@ 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; } 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 1ef45f6e1..84b551829 100644 --- a/src/main/java/org/springframework/cheapy/model/SpeedOffer.java +++ b/src/main/java/org/springframework/cheapy/model/SpeedOffer.java @@ -3,34 +3,42 @@ 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 { + // Ofertar por rapidez comiendo + private static final long serialVersionUID = 1L; @NotNull - private Integer gold; // x minutos + @Min(0) + private Integer gold; @Column(name = "discount_gold") - @NotBlank - private String discountGold; + @NotNull + @Min(0) + private Integer discountGold; @NotNull + @Min(0) private Integer silver; @Column(name = "discount_silver") - @NotBlank - private String discountSilver; + @NotNull + @Min(0) + private Integer discountSilver; @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; @@ -40,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; } @@ -56,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; } @@ -72,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 33da076ab..44ae5e3d6 100644 --- a/src/main/java/org/springframework/cheapy/model/TimeOffer.java +++ b/src/main/java/org/springframework/cheapy/model/TimeOffer.java @@ -1,25 +1,9 @@ -/* - * 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.LocalTime; import javax.persistence.Entity; import javax.persistence.Table; -import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import org.springframework.format.annotation.DateTimeFormat; @@ -27,7 +11,11 @@ import org.springframework.format.annotation.DateTimeFormat; @Entity @Table(name = "time_offers") public class TimeOffer extends Offer { -//Oferta por franja horaria + + private static final long serialVersionUID = 1L; + + // Oferta por franja horaria + @DateTimeFormat(pattern = "HH:mm") @NotNull private LocalTime init; @@ -36,10 +24,8 @@ public class TimeOffer extends Offer { @NotNull private LocalTime finish; - @NotBlank - private String discount; - - + @NotNull + private Integer discount; public LocalTime getInit() { return init; @@ -57,11 +43,11 @@ public class TimeOffer extends Offer { this.finish = finish; } - public String getDiscount() { + 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 7cfc346d1..e9c232562 100644 --- a/src/main/java/org/springframework/cheapy/model/User.java +++ b/src/main/java/org/springframework/cheapy/model/User.java @@ -1,12 +1,12 @@ package org.springframework.cheapy.model; -import javax.persistence.JoinColumn; -import javax.persistence.MappedSuperclass; -import javax.persistence.OneToOne; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.validation.constraints.NotBlank; @Entity @Table(name = "users") -//@MappedSuperclass public class User{ @Id @@ -17,10 +17,6 @@ public class User{ boolean enabled; - - /** - * - */ private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/springframework/cheapy/model/Usuario.java b/src/main/java/org/springframework/cheapy/model/Usuario.java index f6204abeb..9079bc72e 100644 --- a/src/main/java/org/springframework/cheapy/model/Usuario.java +++ b/src/main/java/org/springframework/cheapy/model/Usuario.java @@ -1,12 +1,8 @@ package org.springframework.cheapy.model; -import java.util.Set; - import javax.persistence.CascadeType; import javax.persistence.Entity; -import javax.persistence.Id; import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.validation.constraints.Email; 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 index 4c12840c2..1e04f6f3a 100644 --- a/src/main/java/org/springframework/cheapy/repository/ClientRepository.java +++ b/src/main/java/org/springframework/cheapy/repository/ClientRepository.java @@ -1,13 +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 index 752bb718d..2e9ca093b 100644 --- a/src/main/java/org/springframework/cheapy/repository/FoodOfferRepository.java +++ b/src/main/java/org/springframework/cheapy/repository/FoodOfferRepository.java @@ -1,18 +1,17 @@ package org.springframework.cheapy.repository; - import org.springframework.cheapy.model.FoodOffer; -import java.util.Collection; +import org.springframework.cheapy.model.StatusOffer; + 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") + @Query("SELECT foodOffer FROM FoodOffer foodOffer") @Transactional(readOnly = true) List findAllFoodOffer(); @@ -21,5 +20,12 @@ public interface FoodOfferRepository extends Repository { FoodOffer findById(@Param("id") Integer id); void save(FoodOffer foodOffer); - + + @Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE foodOffer.status =:status") + @Transactional(readOnly = true) + List findActiveFoodOffer(StatusOffer status); + + @Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE foodOffer.client.id =:id") + @Transactional(readOnly = true) + List findByUserId(@Param("id") Integer id); } diff --git a/src/main/java/org/springframework/cheapy/repository/NuOfferRepository.java b/src/main/java/org/springframework/cheapy/repository/NuOfferRepository.java index 39fff01bb..8e59df4dc 100644 --- a/src/main/java/org/springframework/cheapy/repository/NuOfferRepository.java +++ b/src/main/java/org/springframework/cheapy/repository/NuOfferRepository.java @@ -1,28 +1,30 @@ - package org.springframework.cheapy.repository; -import java.util.Collection; import java.util.List; + +import org.springframework.cheapy.model.FoodOffer; import org.springframework.cheapy.model.NuOffer; +import org.springframework.cheapy.model.StatusOffer; import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; import org.springframework.data.jpa.repository.Query; import org.springframework.transaction.annotation.Transactional; - public interface NuOfferRepository extends Repository { - - - - NuOffer findNuOfferById(int nuOfferId); - @Query("SELECT nuOffer FROM NuOffer nuOffer") + @Query("SELECT nuOffer FROM NuOffer nuOffer") @Transactional(readOnly = true) List findAllNuOffer(); - - void save(NuOffer nuOffer); - + + @Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.status =:status") + @Transactional(readOnly = true) + List findActiveNuOffer(StatusOffer status); + + @Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.id =:id") + @Transactional(readOnly = true) + List findByUserId(@Param("id") Integer id); } diff --git a/src/main/java/org/springframework/cheapy/repository/SpeedOfferRepository.java b/src/main/java/org/springframework/cheapy/repository/SpeedOfferRepository.java index c3840912b..e4df0426c 100644 --- a/src/main/java/org/springframework/cheapy/repository/SpeedOfferRepository.java +++ b/src/main/java/org/springframework/cheapy/repository/SpeedOfferRepository.java @@ -1,28 +1,32 @@ - package org.springframework.cheapy.repository; - -import java.util.Collection; import java.util.List; + +import org.springframework.cheapy.model.FoodOffer; import org.springframework.cheapy.model.SpeedOffer; +import org.springframework.cheapy.model.StatusOffer; 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") + @Query("SELECT speedOffer FROM SpeedOffer speedOffer") @Transactional(readOnly = true) List findAllSpeedOffer(); - void save(SpeedOffer speedOffer); - + + @Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.status =:status") + @Transactional(readOnly = true) + List findActiveSpeedOffer(StatusOffer status); + + @Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.id =:id") + @Transactional(readOnly = true) + List findByUserId(@Param("id") Integer id); } diff --git a/src/main/java/org/springframework/cheapy/repository/TimeOfferRepository.java b/src/main/java/org/springframework/cheapy/repository/TimeOfferRepository.java index 71717624d..1cd4c5e34 100644 --- a/src/main/java/org/springframework/cheapy/repository/TimeOfferRepository.java +++ b/src/main/java/org/springframework/cheapy/repository/TimeOfferRepository.java @@ -1,28 +1,29 @@ - package org.springframework.cheapy.repository; -import java.util.Collection; import java.util.List; + +import org.springframework.cheapy.model.StatusOffer; import org.springframework.cheapy.model.TimeOffer; import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; import org.springframework.data.jpa.repository.Query; import org.springframework.transaction.annotation.Transactional; - public interface TimeOfferRepository extends Repository { - - - - TimeOffer findTimeOfferById(int timeOfferId); - @Query("SELECT timeOffer FROM TimeOffer timeOffer") + @Query("SELECT timeOffer FROM TimeOffer timeOffer") @Transactional(readOnly = true) List findAllTimeOffer(); - - void save(TimeOffer timeOffer); - + + @Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.status =:status") + @Transactional(readOnly = true) + List findActiveTimeOffer(StatusOffer status); + + @Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.id =:id") + @Transactional(readOnly = true) + List findByUserId(@Param("id") Integer id); } diff --git a/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java b/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java index d16d99bf6..1bd7c8ee2 100644 --- a/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java +++ b/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java @@ -2,7 +2,6 @@ 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 { diff --git a/src/main/java/org/springframework/cheapy/service/ClientService.java b/src/main/java/org/springframework/cheapy/service/ClientService.java index 9b197c438..d65649680 100644 --- a/src/main/java/org/springframework/cheapy/service/ClientService.java +++ b/src/main/java/org/springframework/cheapy/service/ClientService.java @@ -1,21 +1,5 @@ -/* - * 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.cheapy.model.Client; import org.springframework.cheapy.repository.ClientRepository; @@ -25,8 +9,6 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - - @Service public class ClientService { @@ -37,13 +19,11 @@ public class ClientService { this.clientRepository = clientRepository; } - @Transactional public Client getCurrentClient() throws DataAccessException { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - String username = authentication.getName(); + 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 index edd61b7f5..c11c9e8a6 100644 --- a/src/main/java/org/springframework/cheapy/service/FoodOfferService.java +++ b/src/main/java/org/springframework/cheapy/service/FoodOfferService.java @@ -2,17 +2,17 @@ package org.springframework.cheapy.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cheapy.model.FoodOffer; +import org.springframework.cheapy.model.StatusOffer; import org.springframework.cheapy.repository.FoodOfferRepository; -import java.util.Collection; 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; @@ -21,15 +21,20 @@ public class FoodOfferService { 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); - + } + + public List findActiveFoodOffer() { + return this.foodOfferRepository.findActiveFoodOffer(StatusOffer.active); + } + + public List findFoodOfferByUserId(final int id) { + return this.foodOfferRepository.findByUserId(id); } } diff --git a/src/main/java/org/springframework/cheapy/service/NuOfferService.java b/src/main/java/org/springframework/cheapy/service/NuOfferService.java index 475a2e7ab..b87093c3d 100644 --- a/src/main/java/org/springframework/cheapy/service/NuOfferService.java +++ b/src/main/java/org/springframework/cheapy/service/NuOfferService.java @@ -1,37 +1,45 @@ -package org.springframework.cheapy.service; +package org.springframework.cheapy.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cheapy.model.NuOffer; +import org.springframework.cheapy.model.StatusOffer; import org.springframework.cheapy.repository.NuOfferRepository; -import java.util.Collection; 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; + private NuOfferRepository nuOfferRepository; @Autowired public NuOfferService(final NuOfferRepository nuOfferRepository) { this.nuOfferRepository = nuOfferRepository; } + @Transactional public NuOffer findNuOfferById(final int id) { - return this.nuOfferRepository.findNuOfferById(id); } - public List findAllNuOffer() { // - return this.nuOfferRepository.findAllNuOffer(); + @Transactional + public List findAllNuOffer() { + return this.nuOfferRepository.findAllNuOffer(); } - - public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException { // - + @Transactional + public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException { this.nuOfferRepository.save(nuOffer); - + } + + public List findActiveNuOffer() { + return this.nuOfferRepository.findActiveNuOffer(StatusOffer.active); + } + + public List findNuOfferByUserId(final int id) { + return this.nuOfferRepository.findByUserId(id); } } diff --git a/src/main/java/org/springframework/cheapy/service/SpeedOfferService.java b/src/main/java/org/springframework/cheapy/service/SpeedOfferService.java index ca2b08036..6063b7426 100644 --- a/src/main/java/org/springframework/cheapy/service/SpeedOfferService.java +++ b/src/main/java/org/springframework/cheapy/service/SpeedOfferService.java @@ -1,13 +1,15 @@ + package org.springframework.cheapy.service; - -import java.util.Collection; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cheapy.model.NuOffer; import org.springframework.cheapy.model.SpeedOffer; +import org.springframework.cheapy.model.StatusOffer; 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 { @@ -20,19 +22,26 @@ public class SpeedOfferService { this.speedOfferRepository = speedOfferRepository; } + @Transactional public SpeedOffer findSpeedOfferById(final int id) { return this.speedOfferRepository.findById(id); } + @Transactional public List findAllSpeedOffer() { // return this.speedOfferRepository.findAllSpeedOffer(); - } - - public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { - + @Transactional + public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { // this.speedOfferRepository.save(speedOffer); - + } + + public List findActiveSpeedOffer() { + return this.speedOfferRepository.findActiveSpeedOffer(StatusOffer.active); + } + + public List findSpeedOfferByUserId(final int id) { + return this.speedOfferRepository.findByUserId(id); } } diff --git a/src/main/java/org/springframework/cheapy/service/TimeOfferService.java b/src/main/java/org/springframework/cheapy/service/TimeOfferService.java index f544b0515..e23fa5151 100644 --- a/src/main/java/org/springframework/cheapy/service/TimeOfferService.java +++ b/src/main/java/org/springframework/cheapy/service/TimeOfferService.java @@ -1,6 +1,9 @@ package org.springframework.cheapy.service; +import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cheapy.model.StatusOffer; import org.springframework.cheapy.model.TimeOffer; import org.springframework.cheapy.repository.TimeOfferRepository; @@ -21,14 +24,20 @@ public class TimeOfferService { return this.timeOfferRepository.findTimeOfferById(id); } - public List findAllTimeOffer() { // + public List findAllTimeOffer() { return this.timeOfferRepository.findAllTimeOffer(); } - public void saveTimeOffer(final TimeOffer TimeOffer) throws DataAccessException { // + public void saveTimeOffer(final TimeOffer TimeOffer) throws DataAccessException { this.timeOfferRepository.save(TimeOffer); - - + } + + public List findActiveTimeOffer() { + return this.timeOfferRepository.findActiveTimeOffer(StatusOffer.active); + } + + public List findTimeOfferByUserId(final int id) { + return this.timeOfferRepository.findByUserId(id); } } diff --git a/src/main/java/org/springframework/cheapy/web/FoodOfferController.java b/src/main/java/org/springframework/cheapy/web/FoodOfferController.java index d9f53a5e6..b2870d93b 100644 --- a/src/main/java/org/springframework/cheapy/web/FoodOfferController.java +++ b/src/main/java/org/springframework/cheapy/web/FoodOfferController.java @@ -1,8 +1,11 @@ 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; @@ -11,73 +14,115 @@ import org.springframework.cheapy.service.FoodOfferService; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @Controller public class FoodOfferController { - private static final String VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM = "foodOffers/createOrUpdateFoodOfferForm"; + private 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; } - @InitBinder - public void setAllowedFields(WebDataBinder dataBinder) { - dataBinder.setDisallowedFields("id"); - } - @GetMapping("/foodOffers/new") + @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("/foodOffers/new") + @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(); + } else { + Client client = this.clientService.getCurrentClient(); foodOffer.setClient(client); - foodOffer.setType(StatusOffer.hidden); + foodOffer.setStatus(StatusOffer.hidden); this.foodOfferService.saveFoodOffer(foodOffer); - return "redirect:/foodOffers/" + foodOffer.getId(); + return "redirect:/offers/food/" + foodOffer.getId(); } } - @GetMapping(value = "/foodOffers/{foodOfferId}/activate") + @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.setType(StatusOffer.active); - foodOffer.setCode("FO-"+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:/foodOffers/"; + return "redirect:/offers/food/"+foodOfferId; + } + @GetMapping("/offers/food/{foodOfferId}") public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map model) { - FoodOffer foodOffer=this.foodOfferService.findFoodOfferById(foodOfferId); - + FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId); + model.put("foodOffer", foodOffer); - return "foodOffers/foodOffersShow"; + 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 index c6ad3c47f..d8533842d 100644 --- a/src/main/java/org/springframework/cheapy/web/NuOfferController.java +++ b/src/main/java/org/springframework/cheapy/web/NuOfferController.java @@ -1,98 +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.Client; 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.WebDataBinder; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; - @Controller public class NuOfferController { - private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "nuOffers/createOrUpdateNuOfferForm"; + 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,ClientService clientService) { + public NuOfferController(final NuOfferService nuOfferService, final ClientService clientService) { this.nuOfferService = nuOfferService; this.clientService = clientService; - } - @InitBinder - public void setAllowedFields(WebDataBinder dataBinder) { - dataBinder.setDisallowedFields("id"); - } - - @GetMapping("/nuOffers/new") + @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("/nuOffers/new") + @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.setType(StatusOffer.hidden); - + } else { + nuOffer.setStatus(StatusOffer.hidden); + Client client = this.clientService.getCurrentClient(); - + nuOffer.setClient(client); - - + this.nuOfferService.saveNuOffer(nuOffer); - return "redirect:/nuOffers/" + nuOffer.getId(); + return "redirect:/offers/nu/"+nuOffer.getId(); } } - @GetMapping(value ="/nuOffers/{nuOfferId}/activate") + + @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.setType(StatusOffer.active); - nuOffer.setCode("NU-"+nuOfferId); + NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId); + if (nuOffer.getClient().equals(client)) { + nuOffer.setStatus(StatusOffer.active); + nuOffer.setCode("NU-" + nuOfferId); this.nuOfferService.saveNuOffer(nuOffer); - return "redirect:/nuOffers/" + nuOffer.getId(); } else { - modelMap.addAttribute("message", "You don't have access to this number offer"); - } - return "redirect:/nuOffers/"; - + modelMap.addAttribute("message", "You don't have access to this number offer"); + } + return "redirect:/offers/nu/"+ nuOffer.getId(); } - - @GetMapping("/offers/nu/{nuOfferId}") + + @GetMapping("/offers/nu/{nuOfferId}") public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map model) { - - NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId); - + NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId); model.put("nuOffer", nuOffer); - - return "nuOffers/nuOffersShow"; + + 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 index dcd92f583..73b3553cd 100644 --- a/src/main/java/org/springframework/cheapy/web/OfertaController.java +++ b/src/main/java/org/springframework/cheapy/web/OfertaController.java @@ -1,21 +1,6 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.springframework.cheapy.web; -import java.util.ArrayList; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Map; @@ -23,60 +8,74 @@ 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.ClientService; import org.springframework.cheapy.service.FoodOfferService; import org.springframework.cheapy.service.NuOfferService; import org.springframework.cheapy.service.SpeedOfferService; import org.springframework.cheapy.service.TimeOfferService; import org.springframework.stereotype.Controller; -import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; - -/** - * @author Juergen Hoeller - * @author Ken Krebs - * @author Arjen Poutsma - * @author Michael Isvy - */ @Controller public class OfertaController { - - //private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm"; - + + private final ClientService clientService; + 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) { + final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService, ClientService clientService) { + this.clientService = clientService; 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(); + List foodOfferLs=this.foodOfferService.findActiveFoodOffer(); + List nuOfferLs=this.nuOfferService.findActiveNuOffer(); + List speedOfferLs=this.speedOfferService.findActiveSpeedOffer(); + List timeOfferLs=this.timeOfferService.findActiveTimeOffer(); 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("/myOffers") + public String processMyOffersForm( Map model) { + + int actual = this.clientService.getCurrentClient().getId(); + + List foodOfferLs = this.foodOfferService.findFoodOfferByUserId(actual); + List nuOfferLs = this.nuOfferService.findNuOfferByUserId(actual); + List speedOfferLs = this.speedOfferService.findSpeedOfferByUserId(actual); + List timeOfferLs = this.timeOfferService.findTimeOfferByUserId(actual); + + 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/myOffersList"; + } // @GetMapping("/owners/{ownerId}/edit") // public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) { // Owner owner = this.ownerService.findOwnerById(ownerId); 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 index 419dc2ad4..2162e8558 100644 --- a/src/main/java/org/springframework/cheapy/web/SpeedOfferController.java +++ b/src/main/java/org/springframework/cheapy/web/SpeedOfferController.java @@ -1,43 +1,26 @@ -/* - * 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.time.format.DateTimeFormatter; import java.util.Map; import javax.validation.Valid; -import org.springframework.cheapy.model.Client; 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.WebDataBinder; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @Controller public class SpeedOfferController { - private static final String VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM = "speedOffers/createOrUpdateSpeedOfferForm"; + private static final String VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM = "offers/speed/createOrUpdateSpeedOfferForm"; private final SpeedOfferService speedOfferService; private final ClientService clientService; @@ -45,58 +28,96 @@ public class SpeedOfferController { public SpeedOfferController(final SpeedOfferService speedOfferService, final ClientService clientService) { this.speedOfferService = speedOfferService; this.clientService = clientService; - } - @InitBinder - public void setAllowedFields(WebDataBinder dataBinder) { - dataBinder.setDisallowedFields("id"); - } - @GetMapping("/speedOffers/new") + @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("/speedOffers/new") + @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(); + } else { + Client client = this.clientService.getCurrentClient(); speedOffer.setClient(client); - speedOffer.setType(StatusOffer.hidden); + speedOffer.setStatus(StatusOffer.hidden); this.speedOfferService.saveSpeedOffer(speedOffer); - return "redirect:/speedOffers/" + speedOffer.getId(); + return "redirect:/offers/speed/" + speedOffer.getId(); } } + - @GetMapping(value = "/speedOffers/{speedOfferId}/activate") + @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.setType(StatusOffer.active); - speedOffer.setCode("SP-"+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:/speedOffers/"; + return "redirect:/offers/speed/" + speedOffer.getId(); } - - @GetMapping("/offers/speed/{speedOfferId}") + + @GetMapping("/offers/speed/{speedOfferId}") public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map model) { - SpeedOffer speedOffer=this.speedOfferService.findSpeedOfferById(speedOfferId); - + 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) { - return "speedOffers/speedOffersShow"; + 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 index b1bc2e528..41fcb27ce 100644 --- a/src/main/java/org/springframework/cheapy/web/TimeOfferController.java +++ b/src/main/java/org/springframework/cheapy/web/TimeOfferController.java @@ -1,96 +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.TimeOffer; 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.WebDataBinder; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; - @Controller public class TimeOfferController { - private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "timeOffers/createOrUpdateTimeOfferForm"; + private 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) { + public TimeOfferController(final TimeOfferService timeOfferService, ClientService clientService) { this.timeOfferService = timeOfferService; this.clientService = clientService; - } - @InitBinder - public void setAllowedFields(WebDataBinder dataBinder) { - dataBinder.setDisallowedFields("id"); - } - - @GetMapping("/timeOffers/new") + @GetMapping("/offers/time/new") public String initCreationForm(Map model) { TimeOffer timeOffer = new TimeOffer(); model.put("timeOffer", timeOffer); - return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM; + return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM; } - @PostMapping("/timeOffers/new") + @PostMapping("/offers/time/new") public String processCreationForm(@Valid TimeOffer timeOffer, BindingResult result) { if (result.hasErrors()) { - return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM; - } - else { - timeOffer.setType(StatusOffer.hidden); - + 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:/TimeOffers/" + timeOffer.getId(); + return "redirect:/offers/time/" + timeOffer.getId(); } } - @GetMapping(value ="/timeOffers/{timeOfferId}/activate") + + @GetMapping(value ="/offers/time/{timeOfferId}/activate") public String activateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap modelMap) { Client client = this.clientService.getCurrentClient(); - TimeOffer timeOffer=this.timeOfferService.findTimeOfferById(timeOfferId); - if(timeOffer.getClient().equals(client)) { - timeOffer.setType(StatusOffer.active); - timeOffer.setCode("TI-"+timeOfferId); + TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId); + if (timeOffer.getClient().equals(client)) { + timeOffer.setStatus(StatusOffer.active); + timeOffer.setCode("TI-" + timeOfferId); this.timeOfferService.saveTimeOffer(timeOffer); + - return "redirect:/timeOffers/" + timeOffer.getId(); } else { - modelMap.addAttribute("message", "You don't have access to this time offer"); - } - return "redirect:/timeOffers/"; - + modelMap.addAttribute("message", "You don't have access to this time offer"); + } + return "redirect:/offers/time/" + timeOffer.getId(); + } - - @GetMapping("/offers/time/{timeOfferId}") + + @GetMapping("/offers/time/{timeOfferId}") public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map model) { - TimeOffer timeOffer=this.timeOfferService.findTimeOfferById(timeOfferId); - + TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId); + model.put("timeOffer", timeOffer); + + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); - return "timeOffers/timeOffersShow"; + 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/less/cheapy.less b/src/main/less/cheapy.less index 0f326f7ed..2ad446686 100644 --- a/src/main/less/cheapy.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/data.sql b/src/main/resources/db/mysql/data.sql index 4678e73bb..39f0ca7b1 100644 --- a/src/main/resources/db/mysql/data.sql +++ b/src/main/resources/db/mysql/data.sql @@ -9,33 +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 food_offers(start, end, code, type, client_id, food, discount, units) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'FO-1', 'active', null, 'macarrones', '15%', 10); -INSERT INTO speed_offers(start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'SP-1', 'active', null, 5, '15%', 10, '10%', 15, '5%'); -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 speed_offers(start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null,5,'25%',10,'15%',15,'10%' ); -INSERT INTO nu_offers(start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null,15,'25%',10,'15%',5,'10%' ); - - -INSERT INTO users (dtype,username,password,enabled) VALUES ('user','admin','admin', TRUE ); +INSERT INTO users (dtype,username,password,enabled) VALUES ('User','admin','admin', TRUE ); INSERT INTO authorities VALUES ('admin','admin'); -INSERT INTO users (dtype,username,password,enabled) VALUES ('user','manoli','manoli', TRUE ); -INSERT INTO authorities VALUES ('manoli','cliente'); -INSERT INTO users (dtype,username,password,enabled) VALUES ('user','david','david', TRUE ); -INSERT INTO authorities VALUES ('david','cliente'); -INSERT INTO users (dtype,username,password,enabled) VALUES ('user','paco','paco', TRUE ); +INSERT INTO users (dtype,username,password,enabled) VALUES ('User','manoli','manoli', TRUE ); + +INSERT INTO authorities VALUES ('manoli','client'); +INSERT INTO users (dtype,username,password,enabled) VALUES ('User','david','david', TRUE ); +INSERT INTO authorities VALUES ('david','client'); + +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 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 users (dtype,username,password,enabled) VALUES ('User','pepe','pepe', TRUE ); INSERT INTO authorities VALUES ('pepe','usuario'); INSERT INTO usuarios VALUES (1, 'admin', 'admin', 'admin', 'C/admin', '000000000', 'admin@gmail.com','admin'); - -INSERT INTO clients VALUES (1,'manoli@gmail.com','C/Betis','10:00','22:00','608726190', 'description 1', 'code1', 'ESPAÑOLA','manoli'); -INSERT INTO clients VALUES (2,'david@gmail.com','C/Sevilla','09:30','22:00','608726190', 'description 2', 'code2', 'americana','david'); - 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 clients (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (1,'bar manoli','manoli@gmail.com','C/Betis','10:00','22:00','608726190', 'description 1', 'code1', 'ESPAÑOLA','manoli'); +INSERT INTO clients (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (2,'bar david','david@gmail.com','C/Sevilla','09:30','22:00','608726190', 'description 2', 'code2', 'americana','david'); + +INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'FO-1', 'inactive', 1, 'macarrones', 15); +INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'T-1', 'active', 1, '12:00:00', '13:00:00', 10); +INSERT INTO speed_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'SP-1', 'active',1,5,25,10,15,15,10); +INSERT INTO nu_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'NU-1', 'active',1,15,25,10,15,5,10); + 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/webapp/WEB-INF/jsp/error.jsp b/src/main/webapp/WEB-INF/jsp/error.jsp index 3534ac497..a1fcc6296 100644 --- a/src/main/webapp/WEB-INF/jsp/error.jsp +++ b/src/main/webapp/WEB-INF/jsp/error.jsp @@ -5,7 +5,7 @@ -

Algo malo ha pasado...

+

Algo malo ha pasado...

diff --git a/src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersShow.jsp deleted file mode 100644 index 0b7c8785a..000000000 --- a/src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersShow.jsp +++ /dev/null @@ -1,44 +0,0 @@ -<%@ 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" %> - - - -

Oferta por plato específico

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Inicio de la oferta
Fin de la oferta
Plato en oferta
Descuento
Cantidad
Codigo de la oferta
- - <%-- - - - Edit Owner --%> - -
diff --git a/src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersShow.jsp deleted file mode 100644 index 431d2a4d6..000000000 --- a/src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersShow.jsp +++ /dev/null @@ -1,56 +0,0 @@ -<%@ 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" %> - - - -

Oferta por número de comensales

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Inicio de la oferta
Fin de la oferta
Meta oro
Descuento oro
Meta plata
Descuento plata
Meta bronce
Descuento bronce
Codigo de la oferta
- - <%-- - - - Edit Owner --%> - -
diff --git a/src/main/webapp/WEB-INF/jsp/foodOffers/createOrUpdateFoodOfferForm.jsp b/src/main/webapp/WEB-INF/jsp/offers/food/createOrUpdateFoodOfferForm.jsp similarity index 81% rename from src/main/webapp/WEB-INF/jsp/foodOffers/createOrUpdateFoodOfferForm.jsp rename to src/main/webapp/WEB-INF/jsp/offers/food/createOrUpdateFoodOfferForm.jsp index ff6097fe2..daeeec363 100644 --- a/src/main/webapp/WEB-INF/jsp/foodOffers/createOrUpdateFoodOfferForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/offers/food/createOrUpdateFoodOfferForm.jsp @@ -12,18 +12,23 @@
+ + + -
- + + + +
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/myOffersList.jsp b/src/main/webapp/WEB-INF/jsp/offers/myOffersList.jsp new file mode 100644 index 000000000..201065542 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/offers/myOffersList.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/nuOffers/createOrUpdateNuOfferForm.jsp b/src/main/webapp/WEB-INF/jsp/offers/nu/createOrUpdateNuOfferForm.jsp similarity index 91% rename from src/main/webapp/WEB-INF/jsp/nuOffers/createOrUpdateNuOfferForm.jsp rename to src/main/webapp/WEB-INF/jsp/offers/nu/createOrUpdateNuOfferForm.jsp index e0d2366cd..904bbfffb 100644 --- a/src/main/webapp/WEB-INF/jsp/nuOffers/createOrUpdateNuOfferForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/offers/nu/createOrUpdateNuOfferForm.jsp @@ -12,6 +12,9 @@
+ + + @@ -27,10 +30,10 @@
- + - +
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 index 54efc214d..30ee72a07 100644 --- a/src/main/webapp/WEB-INF/jsp/offers/offersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/offers/offersList.jsp @@ -4,17 +4,18 @@ <%@ 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" %> + - -

Ofertas por plato específico

+ +

- - - + + + @@ -25,16 +26,20 @@ @@ -42,14 +47,14 @@
PlatoFecha inicioFecha fin
- + - + - - - - Enlace + + + +
+ +
-

Ofertas por número de comensales

+

- - + + @@ -59,29 +64,33 @@
Fecha inicioFecha fin
- + - + - - - - Enlace + + + +
+ +
-

Ofertas rapidez comiendo

+

- - + + @@ -91,30 +100,34 @@
Fecha inicioFecha fin
- + - + - Enlace +
+ +
-

Ofertas por franja horaria

+

- - + + @@ -123,16 +136,20 @@ diff --git a/src/main/webapp/WEB-INF/jsp/speedOffers/createOrUpdateSpeedOfferForm.jsp b/src/main/webapp/WEB-INF/jsp/offers/speed/createOrUpdateSpeedOfferForm.jsp similarity index 84% rename from src/main/webapp/WEB-INF/jsp/speedOffers/createOrUpdateSpeedOfferForm.jsp rename to src/main/webapp/WEB-INF/jsp/offers/speed/createOrUpdateSpeedOfferForm.jsp index 0e35b6ed3..3327373db 100644 --- a/src/main/webapp/WEB-INF/jsp/speedOffers/createOrUpdateSpeedOfferForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/offers/speed/createOrUpdateSpeedOfferForm.jsp @@ -12,6 +12,9 @@
+ + + @@ -25,8 +28,11 @@
- + + + +
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" %> + + + + +

+ + +
Fecha inicioFecha fin
- + - + - + - Enlace +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + Editar oferta + + + + + Desactivar oferta + +
diff --git a/src/main/webapp/WEB-INF/jsp/timeOffers/createOrUpdateTimeOfferForm.jsp b/src/main/webapp/WEB-INF/jsp/offers/time/createOrUpdateTimeOfferForm.jsp similarity index 89% rename from src/main/webapp/WEB-INF/jsp/timeOffers/createOrUpdateTimeOfferForm.jsp rename to src/main/webapp/WEB-INF/jsp/offers/time/createOrUpdateTimeOfferForm.jsp index 0dc37f439..cd12ad6fc 100644 --- a/src/main/webapp/WEB-INF/jsp/timeOffers/createOrUpdateTimeOfferForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/offers/time/createOrUpdateTimeOfferForm.jsp @@ -12,12 +12,16 @@
+ + + - + +
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/speedOffers/speedOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/speedOffers/speedOffersShow.jsp deleted file mode 100644 index 4a85df28b..000000000 --- a/src/main/webapp/WEB-INF/jsp/speedOffers/speedOffersShow.jsp +++ /dev/null @@ -1,56 +0,0 @@ -<%@ 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" %> - - - -

Oferta por comer veloz

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Inicio de la oferta
Fin de la oferta
Meta oro
Descuento oro
Meta plata
Descuento plata
Meta bronce
Descuento bronce
Codigo de la oferta
- - <%-- - - - Edit Owner --%> - -
diff --git a/src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersShow.jsp b/src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersShow.jsp deleted file mode 100644 index a344a6221..000000000 --- a/src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersShow.jsp +++ /dev/null @@ -1,31 +0,0 @@ -<%@ 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" %> - - - -

Oferta por franja horária

- - - - - - - - - - - - - - - - - - - -
Inicio de la oferta
Fin de la oferta
Descuento
Codigo de la oferta
- -
diff --git a/src/main/webapp/WEB-INF/jsp/welcome.jsp b/src/main/webapp/WEB-INF/jsp/welcome.jsp index fc2db8671..95c506f42 100644 --- a/src/main/webapp/WEB-INF/jsp/welcome.jsp +++ b/src/main/webapp/WEB-INF/jsp/welcome.jsp @@ -6,7 +6,7 @@ -

+

@@ -14,8 +14,9 @@
- - +
diff --git a/src/main/webapp/WEB-INF/tags/menu.tag b/src/main/webapp/WEB-INF/tags/menu.tag index d402d3729..10a512467 100644 --- a/src/main/webapp/WEB-INF/tags/menu.tag +++ b/src/main/webapp/WEB-INF/tags/menu.tag @@ -25,7 +25,7 @@ - Home + Inicio Ver ofertas + + + + Mis ofertas + + + @@ -48,7 +55,7 @@