[a51a591] | 1 | package com.example.model;
|
---|
| 2 |
|
---|
| 3 | import com.example.model.Enumerations.Role;
|
---|
| 4 | import lombok.Getter;
|
---|
| 5 | import lombok.Setter;
|
---|
| 6 | import org.hibernate.Hibernate;
|
---|
| 7 |
|
---|
| 8 | import javax.persistence.*;
|
---|
| 9 | import java.time.LocalDate;
|
---|
| 10 | import java.util.Objects;
|
---|
| 11 |
|
---|
| 12 | @Getter
|
---|
| 13 | @Setter
|
---|
| 14 | @Entity
|
---|
| 15 | @Table(name = "korisnici")
|
---|
| 16 | @Inheritance(strategy = InheritanceType.JOINED)
|
---|
| 17 | public class User {
|
---|
| 18 | @Id
|
---|
| 19 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
| 20 | @Column(name = "korisnik_id")
|
---|
| 21 | Integer id;
|
---|
| 22 | @Column(name = "datum_kreiran")
|
---|
| 23 | LocalDate date;
|
---|
| 24 | @Column(name = "ime")
|
---|
| 25 | String name;
|
---|
| 26 |
|
---|
| 27 | String username;
|
---|
| 28 | @Column(name = "lozinka")
|
---|
| 29 | String password;
|
---|
| 30 | @Column(name = "tel_broj")
|
---|
| 31 | String number;
|
---|
| 32 |
|
---|
| 33 | @Enumerated(value = EnumType.STRING)
|
---|
| 34 | Role role;
|
---|
| 35 |
|
---|
| 36 | public User(String name, String username, String number, String password, Role role) {
|
---|
| 37 | this.date = LocalDate.now();
|
---|
| 38 | this.name = name;
|
---|
| 39 | this.username = username;
|
---|
| 40 | this.password = password;
|
---|
| 41 | this.number = number;
|
---|
| 42 | this.role = role;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | public User(){
|
---|
| 46 |
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | // // @Override
|
---|
| 50 | // public Collection<? extends GrantedAuthority> getAuthorities() {
|
---|
| 51 | // return Collections.singletonList(Role.ROLE_USER);
|
---|
| 52 | // }
|
---|
| 53 |
|
---|
| 54 | @Override
|
---|
| 55 | public boolean equals(Object o) {
|
---|
| 56 | if (this == o) return true;
|
---|
| 57 | if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
---|
| 58 | User that = (User) o;
|
---|
| 59 | return id != null && Objects.equals(id, that.id);
|
---|
| 60 | }
|
---|
| 61 | } |
---|