source: src/main/java/project/educatum/model/Teacher.java

Last change on this file was d3cf3a1, checked in by Marija Micevska <marija_micevska@…>, 2 years ago

Initial commit

  • Property mode set to 100644
File size: 2.3 KB
Line 
1package project.educatum.model;
2
3import lombok.Data;
4import org.springframework.security.core.GrantedAuthority;
5import org.springframework.security.core.userdetails.UserDetails;
6
7import javax.persistence.*;
8import java.util.Collection;
9
10@Data
11@Entity
12@Table(name = "nastavnici", schema = "project")
13public class Teacher implements UserDetails {
14 @Id
15 @GeneratedValue(strategy = GenerationType.IDENTITY)
16 @Column(name = "id_nastavnik", nullable = false)
17 private Integer id;
18
19 @Column(name = "ime", nullable = false, length = 50)
20 private String name;
21
22 @Column(name = "prezime", nullable = false, length = 50)
23 private String surname;
24
25 @Column(name = "opis", nullable = false, length = 500)
26 private String description;
27
28 @Column(name = "email", nullable = false, length = 50)
29 private String email;
30
31 @Column(name = "password", nullable = false, length = 30)
32 private String password;
33
34 @Column(name = "telefonski_broj", length = 15)
35 private String telephoneNumber;
36
37 @ManyToOne(optional = false)
38 @JoinColumn(name = "id_admin", nullable = false)
39 private Admin idAdmin;
40
41 @Column(name = "enabled")
42 private Boolean enabled;
43
44 @Transient
45 private Float rating;
46
47
48 public Teacher() {
49 }
50
51 public Teacher(String name, String surname, String description, String email, String password, String telephoneNumber) {
52 this.rating = Float.valueOf(0);
53 this.enabled = false;
54 this.name = name;
55 this.surname = surname;
56 this.description = description;
57 this.email = email;
58 this.password = password;
59 this.telephoneNumber = telephoneNumber;
60 }
61
62 @Override
63 public Collection<? extends GrantedAuthority> getAuthorities() {
64 return null;
65 }
66
67 public String getPassword() {
68 return password;
69 }
70
71 @Override
72 public String getUsername() {
73 return email;
74 }
75
76 @Override
77 public boolean isAccountNonExpired() {
78 return false;
79 }
80
81 @Override
82 public boolean isAccountNonLocked() {
83 return false;
84 }
85
86 @Override
87 public boolean isCredentialsNonExpired() {
88 return false;
89 }
90
91 @Override
92 public boolean isEnabled() {
93 return enabled;
94 }
95
96
97 public String getFullName() {
98 return name + ' ' + surname;
99 }
100}
Note: See TracBrowser for help on using the repository browser.