mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Merge branch 'develop' into 025-cambiar-vistas-sprint2
This commit is contained in:
commit
965d2cca23
55 changed files with 2164 additions and 563 deletions
|
@ -6,8 +6,10 @@ import javax.persistence.Table;
|
|||
|
||||
@Entity
|
||||
@Table(name = "authorities")
|
||||
public class Authorities{
|
||||
public class Authorities {
|
||||
|
||||
|
||||
//@NotNull
|
||||
@Id
|
||||
String username;
|
||||
|
||||
|
@ -25,34 +27,41 @@ public class Authorities{
|
|||
public void setAuthority(String authority) {
|
||||
this.authority = authority;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((authority == null) ? 0 : authority.hashCode());
|
||||
result = prime * result + ((username == null) ? 0 : username.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Authorities other = (Authorities) obj;
|
||||
if (authority == null) {
|
||||
if (other.authority != null)
|
||||
return false;
|
||||
} else if (!authority.equals(other.authority))
|
||||
return false;
|
||||
if (username == null) {
|
||||
if (other.username != null)
|
||||
return false;
|
||||
} else if (!username.equals(other.username))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Authorities [username=" + username + ", authority=" + authority + "]";
|
||||
}
|
||||
|
||||
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "username")
|
||||
// private Usuario user;
|
||||
//
|
||||
// @Size(min = 3, max = 50)
|
||||
// private String authority;
|
||||
//
|
||||
// public Usuario getUser() {
|
||||
// return user;
|
||||
// }
|
||||
//
|
||||
// public void setUser(Usuario usern) {
|
||||
// this.user = usern;
|
||||
// }
|
||||
//
|
||||
// public String getAuthority() {
|
||||
// return authority;
|
||||
// }
|
||||
//
|
||||
// public void setAuthority(String authority) {
|
||||
// this.authority = authority;
|
||||
// }
|
||||
//
|
||||
// public static long getSerialversionuid() {
|
||||
// return serialVersionUID;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
|||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
|
@ -32,6 +34,10 @@ public class Client extends BaseEntity {
|
|||
|
||||
@NotEmpty
|
||||
private String address;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@NotNull
|
||||
private Municipio municipio;
|
||||
|
||||
// Hora de apertura del local
|
||||
@DateTimeFormat(pattern = "HH:mm")
|
||||
|
@ -51,8 +57,8 @@ public class Client extends BaseEntity {
|
|||
private String description;
|
||||
|
||||
// Codigo de activacion de cuenta
|
||||
@NotEmpty
|
||||
private String code;
|
||||
// @NotEmpty
|
||||
// private String code;
|
||||
|
||||
@NotEmpty
|
||||
private String food;
|
||||
|
@ -60,6 +66,10 @@ public class Client extends BaseEntity {
|
|||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "username", referencedColumnName = "username")
|
||||
private User usuar;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "code", referencedColumnName = "code")
|
||||
private Code cod;
|
||||
|
||||
@OneToMany
|
||||
private List<FoodOffer> foodOffers;
|
||||
|
@ -129,12 +139,20 @@ public class Client extends BaseEntity {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
public Municipio getMunicipio() {
|
||||
return municipio;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
public void setMunicipio(Municipio municipio) {
|
||||
this.municipio = municipio;
|
||||
}
|
||||
|
||||
public Code getCode() {
|
||||
return cod;
|
||||
}
|
||||
|
||||
public void setCode(Code code) {
|
||||
this.cod = code;
|
||||
}
|
||||
|
||||
public String getFood() {
|
||||
|
|
38
src/main/java/org/springframework/cheapy/model/Code.java
Normal file
38
src/main/java/org/springframework/cheapy/model/Code.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package org.springframework.cheapy.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "codes")
|
||||
public class Code extends BaseEntity{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
String code;
|
||||
|
||||
Boolean activo;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Boolean getActivo() {
|
||||
return activo;
|
||||
}
|
||||
|
||||
public void setActivo(Boolean activo) {
|
||||
this.activo = activo;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.springframework.cheapy.model;
|
||||
|
||||
public enum Municipio {
|
||||
sevilla,dos_hermanas,carmona,bollullos,pilas,montellano,mairena_aljarafe,mairena_alcor
|
||||
}
|
|
@ -7,18 +7,27 @@ import javax.validation.constraints.NotBlank;
|
|||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class User{
|
||||
public class User {
|
||||
|
||||
|
||||
|
||||
@Id
|
||||
@NotBlank
|
||||
private String username;
|
||||
|
||||
@NotBlank
|
||||
private String password;
|
||||
|
||||
boolean enabled;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Boolean enabled;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
|
@ -36,11 +45,48 @@ public class User{
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return enabled;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((enabled == null) ? 0 : enabled.hashCode());
|
||||
result = prime * result + ((password == null) ? 0 : password.hashCode());
|
||||
result = prime * result + ((username == null) ? 0 : username.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
User other = (User) obj;
|
||||
if (enabled == null) {
|
||||
if (other.enabled != null)
|
||||
return false;
|
||||
} else if (!enabled.equals(other.enabled))
|
||||
return false;
|
||||
if (password == null) {
|
||||
if (other.password != null)
|
||||
return false;
|
||||
} else if (!password.equals(other.password))
|
||||
return false;
|
||||
if (username == null) {
|
||||
if (other.username != null)
|
||||
return false;
|
||||
} else if (!username.equals(other.username))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User [username=" + username + ", password=" + password + ", enabled=" + enabled + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.springframework.cheapy.model;
|
|||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
@ -23,16 +25,12 @@ public class Usuario extends BaseEntity{
|
|||
@NotBlank
|
||||
private String apellidos;
|
||||
|
||||
@NotBlank
|
||||
private String dni;
|
||||
|
||||
@NotBlank
|
||||
private String direccion;
|
||||
|
||||
@NotBlank
|
||||
//@Pattern(regexp = "([+][^0][\\d]{0,2})?[ ]?([(][\\d]{0,4}[)])?[ ]?([\\d]{6,10})$")
|
||||
private String telefono;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private Municipio municipio;
|
||||
|
||||
@Email
|
||||
@NotBlank
|
||||
private String email;
|
||||
|
@ -57,13 +55,6 @@ public class Usuario extends BaseEntity{
|
|||
this.apellidos = apellidos;
|
||||
}
|
||||
|
||||
public String getDni() {
|
||||
return dni;
|
||||
}
|
||||
|
||||
public void setDni(String dni) {
|
||||
this.dni = dni;
|
||||
}
|
||||
|
||||
public String getDireccion() {
|
||||
return direccion;
|
||||
|
@ -73,12 +64,20 @@ public class Usuario extends BaseEntity{
|
|||
this.direccion = direccion;
|
||||
}
|
||||
|
||||
public String getTelefono() {
|
||||
return telefono;
|
||||
public Municipio getMunicipio() {
|
||||
return municipio;
|
||||
}
|
||||
|
||||
public void setTelefono(String telefono) {
|
||||
this.telefono = telefono;
|
||||
public void setMunicipio(Municipio municipio) {
|
||||
this.municipio = municipio;
|
||||
}
|
||||
|
||||
public User getUsuar() {
|
||||
return usuar;
|
||||
}
|
||||
|
||||
public void setUsuar(User usuar) {
|
||||
this.usuar = usuar;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
|
@ -89,13 +88,7 @@ public class Usuario extends BaseEntity{
|
|||
this.email = email;
|
||||
}
|
||||
|
||||
public User getUsuar() {
|
||||
return usuar;
|
||||
}
|
||||
|
||||
public void setUsuar(User username) {
|
||||
this.usuar = username;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
package org.springframework.cheapy.repository;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.Authorities;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
public interface AuthoritiesRepository extends CrudRepository<Authorities, Integer>{
|
||||
public interface AuthoritiesRepository extends CrudRepository<Authorities, String>{
|
||||
|
||||
// @Autowired
|
||||
// void save(Authorities authorities);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,12 +6,14 @@ import java.util.List;
|
|||
|
||||
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.Code;
|
||||
import org.springframework.cheapy.model.Usuario;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface ClientRepository extends CrudRepository<Client, String> {
|
||||
public interface ClientRepository extends Repository<Client, Integer> {
|
||||
|
||||
@Query("SELECT client FROM Client client WHERE username =:username")
|
||||
@Transactional(readOnly = true)
|
||||
|
@ -26,5 +28,7 @@ public interface ClientRepository extends CrudRepository<Client, String> {
|
|||
@Transactional(readOnly = true)
|
||||
List<Client> findAllClient();
|
||||
|
||||
|
||||
}
|
||||
void save(Client client);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package org.springframework.cheapy.repository;
|
||||
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.Code;
|
||||
import org.springframework.cheapy.model.Usuario;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface CodeRepository extends Repository<Code, Integer> {
|
||||
|
||||
void save(Code code);
|
||||
|
||||
@Query("SELECT code FROM Code code WHERE code.code =:code")
|
||||
@Transactional(readOnly = true)
|
||||
Code findCodeByCode(String code);
|
||||
|
||||
}
|
|
@ -34,4 +34,13 @@ public interface FoodOfferRepository extends PagingAndSortingRepository<FoodOffe
|
|||
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE foodOffer.client.id =:id AND foodOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<FoodOffer> findFoodOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE foodOffer.client.name LIKE :name AND foodOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<FoodOffer> findFoodOfferByClientName(String name);
|
||||
|
||||
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE foodOffer.client.food LIKE :name AND foodOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<FoodOffer> findFoodOfferByClientFood(String name);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,33 +1,42 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface NuOfferRepository extends Repository<NuOffer, Integer> {
|
||||
public interface NuOfferRepository extends PagingAndSortingRepository<NuOffer, Integer> {
|
||||
|
||||
NuOffer findNuOfferById(int nuOfferId);
|
||||
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findAllNuOffer();
|
||||
List<NuOffer> findAllNuOffer(Pageable p);
|
||||
|
||||
//void save(NuOffer nuOffer);
|
||||
|
||||
void save(NuOffer nuOffer);
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.status =:status")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findActiveNuOffer(StatusOffer status);
|
||||
|
||||
List<NuOffer> findActiveNuOffer(StatusOffer status, Pageable p);
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.id =:id AND nuOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findNuOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.name LIKE :name AND nuOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findNuOfferByClientName(String name);
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.food LIKE :name AND nuOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findNuOfferByClientFood(String name);
|
||||
}
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cheapy.model.Review;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface ReviewRepository extends Repository<Review, Integer> {
|
||||
public interface ReviewRepository extends PagingAndSortingRepository<Review, Integer> {
|
||||
|
||||
@Query("SELECT r FROM Review r")
|
||||
@Transactional(readOnly = true)
|
||||
List<Review> findAllReviews();
|
||||
List<Review> findAllReviews(Pageable p);
|
||||
|
||||
//void save(Review review);
|
||||
|
||||
void save(Review review);
|
||||
|
||||
@Query("SELECT r FROM Review r WHERE id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
Review findReviewById(@Param("id") Integer id);
|
||||
|
|
|
@ -1,35 +1,45 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface SpeedOfferRepository extends Repository<SpeedOffer, Integer> {
|
||||
public interface SpeedOfferRepository extends PagingAndSortingRepository<SpeedOffer, Integer> {
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
SpeedOffer findById(@Param("id") Integer id);
|
||||
|
||||
SpeedOffer findByIdSO(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findAllSpeedOffer();
|
||||
|
||||
void save(SpeedOffer speedOffer);
|
||||
|
||||
List<SpeedOffer> findAllSpeedOffer(Pageable p);
|
||||
|
||||
//void save(SpeedOffer speedOffer);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.status =:status")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findActiveSpeedOffer(StatusOffer status);
|
||||
|
||||
List<SpeedOffer> findActiveSpeedOffer(StatusOffer status, Pageable p);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.id =:id AND speedOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findSpeedOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.name LIKE :name AND speedOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findSpeedOfferByClientName(String name);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.food LIKE :name AND speedOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findSpeedOfferByClientFood(String name);
|
||||
}
|
||||
|
|
|
@ -1,33 +1,44 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
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.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface TimeOfferRepository extends Repository<TimeOffer, Integer> {
|
||||
public interface TimeOfferRepository extends PagingAndSortingRepository<FoodOffer, Integer> {
|
||||
|
||||
TimeOffer findTimeOfferById(int timeOfferId);
|
||||
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findAllTimeOffer();
|
||||
List<TimeOffer> findAllTimeOffer(Pageable p);
|
||||
|
||||
void save(TimeOffer timeOffer);
|
||||
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.status =:status")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findActiveTimeOffer(StatusOffer status);
|
||||
|
||||
List<TimeOffer> findActiveTimeOffer(StatusOffer status, Pageable p);
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.id =:id AND timeOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findTimeOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.name LIKE :name AND timeOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findTimeOfferByClientName(String name);
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.food LIKE :name AND timeOffer.status= 'active'")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findTimeOfferByClientFood(String name);
|
||||
}
|
||||
|
|
|
@ -3,13 +3,18 @@ package org.springframework.cheapy.repository;
|
|||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.model.Usuario;
|
||||
|
||||
public interface UserRepository extends CrudRepository<Usuario, String> {
|
||||
public interface UserRepository extends Repository<User, Integer> {
|
||||
|
||||
@Query("SELECT u FROM User u WHERE username =:username")
|
||||
@Transactional(readOnly = true)
|
||||
User findByUsername(String username);
|
||||
|
||||
|
||||
void save(User user);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -17,6 +18,11 @@ public interface UsuarioRepository extends Repository<Usuario, String> {
|
|||
@Transactional(readOnly = true)
|
||||
List<Usuario> findAllUsuario();
|
||||
|
||||
@Query("SELECT usuario FROM Usuario usuario WHERE usuario.usuar.enabled = true")
|
||||
@Transactional(readOnly = true)
|
||||
List<Usuario> findUsuarioEnabled();
|
||||
|
||||
void save(Usuario usuario);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,14 +15,20 @@
|
|||
*/
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.Authorities;
|
||||
import org.springframework.cheapy.repository.AuthoritiesRepository;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class AuthoritiesService {
|
||||
/*
|
||||
private AuthoritiesRepository authoritiesRepository;
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private AuthoritiesRepository authoritiesRepository;
|
||||
// private UserService userService;
|
||||
/*
|
||||
@Autowired
|
||||
public AuthoritiesService(AuthoritiesRepository authoritiesRepository,UserService userService) {
|
||||
this.authoritiesRepository = authoritiesRepository;
|
||||
|
@ -33,12 +39,20 @@ public class AuthoritiesService {
|
|||
public Authorities findAuthoritiyByUser(User user) {
|
||||
return this.authoritiesRepository.findByUser(user.getUsername());
|
||||
}
|
||||
|
||||
*/
|
||||
@Transactional
|
||||
public void saveAuthorities(Authorities authorities) throws DataAccessException {
|
||||
authoritiesRepository.save(authorities);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveAuthorities(String username, String role) throws DataAccessException {
|
||||
Authorities authority = new Authorities();
|
||||
authority.setUsername(username);
|
||||
authority.setAuthority(role);
|
||||
authoritiesRepository.save(authority);
|
||||
}
|
||||
/*
|
||||
@Transactional
|
||||
public void saveAuthorities(String username, String role) throws DataAccessException {
|
||||
Authorities authority = new Authorities();
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.Code;
|
||||
import org.springframework.cheapy.model.Usuario;
|
||||
import org.springframework.cheapy.repository.ClientRepository;
|
||||
import org.springframework.cheapy.repository.CodeRepository;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
@ -15,10 +20,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
public class ClientService {
|
||||
|
||||
private ClientRepository clientRepository;
|
||||
private CodeRepository codeRepository;
|
||||
|
||||
@Autowired
|
||||
public ClientService(final ClientRepository clientRepository) {
|
||||
public ClientService(final ClientRepository clientRepository, CodeRepository codeRepository) {
|
||||
this.clientRepository = clientRepository;
|
||||
this.codeRepository = codeRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
@ -27,15 +34,25 @@ public class ClientService {
|
|||
String username = authentication.getName();
|
||||
return this.clientRepository.findByUsername(username);
|
||||
}
|
||||
|
||||
public void saveClient(final Client client) throws DataAccessException {
|
||||
this.clientRepository.save(client);
|
||||
}
|
||||
|
||||
public void saveCode(Code code) throws DataAccessException{
|
||||
this.codeRepository.save(code);
|
||||
|
||||
}
|
||||
|
||||
public Code findCodeByCode(String code) {
|
||||
return this.codeRepository.findCodeByCode(code);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Client findByUsername(String username) throws DataAccessException {
|
||||
return this.clientRepository.findByUsername(username);
|
||||
}
|
||||
|
||||
public void saveClient(final Client client) throws DataAccessException {
|
||||
this.clientRepository.save(client);
|
||||
}
|
||||
@Transactional
|
||||
public List<Client> findAllClient() throws DataAccessException {
|
||||
return this.clientRepository.findAllClient();
|
||||
|
|
|
@ -45,4 +45,14 @@ public class FoodOfferService {
|
|||
public List<FoodOffer> findFoodOfferActOclByUserId(final int id) {
|
||||
return this.foodOfferRepository.findFoodOfferActOclByUserId(id);
|
||||
}
|
||||
|
||||
public List<FoodOffer> findFoodOfferByClientName(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.foodOfferRepository.findFoodOfferByClientName(nameEdit);
|
||||
}
|
||||
|
||||
public List<FoodOffer> findFoodOfferByClientFood(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.foodOfferRepository.findFoodOfferByClientFood(nameEdit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.List;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -15,6 +17,7 @@ public class NuOfferService {
|
|||
|
||||
private NuOfferRepository nuOfferRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
public NuOfferService(final NuOfferRepository nuOfferRepository) {
|
||||
this.nuOfferRepository = nuOfferRepository;
|
||||
|
@ -26,29 +29,39 @@ public class NuOfferService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public List<NuOffer> findAllNuOffer() {
|
||||
return this.nuOfferRepository.findAllNuOffer();
|
||||
public List<NuOffer> findAllNuOffer(final Pageable page) {
|
||||
return this.nuOfferRepository.findAllNuOffer(page);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException {
|
||||
this.nuOfferRepository.save(nuOffer);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void saveUpdateNuOffer(final NuOffer nuOfferNew, final NuOffer nuOfferOld) throws DataAccessException {
|
||||
this.nuOfferRepository.save(nuOfferNew);
|
||||
}
|
||||
|
||||
public List<NuOffer> findActiveNuOffer() {
|
||||
return this.nuOfferRepository.findActiveNuOffer(StatusOffer.active);
|
||||
|
||||
public List<NuOffer> findActiveNuOffer(final Pageable page) {
|
||||
return this.nuOfferRepository.findActiveNuOffer(StatusOffer.active, page);
|
||||
}
|
||||
|
||||
|
||||
public List<NuOffer> findNuOfferByUserId(final int id) {
|
||||
return this.nuOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
|
||||
public List<NuOffer> findNuOfferActOclByUserId(final int id) {
|
||||
return this.nuOfferRepository.findNuOfferActOclByUserId(id);
|
||||
}
|
||||
|
||||
public List<NuOffer> findNuOfferByClientName(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.nuOfferRepository.findNuOfferByClientName(nameEdit);
|
||||
}
|
||||
|
||||
public List<NuOffer> findNuOfferByClientFood(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.nuOfferRepository.findNuOfferByClientFood(nameEdit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -5,15 +6,17 @@ import java.util.List;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.Review;
|
||||
import org.springframework.cheapy.repository.ReviewRepository;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class ReviewService {
|
||||
|
||||
private ReviewRepository reviewRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
public ReviewService(final ReviewRepository reviewRepository) {
|
||||
this.reviewRepository = reviewRepository;
|
||||
|
@ -25,8 +28,8 @@ public class ReviewService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public List<Review> findAllReviews() {
|
||||
return this.reviewRepository.findAllReviews();
|
||||
public List<Review> findAllReviews(final Pageable page) {
|
||||
return this.reviewRepository.findAllReviews(page);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.repository.SpeedOfferRepository;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -23,28 +25,38 @@ public class SpeedOfferService {
|
|||
|
||||
@Transactional
|
||||
public SpeedOffer findSpeedOfferById(final int id) {
|
||||
return this.speedOfferRepository.findById(id);
|
||||
return this.speedOfferRepository.findByIdSO(id);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public List<SpeedOffer> findAllSpeedOffer() { //
|
||||
return this.speedOfferRepository.findAllSpeedOffer();
|
||||
public List<SpeedOffer> findAllSpeedOffer(final Pageable page) { //
|
||||
return this.speedOfferRepository.findAllSpeedOffer(page);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { //
|
||||
this.speedOfferRepository.save(speedOffer);
|
||||
}
|
||||
|
||||
public List<SpeedOffer> findActiveSpeedOffer() {
|
||||
return this.speedOfferRepository.findActiveSpeedOffer(StatusOffer.active);
|
||||
|
||||
public List<SpeedOffer> findActiveSpeedOffer(final Pageable page) {
|
||||
return this.speedOfferRepository.findActiveSpeedOffer(StatusOffer.active, page);
|
||||
}
|
||||
|
||||
|
||||
public List<SpeedOffer> findSpeedOfferByUserId(final int id) {
|
||||
return this.speedOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
|
||||
public List<SpeedOffer> findSpeedOfferActOclByUserId(final int id) {
|
||||
return this.speedOfferRepository.findSpeedOfferActOclByUserId(id);
|
||||
}
|
||||
|
||||
public List<SpeedOffer> findSpeedOfferByClientName(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.speedOfferRepository.findSpeedOfferByClientName(nameEdit);
|
||||
}
|
||||
|
||||
public List<SpeedOffer> findSpeedOfferByClientFood(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.speedOfferRepository.findSpeedOfferByClientFood(nameEdit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -6,12 +7,13 @@ 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;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TimeOfferService {
|
||||
|
||||
private TimeOfferRepository timeOfferRepository;
|
||||
|
||||
|
||||
|
@ -23,25 +25,34 @@ public class TimeOfferService {
|
|||
public TimeOffer findTimeOfferById(final int id) {
|
||||
return this.timeOfferRepository.findTimeOfferById(id);
|
||||
}
|
||||
|
||||
public List<TimeOffer> findAllTimeOffer() {
|
||||
return this.timeOfferRepository.findAllTimeOffer();
|
||||
|
||||
public List<TimeOffer> findAllTimeOffer(final Pageable page) {
|
||||
return this.timeOfferRepository.findAllTimeOffer(page);
|
||||
}
|
||||
|
||||
|
||||
public void saveTimeOffer(final TimeOffer TimeOffer) throws DataAccessException {
|
||||
public void saveTimeOffer(final TimeOffer TimeOffer) throws DataAccessException {
|
||||
this.timeOfferRepository.save(TimeOffer);
|
||||
}
|
||||
|
||||
public List<TimeOffer> findActiveTimeOffer() {
|
||||
return this.timeOfferRepository.findActiveTimeOffer(StatusOffer.active);
|
||||
|
||||
public List<TimeOffer> findActiveTimeOffer(final Pageable p) {
|
||||
return this.timeOfferRepository.findActiveTimeOffer(StatusOffer.active, p);
|
||||
}
|
||||
|
||||
|
||||
public List<TimeOffer> findTimeOfferByUserId(final int id) {
|
||||
return this.timeOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
|
||||
public List<TimeOffer> findTimeOfferActOclByUserId(final int id) {
|
||||
return this.timeOfferRepository.findTimeOfferActOclByUserId(id);
|
||||
}
|
||||
|
||||
public List<TimeOffer> findTimeOfferByClientName(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.timeOfferRepository.findTimeOfferByClientName(nameEdit);
|
||||
}
|
||||
|
||||
public List<TimeOffer> findTimeOfferByClientFood(String name) {
|
||||
String nameEdit = "%"+name+"%";
|
||||
return this.timeOfferRepository.findTimeOfferByClientFood(nameEdit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.springframework.cheapy.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.repository.UserRepository;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
@ -25,5 +26,8 @@ public class UserService {
|
|||
String username = authentication.getName();
|
||||
return this.userRepository.findByUsername(username);
|
||||
}
|
||||
|
||||
|
||||
public void saveUser(final User user) throws DataAccessException {
|
||||
this.userRepository.save(user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ public class UsuarioService {
|
|||
|
||||
private UsuarioRepository usuarioRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
public UsuarioService(final UsuarioRepository usuarioRepository) {
|
||||
this.usuarioRepository = usuarioRepository;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public Usuario getCurrentUsuario() throws DataAccessException {
|
||||
|
@ -39,6 +39,11 @@ public class UsuarioService {
|
|||
public List<Usuario> findAllUsuario() throws DataAccessException {
|
||||
return this.usuarioRepository.findAllUsuario();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Usuario> findUsuarioEnabled() throws DataAccessException {
|
||||
return this.usuarioRepository.findUsuarioEnabled();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveUsuario(final Usuario usuario) throws DataAccessException {
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
package org.springframework.cheapy.system;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.Authorities;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.Code;
|
||||
import org.springframework.cheapy.model.Municipio;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.model.Usuario;
|
||||
import org.springframework.cheapy.service.AuthoritiesService;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.UserService;
|
||||
import org.springframework.cheapy.service.UsuarioService;
|
||||
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.PostMapping;
|
||||
|
||||
@Controller
|
||||
public class SingUpController {
|
||||
|
||||
//private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";
|
||||
|
||||
@Autowired
|
||||
private final ClientService clientService;
|
||||
@Autowired
|
||||
private final UserService userService;
|
||||
@Autowired
|
||||
private final UsuarioService usuarioService;
|
||||
@Autowired
|
||||
private final AuthoritiesService authoritiesService;
|
||||
|
||||
|
||||
public SingUpController(final ClientService clientService, UserService userService, AuthoritiesService authoritiesService,
|
||||
UsuarioService usuarioService) {
|
||||
this.clientService = clientService;
|
||||
this.userService = userService;
|
||||
this.authoritiesService = authoritiesService;
|
||||
this.usuarioService = usuarioService;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
private boolean checkTimes(final Client client) {
|
||||
boolean res = false;
|
||||
if(client.getFinish()==null || client.getInit()==null || client.getFinish().isAfter(client.getInit())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/users/new")
|
||||
public String singUpUserForm(Map<String, Object> model) {
|
||||
Usuario usuario = new Usuario();
|
||||
|
||||
User user=new User();
|
||||
|
||||
usuario.setUsuar(user);
|
||||
model.put("municipio", Municipio.values());
|
||||
model.put("usuario", usuario);
|
||||
//model.put("user", user);
|
||||
return "singup/singUpUser";
|
||||
}
|
||||
|
||||
@PostMapping("/users/new")
|
||||
public String singUpUserForm(/*@Valid User user,*/ @Valid Usuario usuario, BindingResult result) {
|
||||
Authorities auth=new Authorities();
|
||||
User user= usuario.getUsuar();
|
||||
user.setEnabled(true);
|
||||
usuario.setUsuar(user);
|
||||
auth.setUsername(user.getUsername());
|
||||
auth.setAuthority("usuario");
|
||||
if (result.hasErrors()) {
|
||||
return "singup/singUpUser";
|
||||
}
|
||||
else {
|
||||
//auth.setId(1);
|
||||
//this.authoritiesService.saveAuthorities(auth);
|
||||
this.usuarioService.saveUsuario(usuario);
|
||||
this.userService.saveUser(user);
|
||||
this.authoritiesService.saveAuthorities(usuario.getUsuar().getUsername(), "usuario");
|
||||
|
||||
return "redirect:/";
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/clients/new")
|
||||
public String singUpClientForm(Map<String, Object> model) {
|
||||
Client cliente = new Client();
|
||||
|
||||
User user=new User();
|
||||
|
||||
cliente.setUsuar(user);
|
||||
model.put("municipio", Municipio.values());
|
||||
model.put("cliente", cliente);
|
||||
//model.put("user", user);
|
||||
return "singup/singUpClient";
|
||||
}
|
||||
|
||||
@PostMapping("/clients/new")
|
||||
public String singUpClientForm(/*@Valid User user,*/ @Valid Client cliente, final BindingResult result, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
Authorities auth=new Authorities();
|
||||
String cod=cliente.getCode().getCode();
|
||||
Code code=this.clientService.findCodeByCode(cod);
|
||||
User user= cliente.getUsuar();
|
||||
user.setEnabled(true);
|
||||
cliente.setUsuar(user);
|
||||
auth.setUsername(user.getUsername());
|
||||
auth.setAuthority("client");
|
||||
if(!this.checkTimes(cliente)) {
|
||||
result.rejectValue("finish","" ,"La hora de cierre debe ser posterior a la hora de apertura");
|
||||
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
model.put("municipio", Municipio.values());
|
||||
model.put("cliente", cliente);
|
||||
return "singup/singUpClient";
|
||||
}else if(code.getActivo().equals(false)) {
|
||||
return "error";
|
||||
}else {
|
||||
code.setActivo(false);
|
||||
this.clientService.saveCode(code);
|
||||
cliente.setCode(code);
|
||||
this.clientService.saveClient(cliente);
|
||||
this.userService.saveUser(user);
|
||||
this.authoritiesService.saveAuthorities(cliente.getUsuar().getUsername(), "client");
|
||||
|
||||
|
||||
return "redirect:/";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,17 @@ import java.util.Map;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.model.Usuario;
|
||||
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.cheapy.service.UsuarioService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
|
@ -22,15 +31,26 @@ public class AdministratorController {
|
|||
|
||||
private final UsuarioService usuarioService;
|
||||
private final ClientService clientService;
|
||||
|
||||
private final FoodOfferService foodOfferService;
|
||||
private final SpeedOfferService speedOfferService;
|
||||
private final NuOfferService nuOfferService;
|
||||
private final TimeOfferService timeOfferService;
|
||||
|
||||
public AdministratorController(final UsuarioService usuarioService, ClientService clientService) {
|
||||
public AdministratorController(final UsuarioService usuarioService, ClientService clientService,
|
||||
FoodOfferService foodOfferService, SpeedOfferService speedOfferService, NuOfferService nuOfferService,
|
||||
TimeOfferService timeOfferService ) {
|
||||
this.usuarioService = usuarioService;
|
||||
this.clientService=clientService;
|
||||
this.foodOfferService=foodOfferService;
|
||||
this.speedOfferService=speedOfferService;
|
||||
this.nuOfferService=nuOfferService;
|
||||
this.timeOfferService=timeOfferService;
|
||||
}
|
||||
|
||||
@GetMapping("/administrators/usuarios")
|
||||
public String processFindUsuariosForm(Map<String, Object> model) {
|
||||
List<Usuario> usuarioLs = this.usuarioService.findAllUsuario();
|
||||
List<Usuario> usuarioLs = this.usuarioService.findUsuarioEnabled();
|
||||
model.put("usuarioLs", usuarioLs);
|
||||
return "usuarios/usuariosList";
|
||||
}
|
||||
|
@ -86,6 +106,36 @@ public class AdministratorController {
|
|||
|
||||
Client client = this.clientService.findByUsername(username);
|
||||
client.getUsuar().setEnabled(false);
|
||||
|
||||
List<FoodOffer> foodOffers=this.foodOfferService.findFoodOfferByUserId(client.getId());
|
||||
List<SpeedOffer> speedOffers=this.speedOfferService.findSpeedOfferByUserId(client.getId());
|
||||
List<NuOffer> nuOffers=this.nuOfferService.findNuOfferByUserId(client.getId());
|
||||
List<TimeOffer> timeOffers=this.timeOfferService.findTimeOfferByUserId(client.getId());
|
||||
|
||||
foodOffers.stream().forEach(f->f.setStatus(StatusOffer.inactive));
|
||||
|
||||
speedOffers.stream().forEach(s->s.setStatus(StatusOffer.inactive));
|
||||
|
||||
nuOffers.stream().forEach(n->n.setStatus(StatusOffer.inactive));
|
||||
|
||||
timeOffers.stream().forEach(t->t.setStatus(StatusOffer.inactive));
|
||||
|
||||
this.clientService.saveClient(client);
|
||||
return "redirect:/administrators/clients";
|
||||
}
|
||||
|
||||
@GetMapping(value = "/administrators/clients/{username}/activate")
|
||||
public String activateClient(@PathVariable("username") final String username, final ModelMap model) {
|
||||
|
||||
Client client = this.clientService.findByUsername(username);
|
||||
model.put("client", client);
|
||||
return "clients/clientActivate";
|
||||
}
|
||||
@PostMapping(value = "/administrators/clients/{username}/activate")
|
||||
public String activateClientForm(@PathVariable("username") final String username, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
Client client = this.clientService.findByUsername(username);
|
||||
client.getUsuar().setEnabled(true);
|
||||
this.clientService.saveClient(client);
|
||||
return "redirect:/administrators/clients";
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.beans.BeanUtils;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.Municipio;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
|
@ -84,7 +85,8 @@ public class ClientController {
|
|||
public String updateClient( final ModelMap model, HttpServletRequest request) {
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
||||
|
||||
model.put("municipio", Municipio.values());
|
||||
model.addAttribute("client", client);
|
||||
|
||||
return ClientController.VIEWS_CREATE_OR_UPDATE_CLIENT;
|
||||
|
@ -96,7 +98,6 @@ public class ClientController {
|
|||
|
||||
|
||||
Client clienteSesion = this.clientService.getCurrentClient();
|
||||
|
||||
if(!this.checkTimes(clientEdit)) {
|
||||
result.rejectValue("finish","" ,"La hora de cierre debe ser posterior a la hora de apertura");
|
||||
|
||||
|
@ -105,6 +106,7 @@ public class ClientController {
|
|||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("client", clientEdit);
|
||||
model.put("municipio", Municipio.values());
|
||||
return ClientController.VIEWS_CREATE_OR_UPDATE_CLIENT;
|
||||
}
|
||||
|
||||
|
@ -161,7 +163,6 @@ public class ClientController {
|
|||
public String showRestaurant(final ModelMap model, @PathVariable("clientId") Integer id) {
|
||||
|
||||
Client client = this.clientRepo.findById(id).get();
|
||||
System.out.println(client.getDescription());
|
||||
model.put("client", client);
|
||||
return "clients/restaurantShow";
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.springframework.cheapy.model.FoodOffer;
|
|||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.FoodOfferService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -24,10 +26,11 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class FoodOfferController {
|
||||
|
||||
private static final String VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM = "offers/food/createOrUpdateFoodOfferForm";
|
||||
private static final String VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM = "offers/food/createOrUpdateFoodOfferForm";
|
||||
|
||||
private final FoodOfferService foodOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
private final FoodOfferService foodOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
public FoodOfferController(final FoodOfferService foodOfferService, final ClientService clientService) {
|
||||
this.foodOfferService = foodOfferService;
|
||||
|
@ -47,24 +50,25 @@ public class FoodOfferController {
|
|||
|
||||
private boolean checkOffer(final FoodOffer session, final FoodOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus() && (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !session.getStatus().equals(StatusOffer.inactive)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDates(final FoodOffer foodOffer) {
|
||||
boolean res = false;
|
||||
if(foodOffer.getEnd()==null || foodOffer.getStart()==null || foodOffer.getEnd().isAfter(foodOffer.getStart())) {
|
||||
if (foodOffer.getEnd() == null || foodOffer.getStart() == null || foodOffer.getEnd().isAfter(foodOffer.getStart())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/foodOfferList")
|
||||
public String processFindForm(Map<String, Object> model) {
|
||||
List<FoodOffer> foodOfferLs=this.foodOfferService.findActiveFoodOffer();
|
||||
|
||||
@GetMapping("/offers/foodOfferList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 5);
|
||||
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findActiveFoodOffer(elements);
|
||||
model.put("foodOfferLs", foodOfferLs);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersList";
|
||||
|
@ -72,32 +76,32 @@ public class FoodOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/food/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
FoodOffer foodOffer = new FoodOffer();
|
||||
model.put("foodOffer", foodOffer);
|
||||
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/food/new")
|
||||
public String processCreationForm(@Valid FoodOffer foodOffer, BindingResult result) {
|
||||
|
||||
if(!this.checkDates(foodOffer)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
foodOffer.setClient(client);
|
||||
foodOffer.setStatus(StatusOffer.hidden);
|
||||
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||
return "redirect:/offers/food/" + foodOffer.getId();
|
||||
|
||||
public String processCreationForm(@Valid final FoodOffer foodOffer, final BindingResult result) {
|
||||
|
||||
if (!this.checkDates(foodOffer)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
foodOffer.setClient(client);
|
||||
foodOffer.setStatus(StatusOffer.hidden);
|
||||
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||
return "redirect:/offers/food/" + foodOffer.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/activate")
|
||||
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, ModelMap modelMap) {
|
||||
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap modelMap) {
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if (foodOffer.getClient().equals(client)) {
|
||||
|
@ -112,26 +116,25 @@ public class FoodOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/food/{foodOfferId}")
|
||||
public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("foodOfferId") final int foodOfferId, final Map<String, Object> model) {
|
||||
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
if(foodOffer.getStatus().equals(StatusOffer.active)) {
|
||||
if (foodOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("foodOffer", foodOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersShow";
|
||||
|
||||
}else if(foodOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(foodOfferId))) {
|
||||
model.put("foodOffer", foodOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersShow";
|
||||
}else {
|
||||
|
||||
} else if (foodOffer.getStatus().equals(StatusOffer.hidden) && this.checkIdentity(foodOfferId)) {
|
||||
model.put("foodOffer", foodOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersShow";
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
|
@ -146,8 +149,7 @@ public class FoodOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferEdit.getId())) {
|
||||
return "error";
|
||||
|
@ -157,22 +159,21 @@ public class FoodOfferController {
|
|||
if (!this.checkOffer(foodOffer, foodOfferEdit)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
if(!this.checkDates(foodOfferEdit)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("foodOffer", foodOfferEdit);
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.foodOfferService.findFoodOfferById(foodOfferEdit.getId()), foodOfferEdit,
|
||||
"start", "end", "food", "discount");
|
||||
this.foodOfferService.saveFoodOffer(foodOfferEdit);
|
||||
return "redirect:/offers/food/" + foodOfferEdit.getId();
|
||||
|
||||
if (!this.checkDates(foodOfferEdit)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("foodOffer", foodOfferEdit);
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.foodOfferService.findFoodOfferById(foodOfferEdit.getId()), foodOfferEdit, "start", "end", "food", "discount");
|
||||
this.foodOfferService.saveFoodOffer(foodOfferEdit);
|
||||
return "redirect:/offers/food/" + foodOfferEdit.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/disable")
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.security.Principal;
|
||||
|
@ -15,7 +16,8 @@ import org.springframework.cheapy.model.NuOffer;
|
|||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.NuOfferService;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -27,16 +29,17 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
@Controller
|
||||
public class NuOfferController {
|
||||
|
||||
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "offers/nu/createOrUpdateNuOfferForm";
|
||||
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "offers/nu/createOrUpdateNuOfferForm";
|
||||
|
||||
private final NuOfferService nuOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
private final NuOfferService nuOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
public NuOfferController(final NuOfferService nuOfferService, final ClientService clientService) {
|
||||
this.nuOfferService = nuOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkIdentity(final int nuOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
@ -50,43 +53,44 @@ public class NuOfferController {
|
|||
|
||||
private boolean checkOffer(final NuOffer session, final NuOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus() && (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !session.getStatus().equals(StatusOffer.inactive)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDates(final NuOffer nuOffer) {
|
||||
boolean res = false;
|
||||
if(nuOffer.getEnd()==null || nuOffer.getStart()==null || nuOffer.getEnd().isAfter(nuOffer.getStart())) {
|
||||
if (nuOffer.getEnd() == null || nuOffer.getStart() == null || nuOffer.getEnd().isAfter(nuOffer.getStart())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkConditions(final NuOffer nuOffer) {
|
||||
boolean res = false;
|
||||
if(nuOffer.getGold()==null || nuOffer.getSilver()==null || nuOffer.getBronze()==null) {
|
||||
|
||||
}else if(nuOffer.getGold() >= nuOffer.getSilver() && nuOffer.getSilver() >= nuOffer.getBronze()) {
|
||||
if (nuOffer.getGold() == null || nuOffer.getSilver() == null || nuOffer.getBronze() == null) {
|
||||
|
||||
} else if (nuOffer.getGold() >= nuOffer.getSilver() && nuOffer.getSilver() >= nuOffer.getBronze()) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDiscounts(final NuOffer NuOffer) {
|
||||
boolean res = false;
|
||||
if(NuOffer.getDiscountGold()==null || NuOffer.getDiscountSilver()==null || NuOffer.getDiscountBronze()==null) {
|
||||
}else if(NuOffer.getDiscountGold() >= NuOffer.getDiscountSilver() && NuOffer.getDiscountSilver() >= NuOffer.getDiscountBronze()) {
|
||||
if (NuOffer.getDiscountGold() == null || NuOffer.getDiscountSilver() == null || NuOffer.getDiscountBronze() == null) {
|
||||
} else if (NuOffer.getDiscountGold() >= NuOffer.getDiscountSilver() && NuOffer.getDiscountSilver() >= NuOffer.getDiscountBronze()) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/nuOfferList")
|
||||
public String processFindForm(Map<String, Object> model) {
|
||||
List<NuOffer> foodOfferLs=this.nuOfferService.findActiveNuOffer();
|
||||
|
||||
@GetMapping("/offers/nuOfferList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 5);
|
||||
|
||||
List<NuOffer> foodOfferLs = this.nuOfferService.findActiveNuOffer(elements);
|
||||
model.put("nuOfferLs", foodOfferLs);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersList";
|
||||
|
@ -94,48 +98,40 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/nu/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
NuOffer nuOffer = new NuOffer();
|
||||
model.put("nuOffer", nuOffer);
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/nu/new")
|
||||
public String processCreationForm(@RequestParam(value="start") String x,@Valid NuOffer nuOffer,BindingResult result) {
|
||||
|
||||
System.out.println(x);
|
||||
LocalDateTime y= LocalDateTime.parse(x);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
|
||||
String formatDateTime = y.format(formatter);
|
||||
System.out.println(formatDateTime);
|
||||
LocalDateTime start2=LocalDateTime.parse(formatDateTime,formatter);
|
||||
nuOffer.setStart(start2);
|
||||
if(!this.checkDates(nuOffer)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkConditions(nuOffer)) {
|
||||
result.rejectValue("gold","" ,"Oro debe ser mayor o igual que plata, y plata mayor o igual que bronce");
|
||||
|
||||
}
|
||||
if(!this.checkDiscounts(nuOffer)) {
|
||||
result.rejectValue("discountGold","" ,"El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
System.out.println(result.getAllErrors());
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
nuOffer.setStatus(StatusOffer.hidden);
|
||||
public String processCreationForm(@Valid final NuOffer nuOffer, final BindingResult result) {
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if (!this.checkDates(nuOffer)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
nuOffer.setClient(client);
|
||||
}
|
||||
if (!this.checkConditions(nuOffer)) {
|
||||
result.rejectValue("gold", "", "Oro debe ser mayor o igual que plata, y plata mayor o igual que bronce");
|
||||
|
||||
}
|
||||
if (!this.checkDiscounts(nuOffer)) {
|
||||
result.rejectValue("discountGold", "", "El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
nuOffer.setStatus(StatusOffer.hidden);
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
||||
nuOffer.setClient(client);
|
||||
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
return "redirect:/offers/nu/" + nuOffer.getId();
|
||||
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
return "redirect:/offers/nu/" + nuOffer.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/activate")
|
||||
|
@ -155,26 +151,25 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/nu/{nuOfferId}")
|
||||
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("nuOfferId") final int nuOfferId, final Map<String, Object> model) {
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
if(nuOffer.getStatus().equals(StatusOffer.active)) {
|
||||
if (nuOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("nuOffer", nuOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
}else if(nuOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(nuOfferId))) {
|
||||
model.put("nuOffer", nuOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
|
||||
}else {
|
||||
} else if (nuOffer.getStatus().equals(StatusOffer.hidden) && this.checkIdentity(nuOfferId)) {
|
||||
model.put("nuOffer", nuOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
|
@ -189,8 +184,7 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferEdit.getId())) {
|
||||
return "error";
|
||||
|
@ -201,35 +195,32 @@ public class NuOfferController {
|
|||
return "error";
|
||||
}
|
||||
|
||||
if(!this.checkDates(nuOfferEdit)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkConditions(nuOfferEdit)) {
|
||||
result.rejectValue("gold","" ,"Oro debe ser mayor o igual que plata, y plata mayor o igual que bronce");
|
||||
|
||||
}
|
||||
if(!this.checkDiscounts(nuOfferEdit)) {
|
||||
result.rejectValue("discountGold","" ,"El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (!this.checkDates(nuOfferEdit)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("nuOffer", nuOfferEdit);
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
if (!this.checkConditions(nuOfferEdit)) {
|
||||
result.rejectValue("gold", "", "Oro debe ser mayor o igual que plata, y plata mayor o igual que bronce");
|
||||
|
||||
}
|
||||
if (!this.checkDiscounts(nuOfferEdit)) {
|
||||
result.rejectValue("discountGold", "", "El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("nuOffer", nuOfferEdit);
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.nuOfferService.findNuOfferById(nuOfferEdit.getId()), nuOfferEdit, "start", "end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
this.nuOfferService.saveNuOffer(nuOfferEdit);
|
||||
return "redirect:/offers/nu/" + nuOfferEdit.getId();
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.nuOfferService.findNuOfferById(nuOfferEdit.getId()), nuOfferEdit, "start",
|
||||
"end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
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) {
|
||||
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
|
@ -241,8 +232,7 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
|
||||
final ModelMap model) {
|
||||
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
|
|
|
@ -43,9 +43,9 @@ public class OfertaController {
|
|||
Pageable elements = PageRequest.of(0, 3);
|
||||
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findActiveFoodOffer(elements);
|
||||
List<NuOffer> nuOfferLs = this.nuOfferService.findActiveNuOffer();
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findActiveSpeedOffer();
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findActiveTimeOffer();
|
||||
List<NuOffer> nuOfferLs = this.nuOfferService.findActiveNuOffer(elements);
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findActiveSpeedOffer(elements);
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findActiveTimeOffer(elements);
|
||||
|
||||
model.put("foodOfferLs", foodOfferLs);
|
||||
model.put("nuOfferLs", nuOfferLs);
|
||||
|
@ -58,6 +58,44 @@ public class OfertaController {
|
|||
return "offers/offersList";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/offersByName")
|
||||
public String processFindFormByName(final Map<String, Object> model, String name) {
|
||||
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findFoodOfferByClientName(name);
|
||||
List<NuOffer> nuOfferLs = this.nuOfferService.findNuOfferByClientName(name);
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findSpeedOfferByClientName(name);
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findTimeOfferByClientName(name);
|
||||
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/offersListSearch";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/offersByFood")
|
||||
public String processFindFormByFood(final Map<String, Object> model, String name) {
|
||||
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findFoodOfferByClientFood(name);
|
||||
List<NuOffer> nuOfferLs = this.nuOfferService.findNuOfferByClientFood(name);
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findSpeedOfferByClientFood(name);
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findTimeOfferByClientFood(name);
|
||||
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/offersListSearch";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/myOffers")
|
||||
public String processMyOffersForm(final Map<String, Object> model) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -9,6 +10,8 @@ import org.springframework.cheapy.model.Review;
|
|||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.service.ReviewService;
|
||||
import org.springframework.cheapy.service.UserService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -19,10 +22,10 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class ReviewController {
|
||||
|
||||
private static final String VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM = "reviews/createOrUpdateReviewForm";
|
||||
private final ReviewService reviewService;
|
||||
private final UserService userService;
|
||||
|
||||
private static final String VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM = "reviews/createOrUpdateReviewForm";
|
||||
private final ReviewService reviewService;
|
||||
private final UserService userService;
|
||||
|
||||
public ReviewController(final ReviewService reviewService, final UserService userService) {
|
||||
this.reviewService = reviewService;
|
||||
|
@ -38,46 +41,44 @@ public class ReviewController {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
@GetMapping("/reviews")
|
||||
public String processFindForm( Map<String, Object> model) {
|
||||
@GetMapping("/reviewsList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 6);
|
||||
|
||||
List<Review> reviewsLs=this.reviewService.findAllReviews();
|
||||
List<Review> reviewsLs = this.reviewService.findAllReviews(elements);
|
||||
model.put("reviewsLs", reviewsLs);
|
||||
|
||||
|
||||
return "reviews/reviewsList";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/reviews/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
Review review = new Review();
|
||||
model.put("review", review);
|
||||
return VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
return ReviewController.VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/reviews/new")
|
||||
public String processCreationForm(@Valid Review review, BindingResult result) {
|
||||
public String processCreationForm(@Valid final Review review, final BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
return ReviewController.VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
} else {
|
||||
User escritor = this.userService.getCurrentUser();
|
||||
review.setEscritor(escritor);
|
||||
|
||||
|
||||
this.reviewService.saveReview(review);
|
||||
return "redirect:/reviews/" + review.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/reviews/{reviewId}")
|
||||
public String processShowForm(@PathVariable("reviewId") int reviewId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("reviewId") final int reviewId, final Map<String, Object> model) {
|
||||
|
||||
Review review = this.reviewService.findReviewById(reviewId);
|
||||
|
||||
model.put("review", review);
|
||||
|
||||
|
||||
|
||||
return "reviews/reviewsShow";
|
||||
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ public class ReviewController {
|
|||
} else {
|
||||
User escritor = this.userService.getCurrentUser();
|
||||
reviewEdit.setEscritor(escritor);
|
||||
|
||||
|
||||
this.reviewService.saveReview(reviewEdit);
|
||||
return "redirect:/reviews/" + reviewEdit.getId();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -13,6 +14,8 @@ import org.springframework.cheapy.model.SpeedOffer;
|
|||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.SpeedOfferService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -23,10 +26,11 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class SpeedOfferController {
|
||||
|
||||
private static final String VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM = "offers/speed/createOrUpdateSpeedOfferForm";
|
||||
private static final String VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM = "offers/speed/createOrUpdateSpeedOfferForm";
|
||||
|
||||
private final SpeedOfferService speedOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
private final SpeedOfferService speedOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
public SpeedOfferController(final SpeedOfferService speedOfferService, final ClientService clientService) {
|
||||
this.speedOfferService = speedOfferService;
|
||||
|
@ -46,43 +50,44 @@ public class SpeedOfferController {
|
|||
|
||||
private boolean checkOffer(final SpeedOffer session, final SpeedOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus() && (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !session.getStatus().equals(StatusOffer.inactive)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDates(final SpeedOffer speedOffer) {
|
||||
boolean res = false;
|
||||
if(speedOffer.getEnd()==null || speedOffer.getStart()==null || speedOffer.getEnd().isAfter(speedOffer.getStart())) {
|
||||
if (speedOffer.getEnd() == null || speedOffer.getStart() == null || speedOffer.getEnd().isAfter(speedOffer.getStart())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkConditions(final SpeedOffer speedOffer) {
|
||||
boolean res = false;
|
||||
if(speedOffer.getGold()==null || speedOffer.getSilver()==null || speedOffer.getBronze()==null) {
|
||||
|
||||
}else if(speedOffer.getGold() <= speedOffer.getSilver() && speedOffer.getSilver() <= speedOffer.getBronze()) {
|
||||
if (speedOffer.getGold() == null || speedOffer.getSilver() == null || speedOffer.getBronze() == null) {
|
||||
|
||||
} else if (speedOffer.getGold() <= speedOffer.getSilver() && speedOffer.getSilver() <= speedOffer.getBronze()) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDiscounts(final SpeedOffer speedOffer) {
|
||||
boolean res = false;
|
||||
if(speedOffer.getDiscountGold()==null || speedOffer.getDiscountSilver()==null || speedOffer.getDiscountBronze()==null) {
|
||||
}else if(speedOffer.getDiscountGold() >= speedOffer.getDiscountSilver() && speedOffer.getDiscountSilver() >= speedOffer.getDiscountBronze()) {
|
||||
if (speedOffer.getDiscountGold() == null || speedOffer.getDiscountSilver() == null || speedOffer.getDiscountBronze() == null) {
|
||||
} else if (speedOffer.getDiscountGold() >= speedOffer.getDiscountSilver() && speedOffer.getDiscountSilver() >= speedOffer.getDiscountBronze()) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/speedOfferList")
|
||||
public String processFindForm(Map<String, Object> model) {
|
||||
List<SpeedOffer> speedOfferLs=this.speedOfferService.findActiveSpeedOffer();
|
||||
|
||||
@GetMapping("/offers/speedOfferList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 5);
|
||||
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findActiveSpeedOffer(elements);
|
||||
model.put("speedOfferLs", speedOfferLs);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersList";
|
||||
|
@ -90,42 +95,42 @@ public class SpeedOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/speed/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
SpeedOffer speedOffer = new SpeedOffer();
|
||||
model.put("speedOffer", speedOffer);
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/speed/new")
|
||||
public String processCreationForm(@Valid SpeedOffer speedOffer, BindingResult result) {
|
||||
|
||||
if(!this.checkDates(speedOffer)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkConditions(speedOffer)) {
|
||||
result.rejectValue("gold","" ,"Oro debe ser menor o igual que plata, y plata menor o igual que bronce");
|
||||
|
||||
}
|
||||
if(!this.checkDiscounts(speedOffer)) {
|
||||
result.rejectValue("discountGold","" ,"El descuento de Oro debe ser menor o igual que el de plata, y el de plata menor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
speedOffer.setClient(client);
|
||||
speedOffer.setStatus(StatusOffer.hidden);
|
||||
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||
return "redirect:/offers/speed/" + speedOffer.getId();
|
||||
|
||||
public String processCreationForm(@Valid final SpeedOffer speedOffer, final BindingResult result) {
|
||||
|
||||
if (!this.checkDates(speedOffer)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if (!this.checkConditions(speedOffer)) {
|
||||
result.rejectValue("gold", "", "Oro debe ser menor o igual que plata, y plata menor o igual que bronce");
|
||||
|
||||
}
|
||||
if (!this.checkDiscounts(speedOffer)) {
|
||||
result.rejectValue("discountGold", "", "El descuento de Oro debe ser menor o igual que el de plata, y el de plata menor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
speedOffer.setClient(client);
|
||||
speedOffer.setStatus(StatusOffer.hidden);
|
||||
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||
return "redirect:/offers/speed/" + speedOffer.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/activate")
|
||||
public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, ModelMap modelMap) {
|
||||
public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap modelMap) {
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if (speedOffer.getClient().equals(client)) {
|
||||
|
@ -139,24 +144,24 @@ public class SpeedOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/speed/{speedOfferId}")
|
||||
public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("speedOfferId") final int speedOfferId, final Map<String, Object> model) {
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
if(speedOffer.getStatus().equals(StatusOffer.active)) {
|
||||
if (speedOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("speedOffer", speedOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
}else if(speedOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(speedOfferId))) {
|
||||
model.put("speedOffer", speedOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
|
||||
}else {
|
||||
} else if (speedOffer.getStatus().equals(StatusOffer.hidden) && this.checkIdentity(speedOfferId)) {
|
||||
model.put("speedOffer", speedOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model, HttpServletRequest request) {
|
||||
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
|
@ -172,8 +177,7 @@ public class SpeedOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferEdit.getId())) {
|
||||
return "error";
|
||||
|
@ -184,29 +188,27 @@ public class SpeedOfferController {
|
|||
return "error";
|
||||
}
|
||||
|
||||
if(!this.checkDates(speedOfferEdit)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkConditions(speedOfferEdit)) {
|
||||
result.rejectValue("gold","" ,"Oro debe ser menor o igual que plata, y plata menor o igual que bronce");
|
||||
|
||||
}
|
||||
if(!this.checkDiscounts(speedOfferEdit)) {
|
||||
result.rejectValue("discountGold","" ,"El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("speedOffer", speedOfferEdit);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
if (!this.checkDates(speedOfferEdit)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.speedOfferService.findSpeedOfferById(speedOfferEdit.getId()), speedOfferEdit,
|
||||
"start", "end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
|
||||
return "redirect:/offers/speed/" + speedOfferEdit.getId();
|
||||
|
||||
}
|
||||
if (!this.checkConditions(speedOfferEdit)) {
|
||||
result.rejectValue("gold", "", "Oro debe ser menor o igual que plata, y plata menor o igual que bronce");
|
||||
|
||||
}
|
||||
if (!this.checkDiscounts(speedOfferEdit)) {
|
||||
result.rejectValue("discountGold", "", "El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("speedOffer", speedOfferEdit);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.speedOfferService.findSpeedOfferById(speedOfferEdit.getId()), speedOfferEdit, "start", "end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
|
||||
return "redirect:/offers/speed/" + speedOfferEdit.getId();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -13,6 +14,8 @@ 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.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -23,11 +26,12 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class TimeOfferController {
|
||||
|
||||
private static final String VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM = "offers/time/createOrUpdateTimeOfferForm";
|
||||
private final TimeOfferService timeOfferService;
|
||||
private final ClientService clientService;
|
||||
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, final ClientService clientService) {
|
||||
this.timeOfferService = timeOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
@ -45,32 +49,33 @@ public class TimeOfferController {
|
|||
|
||||
private boolean checkOffer(final TimeOffer session, final TimeOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus() && (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !session.getStatus().equals(StatusOffer.inactive)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDates(final TimeOffer timeOffer) {
|
||||
boolean res = false;
|
||||
if(timeOffer.getEnd()==null || timeOffer.getStart()==null || timeOffer.getEnd().isAfter(timeOffer.getStart())) {
|
||||
if (timeOffer.getEnd() == null || timeOffer.getStart() == null || timeOffer.getEnd().isAfter(timeOffer.getStart())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkTimes(final TimeOffer timeOffer) {
|
||||
boolean res = false;
|
||||
if(timeOffer.getFinish()==null || timeOffer.getInit()==null || timeOffer.getFinish().isAfter(timeOffer.getInit())) {
|
||||
if (timeOffer.getFinish() == null || timeOffer.getInit() == null || timeOffer.getFinish().isAfter(timeOffer.getInit())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/timeOfferList")
|
||||
public String processFindForm(Map<String, Object> model) {
|
||||
List<TimeOffer> timeOfferLs=this.timeOfferService.findActiveTimeOffer();
|
||||
|
||||
@GetMapping("/offers/timeOfferList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 5);
|
||||
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findActiveTimeOffer(elements);
|
||||
model.put("timeOfferLs", timeOfferLs);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersList";
|
||||
|
@ -78,38 +83,38 @@ public class TimeOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/time/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
TimeOffer timeOffer = new TimeOffer();
|
||||
model.put("timeOffer", timeOffer);
|
||||
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/time/new")
|
||||
public String processCreationForm(@Valid TimeOffer timeOffer, BindingResult result) {
|
||||
|
||||
if(!this.checkDates(timeOffer)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
|
||||
if(!this.checkTimes(timeOffer)) {
|
||||
result.rejectValue("finish","" ,"La hora de fin debe ser posterior a la de inicio");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
timeOffer.setStatus(StatusOffer.hidden);
|
||||
public String processCreationForm(@Valid final TimeOffer timeOffer, final BindingResult result) {
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if (!this.checkDates(timeOffer)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
timeOffer.setClient(client);
|
||||
}
|
||||
|
||||
if (!this.checkTimes(timeOffer)) {
|
||||
result.rejectValue("finish", "", "La hora de fin debe ser posterior a la de inicio");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
timeOffer.setStatus(StatusOffer.hidden);
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
||||
timeOffer.setClient(client);
|
||||
|
||||
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||
return "redirect:/offers/time/" + timeOffer.getId();
|
||||
|
||||
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||
return "redirect:/offers/time/" + timeOffer.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/activate")
|
||||
|
@ -129,26 +134,25 @@ public class TimeOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/time/{timeOfferId}")
|
||||
public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("timeOfferId") final int timeOfferId, final Map<String, Object> model) {
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
if(timeOffer.getStatus().equals(StatusOffer.active)) {
|
||||
if (timeOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("timeOffer", timeOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersShow";
|
||||
|
||||
} else if(timeOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(timeOfferId))) {
|
||||
model.put("timeOffer", timeOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersShow";
|
||||
|
||||
}else {
|
||||
|
||||
} else if (timeOffer.getStatus().equals(StatusOffer.hidden) && this.checkIdentity(timeOfferId)) {
|
||||
model.put("timeOffer", timeOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersShow";
|
||||
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
|
@ -164,8 +168,7 @@ public class TimeOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferEdit.getId())) {
|
||||
return "error";
|
||||
|
@ -176,26 +179,23 @@ public class TimeOfferController {
|
|||
return "error";
|
||||
}
|
||||
|
||||
|
||||
if(!this.checkDates(timeOfferEdit)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkTimes(timeOfferEdit)) {
|
||||
result.rejectValue("finish","" ,"La hora de fin debe ser posterior a la de inicio");
|
||||
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("timeOffer", timeOfferEdit);
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
if (!this.checkDates(timeOfferEdit)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(this.timeOfferService.findTimeOfferById(timeOfferEdit.getId()), timeOfferEdit,
|
||||
"start", "end", "init", "finish", "discount");
|
||||
this.timeOfferService.saveTimeOffer(timeOfferEdit);
|
||||
return "redirect:/offers/time/" + timeOfferEdit.getId();
|
||||
|
||||
}
|
||||
if (!this.checkTimes(timeOfferEdit)) {
|
||||
result.rejectValue("finish", "", "La hora de fin debe ser posterior a la de inicio");
|
||||
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("timeOffer", timeOfferEdit);
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(this.timeOfferService.findTimeOfferById(timeOfferEdit.getId()), timeOfferEdit, "start", "end", "init", "finish", "discount");
|
||||
this.timeOfferService.saveTimeOffer(timeOfferEdit);
|
||||
return "redirect:/offers/time/" + timeOfferEdit.getId();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cheapy.model.Municipio;
|
||||
import org.springframework.cheapy.model.Usuario;
|
||||
import org.springframework.cheapy.service.UsuarioService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
@ -37,15 +38,21 @@ public class UsuarioController {
|
|||
public String updateUsuario(final ModelMap model, HttpServletRequest request) {
|
||||
Usuario usuario = this.usuarioService.getCurrentUsuario();
|
||||
model.addAttribute("usuario", usuario);
|
||||
model.put("municipio", Municipio.values());
|
||||
return UsuarioController.VIEWS_USUARIO_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/usuarios/edit")
|
||||
public String updateUsuario(@Valid final Usuario usuarioEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("usuario", usuarioEdit);
|
||||
model.put("municipio", Municipio.values());
|
||||
return UsuarioController.VIEWS_USUARIO_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
Usuario usuario = this.usuarioService.getCurrentUsuario();
|
||||
BeanUtils.copyProperties(usuario, usuarioEdit, "nombre", "apellidos", "dni", "direccion", "telefono", "usuar");
|
||||
BeanUtils.copyProperties(usuario, usuarioEdit, "nombre", "apellidos", "municipio", "direccion","email", "usuar");
|
||||
usuarioEdit.getUsuar().setUsername(usuario.getNombre());
|
||||
usuarioEdit.getUsuar().setEnabled(true);
|
||||
this.usuarioService.saveUsuario(usuarioEdit);
|
||||
|
|
|
@ -1,26 +1,32 @@
|
|||
INSERT INTO users (username,password,enabled) VALUES ('admin','admin', TRUE );
|
||||
INSERT INTO authorities VALUES ('admin','admin');
|
||||
INSERT INTO authorities (username,authority) VALUES ('admin','admin');
|
||||
|
||||
INSERT INTO users (username,password,enabled) VALUES ('manoli','manoli', TRUE );
|
||||
INSERT INTO authorities VALUES ('manoli','client');
|
||||
INSERT INTO authorities (username,authority) VALUES ('manoli','client');
|
||||
INSERT INTO users (username,password,enabled) VALUES ('david','david', TRUE );
|
||||
INSERT INTO authorities VALUES ('david','client');
|
||||
INSERT INTO authorities (username,authority) VALUES ('david','client');
|
||||
|
||||
INSERT INTO users (username,password,enabled) VALUES ('paco','paco', TRUE );
|
||||
INSERT INTO authorities VALUES ('paco','usuario');
|
||||
INSERT INTO authorities (username,authority) VALUES ('paco','usuario');
|
||||
INSERT INTO users (username,password,enabled) VALUES ('lolo','lolo', TRUE );
|
||||
INSERT INTO authorities VALUES ('lolo','usuario');
|
||||
INSERT INTO authorities (username,authority) VALUES ('lolo','usuario');
|
||||
INSERT INTO users (username,password,enabled) VALUES ('pepe','pepe', TRUE );
|
||||
INSERT INTO authorities VALUES ('pepe','usuario');
|
||||
INSERT INTO authorities (username,authority) VALUES ('pepe','usuario');
|
||||
|
||||
INSERT INTO administrators (id, username) VALUES (1, 'admin');
|
||||
|
||||
INSERT INTO usuarios (id, nombre, apellidos, dni, direccion, telefono, email, username) VALUES (2, 'Paco', 'Naranjo', '21154416G', 'C/Esperanza', '666973647', 'Paco@gmail.com','paco');
|
||||
INSERT INTO usuarios (id, nombre, apellidos, dni, direccion, telefono, email, username) VALUES (3, 'Lolo', 'Lopez', '25486596L', 'C/Macarena', '690670547' ,'Lolo@gmail.com','lolo');
|
||||
INSERT INTO usuarios (id, nombre, apellidos, dni, direccion, telefono, email, username) VALUES (4, 'Pepe', 'Lopez', '12456776V', 'C/Macarena', '690670547', 'Pepe@gmail.com','pepe');
|
||||
INSERT INTO usuarios (id, nombre, apellidos, direccion, municipio, email, username) VALUES (1, 'admin', 'admin', 'C/admin', 'carmona', 'admin@gmail.com','admin');
|
||||
INSERT INTO usuarios (id, nombre, apellidos, direccion, municipio, email, username) VALUES (2, 'Paco', 'Naranjo', 'C/Esperanza', 'sevilla', 'Paco@gmail.com','paco');
|
||||
INSERT INTO usuarios (id, nombre, apellidos, direccion, municipio, email, username) VALUES (3, 'Lolo', 'Lopez', 'C/Macarena', 'dos_hermanas', 'Lolo@gmail.com','lolo');
|
||||
INSERT INTO usuarios (id, nombre, apellidos, direccion, municipio, email, username) VALUES (4, 'Pepe', 'Lopez', 'C/Macarena', 'carmona', 'Pepe@gmail.com','pepe');
|
||||
|
||||
INSERT INTO codes (id,code,activo) VALUES (1,'code1',FALSE);
|
||||
INSERT INTO codes (id,code,activo) VALUES (2,'code2',FALSE);
|
||||
INSERT INTO codes (id,code,activo) VALUES (3,'code3',TRUE);
|
||||
INSERT INTO codes (id,code,activo) VALUES (4,'code4',TRUE);
|
||||
|
||||
INSERT INTO clients (id, name, email, address, municipio, init, finish, telephone, description, food, username, code) VALUES (1,'bar manoli','manoli@gmail.com','C/Betis', 'sevilla','10:00','22:00','608726190', 'description 1', 'ESPAÑOLA','manoli', 'code1');
|
||||
INSERT INTO clients (id, name, email, address, municipio, init, finish, telephone, description, food, username, code) VALUES (2,'bar david','david@gmail.com','C/Sevilla', 'dos_hermanas','09:30','22:00','608726190', 'description 2', 'americana','david', 'code2');
|
||||
|
||||
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:00','22:00: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:00','22:00:00','608726190', 'description 2', 'code2', 'americana','david');
|
||||
|
||||
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-08-14 12:00:00', '2021-08-15 12:00:00', 'FO-1', 'inactive', 1, 'macarrones', 15);
|
||||
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-08-15 12:00:00', '2021-08-16 12:00:00', 'FO-2', 'active', 1, 'macarrones con tomate', 10);
|
||||
|
|
25
src/main/webapp/WEB-INF/jsp/clients/clientActivate.jsp
Normal file
25
src/main/webapp/WEB-INF/jsp/clients/clientActivate.jsp
Normal file
|
@ -0,0 +1,25 @@
|
|||
<%@ 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="cheapy" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<cheapy:layout pageName="client">
|
||||
|
||||
<jsp:body>
|
||||
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>¿Está seguro de que quiere activar esta cuenta?</em></h2>
|
||||
|
||||
<form:form modelAttribute="client" class="form-horizontal">
|
||||
|
||||
<div class="btns-edit2">
|
||||
<button type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Activar</button>
|
||||
</div>
|
||||
</form:form>
|
||||
|
||||
</jsp:body>
|
||||
|
||||
</cheapy:layout>
|
|
@ -35,6 +35,10 @@
|
|||
<tr>
|
||||
<th><fmt:message key="addressClient"/></th>
|
||||
<td><c:out value="${client.address}"/> </td>
|
||||
</tr><tr>
|
||||
<tr>
|
||||
<th><fmt:message key="municipioClient"/></th>
|
||||
<td><c:out value="${client.municipio}"/> </td>
|
||||
</tr><tr>
|
||||
<th><fmt:message key="telephone"/></th>
|
||||
<td><c:out value="${client.telephone}"/> </td>
|
||||
|
@ -73,12 +77,23 @@
|
|||
<sec:authentication var="principal" property="principal" />
|
||||
<div class="btns-edit">
|
||||
|
||||
<c:if test="${ client.usuar.enabled eq true}">
|
||||
<spring:url value="/administrators/clients/{username}/disable" var="deactivateUrl">
|
||||
<spring:param name="username" value="${client.usuar.username}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(deactivateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Desactivar cliente</button>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${ client.usuar.enabled eq false}">
|
||||
<spring:url value="/administrators/clients/{username}/activate" var="activateUrl">
|
||||
<spring:param name="username" value="${client.usuar.username}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(activateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Activar cliente</button>
|
||||
</c:if>
|
||||
</div>
|
||||
</sec:authorize>
|
||||
</div>
|
||||
|
|
|
@ -14,16 +14,21 @@
|
|||
|
||||
<form:form modelAttribute="client" class="form-horizontal" id="add-client-form">
|
||||
<div class="form-group has-feedback">
|
||||
|
||||
<form:hidden path="code"/>
|
||||
<cheapy:passwordField label="Contraseña" placeholder="Restaurante pepito" name="usuar.password"/>
|
||||
|
||||
|
||||
|
||||
<cheapy:passwordField label="Contraseña" placeholder="Restaurante pepito" name="usuar.password"/>
|
||||
<cheapy:inputField label="Hora de inicio" placeholder="HH:mm" name="init"/>
|
||||
<cheapy:inputField label="Hora de fin" placeholder="HH:mm" name="finish"/>
|
||||
<cheapy:inputField label="Name" placeholder="Restaurante pepito" name="name"/>
|
||||
<cheapy:inputField label="Email" placeholder="" name="email"/>
|
||||
<cheapy:inputField label="Dirección" placeholder="" name="address"/>
|
||||
<cheapy:inputField label="Dirección" placeholder="" name="address"/>
|
||||
<div class="form-group">
|
||||
<label>Municipio: </label>
|
||||
<select name="municipio">
|
||||
<c:forEach items="${municipio}" var="entry">
|
||||
<option value="${entry}">${entry}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</div>
|
||||
<cheapy:inputField label="telephone" placeholder="" name="telephone"/>
|
||||
<cheapy:inputField label="description" placeholder="" name="description"/>
|
||||
<cheapy:inputField label="food" placeholder="food" name="food"/>
|
||||
|
@ -31,18 +36,10 @@
|
|||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<div class="btn-mod">
|
||||
<c:choose>
|
||||
<c:when test="${client['new']}">
|
||||
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Crear cliente</button>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
|
||||
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Modificar</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,23 +9,34 @@
|
|||
|
||||
<cheapy:layout pageName="ofertas de plato especifico">
|
||||
|
||||
<spring:url value="/offers/nuOfferList" var="nuOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/nuOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/speedOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl">
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/timeOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
|
||||
|
||||
|
@ -80,6 +91,23 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(foodOfferLs) == 5}">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</c:if>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -9,24 +9,35 @@
|
|||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<spring:url value="/offers/foodOfferList" var="foodOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/foodOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/speedOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl">
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/timeOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="nuOffers"/></h2>
|
||||
<c:if test="${empty nuOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por número de comensales activa.</p>
|
||||
|
@ -77,6 +88,23 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(nuOfferLs) == 5}">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</c:if>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -5,38 +5,55 @@
|
|||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<spring:url value="/offers/foodOfferList" var="foodOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/foodOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/nuOfferList" var="nuOfferUrl">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/nuOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/speedOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl">
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/timeOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<form class="example" action="/offersByName">
|
||||
<input type="text" name="name">
|
||||
<button type="submit"><i class="fa fa-search"></i></button>
|
||||
</form>
|
||||
|
||||
<form class="example" action="/offersByFood">
|
||||
<input type="text" name="name">
|
||||
<button type="submit"><i class="fa fa-search"></i></button>
|
||||
</form>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
|
||||
|
||||
<c:if test="${empty foodOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
|
||||
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty foodOfferLs }">
|
||||
|
||||
|
@ -88,6 +105,9 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ver más</button>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
@ -143,6 +163,9 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ver más</button>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
@ -200,6 +223,10 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl"></spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ver más</button>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
@ -254,9 +281,12 @@
|
|||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl"></spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ver más</button>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
|
||||
|
|
239
src/main/webapp/WEB-INF/jsp/offers/offersListSearch.jsp
Normal file
239
src/main/webapp/WEB-INF/jsp/offers/offersListSearch.jsp
Normal file
|
@ -0,0 +1,239 @@
|
|||
<%@ 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" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
|
||||
|
||||
<c:if test="${empty foodOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty foodOfferLs }">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="foodOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th><fmt:message key="name"/></th>
|
||||
<th><fmt:message key="food"/></th>
|
||||
<th><fmt:message key="discount"/></th>
|
||||
<th><fmt:message key="startDate"/></th>
|
||||
<th><fmt:message key="endDate"/></th>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${foodOfferLs}" var="foodOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/restaurant/${foodOffer.client.id}"><c:out value="${foodOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${foodOffer.food}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${foodOffer.discount}%"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(foodOffer.start)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(foodOffer.end)}"/>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<spring:url value="/offers/food/{foodOfferId}" var="foodOfferUrl">
|
||||
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||
</spring:url>
|
||||
<div class="btn-detalles">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="details"/></button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="nuOffers"/></h2>
|
||||
<c:if test="${empty nuOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por número de comensales activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty nuOfferLs }">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="nuOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th><fmt:message key="name"/></th>
|
||||
<th><fmt:message key="startDate"/></th>
|
||||
<th><fmt:message key="endDate"/></th>
|
||||
<th><fmt:message key="goldGoal"/></th>
|
||||
<th><fmt:message key="goldDiscount"/></th>
|
||||
<th> </th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${nuOfferLs}" var="nuOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/restaurant/${nuOffer.client.id}"><c:out value="${nuOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(nuOffer.start)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(nuOffer.end)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${nuOffer.gold} comensales"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${nuOffer.discountGold}%"/>
|
||||
</td>
|
||||
<td>
|
||||
<spring:url value="/offers/nu/{nuOfferId}" var="nuOfferUrl">
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
</spring:url>
|
||||
<div class="btn-detalles">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="details"/> </button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
|
||||
<c:if test="${empty speedOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por tiempo empleado en comer activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty speedOfferLs }">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="speedOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th><fmt:message key="name"/></th>
|
||||
<th><fmt:message key="startDate"/></th>
|
||||
<th><fmt:message key="endDate"/></th>
|
||||
<th><fmt:message key="goldGoal"/></th>
|
||||
<th><fmt:message key="goldDiscount"/></th>
|
||||
<th> </th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${speedOfferLs}" var="speedOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/restaurant/${speedOffer.client.id}"><c:out value="${speedOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(speedOffer.start)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(speedOffer.end)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${speedOffer.gold} minutos"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${speedOffer.discountGold}%"/>
|
||||
</td>
|
||||
<td>
|
||||
<spring:url value="/offers/speed/{speedOfferId}" var="speedOfferUrl">
|
||||
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||
</spring:url>
|
||||
<div class="btn-detalles">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="details"/> </button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
|
||||
<c:if test="${empty timeOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por franja horaria activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty timeOfferLs }">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="timeOfferTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th><fmt:message key="name"/></th>
|
||||
<th><fmt:message key="startDate"/></th>
|
||||
<th><fmt:message key="endDate"/></th>
|
||||
<th><fmt:message key="init"/></th>
|
||||
<th><fmt:message key="finishOffer"/></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${timeOfferLs}" var="timeOffer">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/restaurant/${timeOffer.client.id}"><c:out value="${timeOffer.client.name}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(timeOffer.start)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${localDateTimeFormat.format(timeOffer.end)}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${timeOffer.init}h"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${timeOffer.finish}h"/>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
|
||||
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||
</spring:url>
|
||||
<div class="btn-detalles">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="details"/> </button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
|
||||
</cheapy:layout>
|
|
@ -9,24 +9,35 @@
|
|||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<spring:url value="/offers/foodOfferList" var="foodOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/foodOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/nuOfferList" var="nuOfferUrl">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/nuOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/timeOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
|
||||
<c:if test="${empty speedOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por tiempo empleado en comer activa.</p>
|
||||
|
@ -78,5 +89,22 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(speedOfferLs) == 5}">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</c:if>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -9,23 +9,34 @@
|
|||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<spring:url value="/offers/foodOfferList" var="foodOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/foodOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/nuOfferList" var="nuOfferUrl">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/nuOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/speedOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
|
||||
<c:if test="${empty timeOfferLs }">
|
||||
|
@ -77,6 +88,23 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(timeOfferLs) == 5}">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</c:if>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<c:choose>
|
||||
<c:when test="${fn:length(reviewsLs) == 0}">
|
||||
<c:when test="${empty reviewsLs}">
|
||||
<tr><td colspan="4"><em><c:out value="No se ha realizado ninguna valoración por el momento."/></em></td></tr>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
|
@ -56,4 +56,21 @@
|
|||
</c:choose>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/reviewsList/{page}" var="reviewsListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(reviewsListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(reviewsLs) == 6}">
|
||||
<spring:url value="/reviewsList/{page}" var="reviewsListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(reviewsListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</cheapy:layout>
|
||||
|
|
317
src/main/webapp/WEB-INF/jsp/singup/singUpClient.jsp
Normal file
317
src/main/webapp/WEB-INF/jsp/singup/singUpClient.jsp
Normal file
|
@ -0,0 +1,317 @@
|
|||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
|
||||
<!-- %@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %-->
|
||||
|
||||
<style>
|
||||
|
||||
|
||||
body {
|
||||
font-family: "montserratregular", sans-serif;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #92badd;
|
||||
display:inline-block;
|
||||
text-decoration: none;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
display:inline-block;
|
||||
margin: 40px 8px 10px 8px;
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* STRUCTURE */
|
||||
|
||||
.wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#formContent {
|
||||
-webkit-border-radius: 10px 10px 10px 10px;
|
||||
border-radius: 10px 10px 10px 10px;
|
||||
background: #fff;
|
||||
padding: 30px;
|
||||
width: 90%;
|
||||
max-width: 450px;
|
||||
position: relative;
|
||||
padding: 0px;
|
||||
-webkit-box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);
|
||||
box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#formFooter {
|
||||
background-color: #f6f6f6;
|
||||
border-top: 1px solid #dce8f1;
|
||||
padding: 25px;
|
||||
text-align: center;
|
||||
-webkit-border-radius: 0 0 10px 10px;
|
||||
border-radius: 0 0 10px 10px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* TABS */
|
||||
|
||||
h2.inactive {
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
h2.active {
|
||||
color: #0d0d0d;
|
||||
border-bottom: 2px solid #5fbae9;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* FORM TYPOGRAPHY*/
|
||||
|
||||
input[type=button], input[type=submit], input[type=reset] {
|
||||
background-color: #56baed;
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 15px 80px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
text-transform: uppercase;
|
||||
font-size: 13px;
|
||||
-webkit-box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4);
|
||||
box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4);
|
||||
-webkit-border-radius: 5px 5px 5px 5px;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
margin: 5px 20px 40px 20px;
|
||||
-webkit-transition: all 0.3s ease-in-out;
|
||||
-moz-transition: all 0.3s ease-in-out;
|
||||
-ms-transition: all 0.3s ease-in-out;
|
||||
-o-transition: all 0.3s ease-in-out;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover {
|
||||
background-color: #39ace7;
|
||||
}
|
||||
|
||||
input[type=button]:active, input[type=submit]:active, input[type=reset]:active {
|
||||
-moz-transform: scale(0.95);
|
||||
-webkit-transform: scale(0.95);
|
||||
-o-transform: scale(0.95);
|
||||
-ms-transform: scale(0.95);
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
input[type=text], input[type=password] {
|
||||
background-color: #f6f6f6;
|
||||
border: none;
|
||||
color: #0d0d0d;
|
||||
padding: 15px 32px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
margin: 5px;
|
||||
width: 85%;
|
||||
border: 2px solid #f6f6f6;
|
||||
-webkit-transition: all 0.5s ease-in-out;
|
||||
-moz-transition: all 0.5s ease-in-out;
|
||||
-ms-transition: all 0.5s ease-in-out;
|
||||
-o-transition: all 0.5s ease-in-out;
|
||||
transition: all 0.5s ease-in-out;
|
||||
-webkit-border-radius: 5px 5px 5px 5px;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
}
|
||||
|
||||
input[type=text]:focus {
|
||||
background-color: #fff;
|
||||
border-bottom: 2px solid #5fbae9;
|
||||
}
|
||||
|
||||
input[type=text]:placeholder {
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ANIMATIONS */
|
||||
|
||||
/* Simple CSS3 Fade-in-down Animation */
|
||||
.fadeInDown {
|
||||
-webkit-animation-name: fadeInDown;
|
||||
animation-name: fadeInDown;
|
||||
-webkit-animation-duration: 1s;
|
||||
animation-duration: 1s;
|
||||
-webkit-animation-fill-mode: both;
|
||||
animation-fill-mode: both;
|
||||
}
|
||||
|
||||
@-webkit-keyframes fadeInDown {
|
||||
0% {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(0, -100%, 0);
|
||||
transform: translate3d(0, -100%, 0);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
-webkit-transform: none;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeInDown {
|
||||
0% {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(0, -100%, 0);
|
||||
transform: translate3d(0, -100%, 0);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
-webkit-transform: none;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Simple CSS3 Fade-in Animation */
|
||||
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
|
||||
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
|
||||
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
|
||||
|
||||
.fadeIn {
|
||||
opacity:0;
|
||||
-webkit-animation:fadeIn ease-in 1;
|
||||
-moz-animation:fadeIn ease-in 1;
|
||||
animation:fadeIn ease-in 1;
|
||||
|
||||
-webkit-animation-fill-mode:forwards;
|
||||
-moz-animation-fill-mode:forwards;
|
||||
animation-fill-mode:forwards;
|
||||
|
||||
-webkit-animation-duration:1s;
|
||||
-moz-animation-duration:1s;
|
||||
animation-duration:1s;
|
||||
}
|
||||
|
||||
.fadeIn.first {
|
||||
-webkit-animation-delay: 0.4s;
|
||||
-moz-animation-delay: 0.4s;
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
.fadeIn.second {
|
||||
-webkit-animation-delay: 0.6s;
|
||||
-moz-animation-delay: 0.6s;
|
||||
animation-delay: 0.6s;
|
||||
}
|
||||
|
||||
.fadeIn.third {
|
||||
-webkit-animation-delay: 0.8s;
|
||||
-moz-animation-delay: 0.8s;
|
||||
animation-delay: 0.8s;
|
||||
}
|
||||
|
||||
.fadeIn.fourth {
|
||||
-webkit-animation-delay: 1s;
|
||||
-moz-animation-delay: 1s;
|
||||
animation-delay: 1s;
|
||||
}
|
||||
|
||||
/* Simple CSS3 Fade-in Animation */
|
||||
.underlineHover:after {
|
||||
display: block;
|
||||
left: 0;
|
||||
bottom: -10px;
|
||||
width: 0;
|
||||
height: 2px;
|
||||
background-color: #56baed;
|
||||
content: "";
|
||||
transition: width 0.2s;
|
||||
}
|
||||
|
||||
.underlineHover:hover {
|
||||
color: #0d0d0d;
|
||||
}
|
||||
|
||||
.underlineHover:hover:after{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* OTHERS */
|
||||
|
||||
*:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#icon {
|
||||
width:60%;
|
||||
}
|
||||
|
||||
</style>
|
||||
<cheapy:layout pageName="singUp">
|
||||
<h2 style="text-align:center;padding:5px">
|
||||
<fmt:message key="new"/><fmt:message key="client"/>
|
||||
</h2>
|
||||
<form:form modelAttribute="cliente" class="form-horizontal"
|
||||
id="add-client-form">
|
||||
<div class="form-group has-feedback">
|
||||
<cheapy:inputField label="Nombre" placeholder="Ponga aqui su nombre"
|
||||
name="name" />
|
||||
<cheapy:inputField label="Direccion" placeholder="Ponga aqui su dirección"
|
||||
name="address" />
|
||||
<div class="form-group">
|
||||
<label>Municipio: </label>
|
||||
<select name="municipio">
|
||||
<c:forEach items="${municipio}" var="entry">
|
||||
<option value="${entry}">${entry}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</div>
|
||||
<cheapy:inputField label="Hora de apertura" placeholder="Ponga aqui su hora de apertura (formato HH:mm)"
|
||||
name="init" />
|
||||
<cheapy:inputField label="Hora de cierre" placeholder="Ponga aqui su hora de cierre (formato HH:mm)"
|
||||
name="finish" />
|
||||
<cheapy:inputField label="Teléfono" placeholder="Ponga aqui el teléfono del local"
|
||||
name="telephone" />
|
||||
<cheapy:inputField label="Descripción" placeholder="Ponga aqui su descripción"
|
||||
name="description" />
|
||||
<cheapy:inputField label="Email" placeholder="Ponga aqui su email"
|
||||
name="email" />
|
||||
<cheapy:inputField label="Tipo de comida" placeholder="Indique que tipo de comida sirve su negocio"
|
||||
name="food" />
|
||||
<cheapy:inputField label="Nombre de usuario" placeholder="Ponga aqui su nombre de usuario"
|
||||
name="usuar.username" />
|
||||
<cheapy:inputField label="Contraseña" placeholder="Ponga aqui su contraseña"
|
||||
name="usuar.password" />
|
||||
<cheapy:inputField label="Código de activación" placeholder="Ponga aqui el código que se le suministro al firmar el contrato"
|
||||
name="code.code" />
|
||||
<input type="submit" class="fadeIn fourth" value="Registrarse">
|
||||
</div>
|
||||
</form:form>
|
||||
|
||||
</cheapy:layout>
|
||||
|
307
src/main/webapp/WEB-INF/jsp/singup/singUpUser.jsp
Normal file
307
src/main/webapp/WEB-INF/jsp/singup/singUpUser.jsp
Normal file
|
@ -0,0 +1,307 @@
|
|||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
|
||||
<!-- %@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %-->
|
||||
|
||||
<style>
|
||||
|
||||
|
||||
body {
|
||||
font-family: "montserratregular", sans-serif;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #92badd;
|
||||
display:inline-block;
|
||||
text-decoration: none;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
display:inline-block;
|
||||
margin: 40px 8px 10px 8px;
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* STRUCTURE */
|
||||
|
||||
.wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#formContent {
|
||||
-webkit-border-radius: 10px 10px 10px 10px;
|
||||
border-radius: 10px 10px 10px 10px;
|
||||
background: #fff;
|
||||
padding: 30px;
|
||||
width: 90%;
|
||||
max-width: 450px;
|
||||
position: relative;
|
||||
padding: 0px;
|
||||
-webkit-box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);
|
||||
box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#formFooter {
|
||||
background-color: #f6f6f6;
|
||||
border-top: 1px solid #dce8f1;
|
||||
padding: 25px;
|
||||
text-align: center;
|
||||
-webkit-border-radius: 0 0 10px 10px;
|
||||
border-radius: 0 0 10px 10px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* TABS */
|
||||
|
||||
h2.inactive {
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
h2.active {
|
||||
color: #0d0d0d;
|
||||
border-bottom: 2px solid #5fbae9;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* FORM TYPOGRAPHY*/
|
||||
|
||||
input[type=button], input[type=submit], input[type=reset] {
|
||||
background-color: #56baed;
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 15px 80px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
text-transform: uppercase;
|
||||
font-size: 13px;
|
||||
-webkit-box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4);
|
||||
box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4);
|
||||
-webkit-border-radius: 5px 5px 5px 5px;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
margin: 5px 20px 40px 20px;
|
||||
-webkit-transition: all 0.3s ease-in-out;
|
||||
-moz-transition: all 0.3s ease-in-out;
|
||||
-ms-transition: all 0.3s ease-in-out;
|
||||
-o-transition: all 0.3s ease-in-out;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover {
|
||||
background-color: #39ace7;
|
||||
}
|
||||
|
||||
input[type=button]:active, input[type=submit]:active, input[type=reset]:active {
|
||||
-moz-transform: scale(0.95);
|
||||
-webkit-transform: scale(0.95);
|
||||
-o-transform: scale(0.95);
|
||||
-ms-transform: scale(0.95);
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
input[type=text], input[type=password] {
|
||||
background-color: #f6f6f6;
|
||||
border: none;
|
||||
color: #0d0d0d;
|
||||
padding: 15px 32px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
margin: 5px;
|
||||
width: 85%;
|
||||
border: 2px solid #f6f6f6;
|
||||
-webkit-transition: all 0.5s ease-in-out;
|
||||
-moz-transition: all 0.5s ease-in-out;
|
||||
-ms-transition: all 0.5s ease-in-out;
|
||||
-o-transition: all 0.5s ease-in-out;
|
||||
transition: all 0.5s ease-in-out;
|
||||
-webkit-border-radius: 5px 5px 5px 5px;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
}
|
||||
|
||||
input[type=text]:focus {
|
||||
background-color: #fff;
|
||||
border-bottom: 2px solid #5fbae9;
|
||||
}
|
||||
|
||||
input[type=text]:placeholder {
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ANIMATIONS */
|
||||
|
||||
/* Simple CSS3 Fade-in-down Animation */
|
||||
.fadeInDown {
|
||||
-webkit-animation-name: fadeInDown;
|
||||
animation-name: fadeInDown;
|
||||
-webkit-animation-duration: 1s;
|
||||
animation-duration: 1s;
|
||||
-webkit-animation-fill-mode: both;
|
||||
animation-fill-mode: both;
|
||||
}
|
||||
|
||||
@-webkit-keyframes fadeInDown {
|
||||
0% {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(0, -100%, 0);
|
||||
transform: translate3d(0, -100%, 0);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
-webkit-transform: none;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeInDown {
|
||||
0% {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(0, -100%, 0);
|
||||
transform: translate3d(0, -100%, 0);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
-webkit-transform: none;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Simple CSS3 Fade-in Animation */
|
||||
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
|
||||
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
|
||||
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
|
||||
|
||||
.fadeIn {
|
||||
opacity:0;
|
||||
-webkit-animation:fadeIn ease-in 1;
|
||||
-moz-animation:fadeIn ease-in 1;
|
||||
animation:fadeIn ease-in 1;
|
||||
|
||||
-webkit-animation-fill-mode:forwards;
|
||||
-moz-animation-fill-mode:forwards;
|
||||
animation-fill-mode:forwards;
|
||||
|
||||
-webkit-animation-duration:1s;
|
||||
-moz-animation-duration:1s;
|
||||
animation-duration:1s;
|
||||
}
|
||||
|
||||
.fadeIn.first {
|
||||
-webkit-animation-delay: 0.4s;
|
||||
-moz-animation-delay: 0.4s;
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
.fadeIn.second {
|
||||
-webkit-animation-delay: 0.6s;
|
||||
-moz-animation-delay: 0.6s;
|
||||
animation-delay: 0.6s;
|
||||
}
|
||||
|
||||
.fadeIn.third {
|
||||
-webkit-animation-delay: 0.8s;
|
||||
-moz-animation-delay: 0.8s;
|
||||
animation-delay: 0.8s;
|
||||
}
|
||||
|
||||
.fadeIn.fourth {
|
||||
-webkit-animation-delay: 1s;
|
||||
-moz-animation-delay: 1s;
|
||||
animation-delay: 1s;
|
||||
}
|
||||
|
||||
/* Simple CSS3 Fade-in Animation */
|
||||
.underlineHover:after {
|
||||
display: block;
|
||||
left: 0;
|
||||
bottom: -10px;
|
||||
width: 0;
|
||||
height: 2px;
|
||||
background-color: #56baed;
|
||||
content: "";
|
||||
transition: width 0.2s;
|
||||
}
|
||||
|
||||
.underlineHover:hover {
|
||||
color: #0d0d0d;
|
||||
}
|
||||
|
||||
.underlineHover:hover:after{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* OTHERS */
|
||||
|
||||
*:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#icon {
|
||||
width:60%;
|
||||
}
|
||||
|
||||
</style>
|
||||
<cheapy:layout pageName="singUp">
|
||||
<h2 style="text-align:center;padding:5px">
|
||||
<fmt:message key="new"/><fmt:message key="user"/>
|
||||
</h2>
|
||||
<form:form modelAttribute="usuario" class="form-horizontal"
|
||||
id="add-foodOffer-form">
|
||||
<div class="form-group has-feedback">
|
||||
<cheapy:inputField label="Nombre" placeholder="Ponga aqui su nombre"
|
||||
name="nombre" />
|
||||
<cheapy:inputField label="Apellidos" placeholder="Ponga aqui sus apellidos"
|
||||
name="apellidos" />
|
||||
<cheapy:inputField label="Direccion" placeholder="Ponga aqui su dirección"
|
||||
name="direccion" />
|
||||
<div class="form-group">
|
||||
<label>Municipio: </label>
|
||||
<select name="municipio">
|
||||
<c:forEach items="${municipio}" var="entry">
|
||||
<option value="${entry}">${entry}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</div>
|
||||
<cheapy:inputField label="Email" placeholder="Ponga aqui su email"
|
||||
name="email" />
|
||||
<cheapy:inputField label="Nombre de usuario" placeholder="Ponga aqui su nombre de usuario"
|
||||
name="usuar.username" />
|
||||
<cheapy:inputField label="Contraseña" placeholder="Ponga aqui su contraseña"
|
||||
name="usuar.password" />
|
||||
<input type="submit" class="fadeIn fourth" value="Registrarse">
|
||||
</div>
|
||||
</form:form>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
@ -16,27 +16,24 @@
|
|||
<div class="form-group has-feedback">
|
||||
<cheapy:inputField label="Nombre" name="nombre"/>
|
||||
<cheapy:inputField label="Apellidos" name="apellidos"/>
|
||||
<cheapy:inputField label="DNI" name="dni"/>
|
||||
<div class="form-group">
|
||||
<label>Municipio: </label>
|
||||
<select name="municipio">
|
||||
<c:forEach items="${municipio}" var="entry">
|
||||
<option value="${entry}">${entry}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</div>
|
||||
<cheapy:inputField label="Direccion" name="direccion"/>
|
||||
<cheapy:inputField label="Telefono" name="telefono"/>
|
||||
<cheapy:inputField label="Email" name="email"/>
|
||||
<cheapy:passwordField label="Password" name="usuar.password"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<div class="btn-mod">
|
||||
<c:choose>
|
||||
<c:when test="${usuario['new']}">
|
||||
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Crear usuario</button>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Modificar</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -22,17 +22,14 @@
|
|||
<td><c:out value="${usuario.apellidos}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="dni"/></th>
|
||||
<td><c:out value="${usuario.dni}"/></td>
|
||||
<th><fmt:message key="municipio"/></th>
|
||||
<td><c:out value="${usuario.municipio}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="addressUser"/></th>
|
||||
<td><c:out value="${usuario.direccion}"/> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="telephone"/></th>
|
||||
<td><c:out value="${usuario.telefono}"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><fmt:message key="email"/></th>
|
||||
<td><c:out value="${usuario.email}"/></td>
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
</cheapy:menuItem>
|
||||
-->
|
||||
<sec:authorize access="isAuthenticated()">
|
||||
<cheapy:menuItem active="${name eq 'reviews'}" url="/reviews" title="opiniones">
|
||||
<cheapy:menuItem active="${name eq 'reviews'}" url="/reviewsList/0" title="opiniones">
|
||||
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
|
||||
<span>Reseñas</span>
|
||||
</cheapy:menuItem>
|
||||
|
@ -90,6 +90,14 @@
|
|||
<li><a href="<c:url value="/login" />">Iniciar sesión</a></li>
|
||||
<!--<li><a href="<c:url value="/users/new" />">Register</a></li>-->
|
||||
</sec:authorize>
|
||||
<sec:authorize access="!isAuthenticated()">
|
||||
<li><a href="<c:url value="/users/new" />">Registrarse Usuario</a></li>
|
||||
<!--<li><a href="<c:url value="/users/new" />">Register</a></li>-->
|
||||
</sec:authorize>
|
||||
<sec:authorize access="!isAuthenticated()">
|
||||
<li><a href="<c:url value="/clients/new" />">Registrarse Cliente</a></li>
|
||||
<!--<li><a href="<c:url value="/users/new" />">Register</a></li>-->
|
||||
</sec:authorize>
|
||||
<sec:authorize access="isAuthenticated()">
|
||||
<li class="dropdown"><a href="#" class="dropdown-toggle"
|
||||
data-toggle="dropdown"> <span class="glyphicon glyphicon-user"></span>
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
|||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.cheapy.configuration.SecurityConfiguration;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.Code;
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
|
@ -52,6 +53,9 @@ class FoodOfferControllerTest {
|
|||
@BeforeEach
|
||||
void setup() {
|
||||
User user1 = new User();
|
||||
Code code1 = new Code();
|
||||
code1.setActivo(true);
|
||||
code1.setCode("codeTest1");
|
||||
user1.setUsername("user1");
|
||||
user1.setPassword("user1");
|
||||
Client client1 = new Client();;
|
||||
|
@ -63,7 +67,7 @@ class FoodOfferControllerTest {
|
|||
client1.setFinish(LocalTime.of(01, 01));
|
||||
client1.setTelephone("123456789");
|
||||
client1.setDescription("client1");
|
||||
client1.setCode("client1");
|
||||
client1.setCode(code1);
|
||||
client1.setFood("client1");
|
||||
client1.setUsuar(user1);
|
||||
BDDMockito.given(this.clientService.getCurrentClient()).willReturn(client1);
|
||||
|
@ -132,4 +136,4 @@ class FoodOfferControllerTest {
|
|||
mockMvc.perform(get("/offers/food/{foodOfferId}/activate", TEST_FOODOFFER_ID+1))
|
||||
.andExpect(view().name("exception"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
|||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.cheapy.configuration.SecurityConfiguration;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.Code;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
|
@ -51,6 +52,9 @@ class NuOfferControllerTest {
|
|||
@BeforeEach
|
||||
void setup() {
|
||||
User user1 = new User();
|
||||
Code code1 = new Code();
|
||||
code1.setActivo(true);
|
||||
code1.setCode("codeTest1");
|
||||
user1.setUsername("user1");
|
||||
user1.setPassword("user1");
|
||||
Client client1 = new Client();
|
||||
|
@ -62,7 +66,7 @@ class NuOfferControllerTest {
|
|||
client1.setFinish(LocalTime.of(01, 01));
|
||||
client1.setTelephone("123456789");
|
||||
client1.setDescription("client1");
|
||||
client1.setCode("client1");
|
||||
client1.setCode(code1);
|
||||
client1.setFood("client1");
|
||||
client1.setUsuar(user1);
|
||||
BDDMockito.given(this.clientService.getCurrentClient()).willReturn(client1);
|
||||
|
@ -148,4 +152,4 @@ class NuOfferControllerTest {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
|||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.cheapy.configuration.SecurityConfiguration;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.Code;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
|
@ -52,6 +53,9 @@ class SpeedOfferControllerTest {
|
|||
@BeforeEach
|
||||
void setup() {
|
||||
User user1 = new User();
|
||||
Code code1 = new Code();
|
||||
code1.setActivo(true);
|
||||
code1.setCode("codeTest1");
|
||||
user1.setUsername("user1");
|
||||
user1.setPassword("user1");
|
||||
Client client1 = new Client();
|
||||
|
@ -63,7 +67,7 @@ class SpeedOfferControllerTest {
|
|||
client1.setFinish(LocalTime.of(01, 01));
|
||||
client1.setTelephone("123456789");
|
||||
client1.setDescription("client1");
|
||||
client1.setCode("client1");
|
||||
client1.setCode(code1);
|
||||
client1.setFood("client1");
|
||||
client1.setUsuar(user1);
|
||||
BDDMockito.given(this.clientService.getCurrentClient()).willReturn(client1);
|
||||
|
@ -148,4 +152,4 @@ class SpeedOfferControllerTest {
|
|||
mockMvc.perform(get("/offers/speed/{speedOfferId}/activate", TEST_SPEEDOFFER_ID+1))
|
||||
.andExpect(view().name("exception"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
|||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.cheapy.configuration.SecurityConfiguration;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.Code;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
|
@ -51,6 +52,9 @@ class TimeOfferControllerTest {
|
|||
@BeforeEach
|
||||
void setup() {
|
||||
User user1 = new User();
|
||||
Code code1 = new Code();
|
||||
code1.setActivo(true);
|
||||
code1.setCode("codeTest1");
|
||||
user1.setUsername("user1");
|
||||
user1.setPassword("user1");
|
||||
Client client1 = new Client();
|
||||
|
@ -62,7 +66,7 @@ class TimeOfferControllerTest {
|
|||
client1.setFinish(LocalTime.of(01, 01));
|
||||
client1.setTelephone("123456789");
|
||||
client1.setDescription("client1");
|
||||
client1.setCode("client1");
|
||||
client1.setCode(code1);
|
||||
client1.setFood("client1");
|
||||
client1.setUsuar(user1);
|
||||
BDDMockito.given(this.clientService.getCurrentClient()).willReturn(client1);
|
||||
|
@ -138,4 +142,4 @@ class TimeOfferControllerTest {
|
|||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue