mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Cambios
This commit is contained in:
parent
ce05bea9c0
commit
5b924de49d
5 changed files with 62 additions and 45 deletions
|
@ -58,7 +58,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||||
public void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
public void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.jdbcAuthentication().dataSource(this.dataSource)
|
auth.jdbcAuthentication().dataSource(this.dataSource)
|
||||||
//[login de admin,owner y vet] .usersByUsernameQuery("select username,password,enabled " + "from users " + "where username = ?")
|
//[login de admin,owner y vet] .usersByUsernameQuery("select username,password,enabled " + "from users " + "where username = ?")
|
||||||
.usersByUsernameQuery("select nombre_usuario,contra,enabled from usuarios where nombre_usuario=?").authoritiesByUsernameQuery("select username, authority " + "from authorities " + "where username = ?") //[login de tallerespaco]
|
.usersByUsernameQuery("select username, password, enabled from users where username=?").authoritiesByUsernameQuery("select username, authority " + "from authorities " + "where username = ?") //[login de tallerespaco]
|
||||||
.passwordEncoder(this.passwordEncoder());
|
.passwordEncoder(this.passwordEncoder());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,24 +2,30 @@ package org.springframework.cheapy.model;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "authorities")
|
@Table(name = "authorities")
|
||||||
public class Authorities {
|
public class Authorities extends BaseEntity{
|
||||||
|
|
||||||
@Id
|
|
||||||
String username;
|
//@ManyToOne
|
||||||
|
//@JoinColumn(name = "username")
|
||||||
|
//private User usern;
|
||||||
|
|
||||||
String authority;
|
@Size(min = 3, max = 50)
|
||||||
|
private String authority;
|
||||||
|
|
||||||
public String getUsername() {
|
// public User getUsername() {
|
||||||
return username;
|
// return usern;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setUser(String username) {
|
// public void setUser(User user) {
|
||||||
this.username = username;
|
// this.usern = user;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public String getAuthority() {
|
public String getAuthority() {
|
||||||
return authority;
|
return authority;
|
||||||
|
|
|
@ -11,7 +11,10 @@ import javax.validation.constraints.NotEmpty;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "clients")
|
@Table(name = "clients")
|
||||||
public class Client extends User {
|
public class Client extends User {
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
private String email;
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
|
@ -42,7 +45,15 @@ public class Client extends User {
|
||||||
|
|
||||||
@OneToMany
|
@OneToMany
|
||||||
private Set<TimeOffer> timeOffers;
|
private Set<TimeOffer> timeOffers;
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,35 @@
|
||||||
package org.springframework.cheapy.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.Email;
|
import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
//@Entity
|
||||||
@Table(name = "users")
|
//@Table(name = "users")
|
||||||
public class User extends BaseEntity {
|
@MappedSuperclass
|
||||||
|
public class User{
|
||||||
@NotBlank
|
|
||||||
String username;
|
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
String password;
|
|
||||||
|
|
||||||
@Email
|
|
||||||
@NotBlank
|
|
||||||
String email;
|
|
||||||
|
|
||||||
@OneToOne
|
@Id
|
||||||
Authorities authority;
|
private String username;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
boolean enabled;
|
||||||
|
|
||||||
|
//@OneToMany(cascade = CascadeType.ALL, mappedBy = "usern")
|
||||||
|
//Set<Authorities> authorities;
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
|
@ -42,19 +47,11 @@ public class User extends BaseEntity {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEmail() {
|
// public Set<Authorities> getAuthority() {
|
||||||
return email;
|
// return authorities;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setEmail(String email) {
|
// public void setAuthorities(Set<Authorities> authorities) {
|
||||||
this.email = email;
|
// this.authorities = authorities;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public Authorities getAuthority() {
|
|
||||||
return authority;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthority(Authorities authority) {
|
|
||||||
this.authority = authority;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,7 @@ INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Wa
|
||||||
|
|
||||||
INSERT INTO food_offers(start, end, code, type, client_id, food, discount, units) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, 'macarrones', '15%', 10);
|
INSERT INTO food_offers(start, end, code, type, client_id, food, discount, units) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, 'macarrones', '15%', 10);
|
||||||
|
|
||||||
INSERT INTO time_offers(start, end, code, type, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, '12:00:00', '13:00:00', '10%');
|
INSERT INTO time_offers(start, end, code, type, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, '12:00:00', '13:00:00', '10%');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue