source: Git/Sources/src/main/java/com/wediscussmovies/project/model/User.java@ 980eeda

main
Last change on this file since 980eeda was 980eeda, checked in by Test <matonikolov77@…>, 22 months ago

Restructuring project

  • Property mode set to 100644
File size: 2.7 KB
Line 
1package com.wediscussmovies.project.model;
2
3import com.wediscussmovies.project.model.relation.MovieLikes;
4import com.wediscussmovies.project.model.relation.UserGenres;
5import com.wediscussmovies.project.model.relation.MovieRates;
6import com.wediscussmovies.project.model.relation.PersonRates;
7import lombok.Data;
8import org.springframework.security.core.GrantedAuthority;
9import org.springframework.security.core.userdetails.UserDetails;
10
11import javax.persistence.*;
12import java.io.Serializable;
13import java.util.ArrayList;
14import java.util.Collection;
15import java.util.Objects;
16
17@Entity
18@Table(name = "users", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
19@Data
20public class User implements UserDetails {
21 @GeneratedValue(strategy = GenerationType.IDENTITY)
22 @Id
23 @Column(name = "user_id")
24 private int userId;
25 @Basic
26 @Column(name = "username")
27 private String username;
28 @Basic
29 @Column(name = "name")
30 private String name;
31 @Basic
32 @Column(name = "surname")
33 private String surname;
34 @Basic
35 @Column(name = "email")
36 private String email;
37 @Basic
38 @Column(name = "password")
39 private String password;
40 @OneToMany(mappedBy = "user")
41 private Collection<Discussion> discussions;
42 @OneToMany(mappedBy = "user")
43 private Collection<MovieLikes> movieLikes;
44 @OneToMany(mappedBy = "user")
45 private Collection<MovieRates> movieRates;
46 @OneToMany(mappedBy = "user")
47 private Collection<PersonRates> personRates;
48 @OneToMany(mappedBy = "user")
49 private Collection<Reply> replies;
50 @OneToMany(mappedBy = "user")
51 private Collection<UserGenres> userGenres;
52
53 public User() {
54
55 }
56
57
58
59 @Override
60 public boolean isAccountNonExpired() {
61 return true;
62 }
63
64 @Override
65 public boolean isAccountNonLocked() {
66 return true;
67 }
68
69 @Override
70 public boolean isCredentialsNonExpired() {
71 return true;
72 }
73
74 @Override
75 public boolean isEnabled() {
76 return true;
77 }
78
79
80 @Override
81 public Collection<? extends GrantedAuthority> getAuthorities() {
82 return new ArrayList<>();
83 }
84
85 public User( String email,String username , String password, String name,String surname) {
86 this.username = username;
87 this.name = name;
88 this.surname = surname;
89 this.email = email;
90 this.password = password;
91 }
92
93 @Override
94 public boolean equals(Object o) {
95 if (this == o) return true;
96 if (o == null || getClass() != o.getClass()) return false;
97 User user = (User) o;
98 return userId == user.userId;
99 }
100
101 @Override
102 public int hashCode() {
103 return Objects.hash(userId);
104 }
105}
Note: See TracBrowser for help on using the repository browser.