Blame view

src/main/java/fr/plil/sio/web/mvc/User.java 2.03 KB
aa193b2b   Julien Iguchi-Cartigny   First version
1
2
  package fr.plil.sio.web.mvc;
  
aa193b2b   Julien Iguchi-Cartigny   First version
3
  
c1d2852e   Zak   Ajout css
4
  import com.fasterxml.jackson.annotation.JsonBackReference;
f9b4ae49   jcartign   Fix recursion in ...
5
  import com.fasterxml.jackson.annotation.JsonManagedReference;
353d9d4f   Zak   désactivation des...
6
  import java.util.ArrayList;
322c9502   Julien Cartigny   Ad Spring securit...
7
8
9
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.userdetails.UserDetails;
  
2070653e   Julien Iguchi-Cartigny   Switching to spri...
10
  import javax.persistence.*;
322c9502   Julien Cartigny   Ad Spring securit...
11
  import java.util.Collection;
353d9d4f   Zak   désactivation des...
12
  import java.util.List;
322c9502   Julien Cartigny   Ad Spring securit...
13
14
  import java.util.Set;
  import java.util.TreeSet;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
15
16
  
  @Entity
322c9502   Julien Cartigny   Ad Spring securit...
17
18
  @Table(name = "USER_T")
  public class User implements UserDetails {
2070653e   Julien Iguchi-Cartigny   Switching to spri...
19
20
  
      @Id
322c9502   Julien Cartigny   Ad Spring securit...
21
      @Column(name = "USER_ID")
2070653e   Julien Iguchi-Cartigny   Switching to spri...
22
23
24
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
322c9502   Julien Cartigny   Ad Spring securit...
25
      @Column(name = "USERNAME_F")
aa193b2b   Julien Iguchi-Cartigny   First version
26
      private String username;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
27
  
322c9502   Julien Cartigny   Ad Spring securit...
28
      @Column(name = "PASSWORD_F")
aa193b2b   Julien Iguchi-Cartigny   First version
29
30
      private String password;
  
c1d2852e   Zak   Ajout css
31
32
33
      @OneToMany(mappedBy="borrower",cascade = CascadeType.REMOVE)
      @JsonBackReference
      private List<Dette> dettes = new ArrayList<>();
353d9d4f   Zak   désactivation des...
34
35
36
37
38
39
40
41
42
43
  
      public List<Dette> getDettes() {
          return dettes;
      }
  
      public void setDettes(List<Dette> dettes) {
          this.dettes = dettes;
      }
      
      
322c9502   Julien Cartigny   Ad Spring securit...
44
      @ManyToMany(mappedBy = "users", fetch = FetchType.EAGER)
f9b4ae49   jcartign   Fix recursion in ...
45
      @JsonManagedReference
322c9502   Julien Cartigny   Ad Spring securit...
46
47
48
49
      private Set<Role> roles = new TreeSet<>();
  
      public Set<Role> getRoles() {
          return roles;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
50
51
      }
  
322c9502   Julien Cartigny   Ad Spring securit...
52
53
54
55
56
57
58
59
      public void setRoles(Set<Role> roles) {
          this.roles = roles;
      }
  
  
      @Override
      public Collection<? extends GrantedAuthority> getAuthorities() {
          return roles;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
60
61
      }
  
aa193b2b   Julien Iguchi-Cartigny   First version
62
63
64
65
66
67
68
69
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
322c9502   Julien Cartigny   Ad Spring securit...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
      @Override
      public boolean isAccountNonExpired() {
          return true;
      }
  
      @Override
      public boolean isAccountNonLocked() {
          return true;
      }
  
      @Override
      public boolean isCredentialsNonExpired() {
          return true;
      }
  
      @Override
      public boolean isEnabled() {
          return true;
      }
  
aa193b2b   Julien Iguchi-Cartigny   First version
90
91
92
93
94
95
96
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
aa193b2b   Julien Iguchi-Cartigny   First version
97
  }