[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.Column;
|
---|
| 9 | import javax.persistence.Entity;
|
---|
| 10 | import javax.persistence.OneToMany;
|
---|
| 11 | import javax.persistence.Table;
|
---|
| 12 | import java.util.List;
|
---|
| 13 | import java.util.Objects;
|
---|
| 14 |
|
---|
| 15 | @Getter
|
---|
| 16 | @Setter
|
---|
| 17 | @Entity
|
---|
| 18 | @Table(name = "admini")
|
---|
| 19 | public class Admin extends User{
|
---|
| 20 |
|
---|
| 21 | @Column(name = "br_organizirani_nastani")
|
---|
| 22 | Integer number_events;
|
---|
| 23 |
|
---|
| 24 | @OneToMany(mappedBy = "admin")
|
---|
| 25 | List<Event> events;
|
---|
| 26 |
|
---|
| 27 | public Admin(String name, String username, String number, String password, Role role) {
|
---|
| 28 | super(name, username, number, password, role);
|
---|
| 29 | this.number_events = 0;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | public Admin() {
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | // @Override
|
---|
| 36 | // public Collection<? extends GrantedAuthority> getAuthorities() {
|
---|
| 37 | // return Collections.singletonList(Role.ROLE_ADMIN);
|
---|
| 38 | // }
|
---|
| 39 |
|
---|
| 40 | @Override
|
---|
| 41 | public boolean equals(Object o) {
|
---|
| 42 | if (this == o) return true;
|
---|
| 43 | if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
---|
| 44 | Admin that = (Admin) o;
|
---|
| 45 | return id != null && Objects.equals(id, that.id);
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | @Override
|
---|
| 49 | public String toString() {
|
---|
| 50 | return "Admin{" +
|
---|
| 51 | "number_events=" + number_events +
|
---|
| 52 | ", events=" + events.toString() +
|
---|
| 53 | ", id=" + id +
|
---|
| 54 | ", date=" + date +
|
---|
| 55 | ", name='" + name + '\'' +
|
---|
| 56 | ", username='" + username + '\'' +
|
---|
| 57 | ", password='" + password + '\'' +
|
---|
| 58 | ", number='" + number + '\'' +
|
---|
| 59 | '}';
|
---|
| 60 | }
|
---|
| 61 | }
|
---|