source: src/main/java/com/example/baziproekt/model/Korisnici.java@ 0e4d807

Last change on this file since 0e4d807 was 0e4d807, checked in by Ivona <ivonatapshanovska@…>, 10 months ago

Initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1package com.example.baziproekt.model;
2
3import javax.persistence.*;
4import lombok.Getter;
5import lombok.Setter;
6import org.springframework.security.core.GrantedAuthority;
7import org.springframework.security.core.userdetails.UserDetails;
8
9import javax.persistence.Table;
10import java.util.Collection;
11import java.util.Objects;
12
13@Getter
14@Setter
15@Table
16@Entity
17@Inheritance(strategy = InheritanceType.JOINED)
18public class Korisnici implements UserDetails {
19
20 @Id
21 @Column(name="korisnicko_ime",unique = true)
22 private String ime;
23
24 public Korisnici(String ime, String lozinka) {
25 this.ime = ime;
26 this.lozinka = lozinka;
27
28 }
29
30 private String lozinka;
31
32
33 @Override
34 public boolean equals(Object o) {
35 if (this == o) return true;
36 if (o == null || getClass() != o.getClass()) return false;
37 Korisnici korisnici = (Korisnici) o;
38 return Objects.equals(ime, korisnici.ime) && Objects.equals(lozinka, korisnici.lozinka) && Objects.equals(email, korisnici.email) && Objects.equals(broj, korisnici.broj);
39 }
40
41 @Override
42 public int hashCode() {
43 return Objects.hash(ime, lozinka, email, broj);
44 }
45
46 @Column(name="e_posta",nullable = false)
47 private String email;
48
49 @Column(name = "telefonski_broj")
50 private String broj;
51
52
53 public Korisnici(String ime, String lozinka, String email) {
54 this.ime = ime;
55 this.lozinka = lozinka;
56 this.email = email;
57
58 }
59
60
61
62
63
64
65 public Korisnici() {
66 }
67
68
69 @Override
70 public Collection<? extends GrantedAuthority> getAuthorities() {
71 return null;
72 }
73
74 @Override
75 public String getPassword() {
76 return lozinka;
77 }
78
79 @Override
80 public String getUsername() {
81 return ime;
82 }
83
84 @Override
85 public boolean isAccountNonExpired() {
86 return true;
87 }
88
89 @Override
90 public boolean isAccountNonLocked() {
91 return true;
92 }
93
94 @Override
95 public boolean isCredentialsNonExpired() {
96 return true;
97 }
98
99 @Override
100 public boolean isEnabled() {
101 return true;
102 }
103}
Note: See TracBrowser for help on using the repository browser.