1 | package com.example.model;
|
---|
2 |
|
---|
3 | import com.example.model.Enumerations.Role;
|
---|
4 | import lombok.Data;
|
---|
5 | import org.hibernate.Hibernate;
|
---|
6 |
|
---|
7 | import javax.persistence.*;
|
---|
8 | import java.util.List;
|
---|
9 | import java.util.Objects;
|
---|
10 |
|
---|
11 | @Data
|
---|
12 | @Entity
|
---|
13 | @Table(name = "keterinzi")
|
---|
14 | public class Catering extends User {
|
---|
15 |
|
---|
16 | @Column(name = "cena")
|
---|
17 | Integer price;
|
---|
18 |
|
---|
19 | @Column(name = "adresa")
|
---|
20 | String address;
|
---|
21 |
|
---|
22 | @OneToMany(mappedBy = "catering_id")
|
---|
23 | List<Client> clients;
|
---|
24 |
|
---|
25 | @OneToMany(mappedBy = "catering")
|
---|
26 | List<Waiter> waiters;
|
---|
27 |
|
---|
28 | @ManyToMany
|
---|
29 | @JoinTable(name = "ketering_nudi_produkt",
|
---|
30 | joinColumns = @JoinColumn(name = "korisnik_id"),
|
---|
31 | inverseJoinColumns = @JoinColumn(name = "produkt_id"))
|
---|
32 | // @ToString.Exclude
|
---|
33 | List<Product> productList;
|
---|
34 |
|
---|
35 | @ManyToMany(mappedBy = "cateringList")
|
---|
36 | List<Event> eventList;
|
---|
37 |
|
---|
38 | public Catering(String name, String username, String number, String password,
|
---|
39 | Integer price, String address, Role role) {
|
---|
40 | super(name, username, number, password, role);
|
---|
41 | this.price = price;
|
---|
42 | this.address = address;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public Catering() {
|
---|
46 | }
|
---|
47 |
|
---|
48 | // @Override
|
---|
49 | // public Collection<? extends GrantedAuthority> getAuthorities() {
|
---|
50 | // return Collections.singletonList(Role.ROLE_CATERING);
|
---|
51 | // }
|
---|
52 |
|
---|
53 | @Override
|
---|
54 | public boolean equals(Object o) {
|
---|
55 | if (this == o) return true;
|
---|
56 | if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
---|
57 | Catering that = (Catering) o;
|
---|
58 | return id != null && Objects.equals(id, that.id);
|
---|
59 | }
|
---|
60 | }
|
---|