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 {
|
||||
auth.jdbcAuthentication().dataSource(this.dataSource)
|
||||
//[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());
|
||||
|
||||
}
|
||||
|
|
|
@ -2,24 +2,30 @@ package org.springframework.cheapy.model;
|
|||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Entity
|
||||
@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() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUser(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
// public User getUsername() {
|
||||
// return usern;
|
||||
// }
|
||||
//
|
||||
// public void setUser(User user) {
|
||||
// this.usern = user;
|
||||
// }
|
||||
|
||||
public String getAuthority() {
|
||||
return authority;
|
||||
|
|
|
@ -11,7 +11,10 @@ import javax.validation.constraints.NotEmpty;
|
|||
@Entity
|
||||
@Table(name = "clients")
|
||||
public class Client extends User {
|
||||
|
||||
|
||||
@NotEmpty
|
||||
private String email;
|
||||
|
||||
@NotEmpty
|
||||
private String address;
|
||||
|
||||
|
@ -42,7 +45,15 @@ public class Client extends User {
|
|||
|
||||
@OneToMany
|
||||
private Set<TimeOffer> timeOffers;
|
||||
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
|
|
@ -1,30 +1,35 @@
|
|||
package org.springframework.cheapy.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class User extends BaseEntity {
|
||||
|
||||
@NotBlank
|
||||
String username;
|
||||
|
||||
@NotBlank
|
||||
String password;
|
||||
|
||||
@Email
|
||||
@NotBlank
|
||||
String email;
|
||||
//@Entity
|
||||
//@Table(name = "users")
|
||||
@MappedSuperclass
|
||||
public class User{
|
||||
|
||||
@OneToOne
|
||||
Authorities authority;
|
||||
@Id
|
||||
private String username;
|
||||
|
||||
@NotBlank
|
||||
private String password;
|
||||
|
||||
boolean enabled;
|
||||
|
||||
//@OneToMany(cascade = CascadeType.ALL, mappedBy = "usern")
|
||||
//Set<Authorities> authorities;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
|
@ -42,19 +47,11 @@ public class User extends BaseEntity {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Authorities getAuthority() {
|
||||
return authority;
|
||||
}
|
||||
|
||||
public void setAuthority(Authorities authority) {
|
||||
this.authority = authority;
|
||||
}
|
||||
// public Set<Authorities> getAuthority() {
|
||||
// return authorities;
|
||||
// }
|
||||
//
|
||||
// public void setAuthorities(Set<Authorities> authorities) {
|
||||
// this.authorities = authorities;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -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 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