source: src/main/java/com/example/moviezone/model/Worker.java@ 608fba87

Last change on this file since 608fba87 was 1e7126f, checked in by DenicaKj <dkorvezir@…>, 15 months ago

fix

  • Property mode set to 100644
File size: 1.9 KB
Line 
1package com.example.moviezone.model;
2
3import javax.persistence.*;
4import lombok.Getter;
5import lombok.Setter;
6import lombok.ToString;
7import org.springframework.security.core.GrantedAuthority;
8
9import java.time.LocalDate;
10import java.util.Collection;
11import java.util.Collections;
12import java.util.Objects;
13
14@Entity
15@Getter
16@Setter
17@ToString
18@Table(name = "workers")
19@PrimaryKeyJoinColumn(name = "id_worker")
20public class Worker extends User {
21
22 String position;
23
24 String work_hours_from;
25 String work_hours_to;
26
27 @ManyToOne
28 @JoinColumn(name = "id_cinema")
29 Cinema cinema;
30
31 public Worker(String password, String first_name, String last_name, String address, String contact_number, String username) {
32 super(password, first_name, last_name, address, contact_number, username);
33 }
34 public Worker(String password, String first_name, String last_name, String address, String contact_number, String username,String position,String work_hours_from,String work_hours_to,Cinema cinema) {
35 super(password, first_name, last_name, address, contact_number, username);
36 this.position=position;
37 this.work_hours_from=work_hours_from;
38 this.work_hours_to=work_hours_to;
39 this.cinema=cinema;
40 }
41
42 @Override
43 public boolean equals(Object o) {
44 if (this == o) return true;
45 if (o == null || getClass() != o.getClass()) return false;
46 Worker worker = (Worker) o;
47 return id_user!=null && Objects.equals(id_user, worker.id_user);
48 }
49
50 @Override
51 public int hashCode() {
52 return Objects.hash();
53 }
54
55 public Worker() {
56
57 }
58
59 @Override
60 public Collection<? extends GrantedAuthority> getAuthorities() {
61 if (position.equalsIgnoreCase("admin"))
62 return Collections.singletonList(Role.ROLE_ADMIN);
63 else{
64 return Collections.singletonList(Role.ROLE_WORKER);
65 }
66 }
67
68}
Note: See TracBrowser for help on using the repository browser.