source: src/main/java/com/example/moviezone/model/Worker.java@ 633b371

Last change on this file since 633b371 was 5444409, checked in by milamihajlovska <mila.mihajlovska01@…>, 21 months ago

update register and registerWorker

  • Property mode set to 100644
File size: 1.7 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 return Collections.singletonList(Role.ROLE_ADMIN);
62 }
63
64}
Note: See TracBrowser for help on using the repository browser.