source: src/main/java/finki/it/terapijamkbackend/spring/entities/User.java

Last change on this file was 743de55, checked in by macagaso <gasoskamarija@…>, 6 weeks ago

Initial commit

  • Property mode set to 100644
File size: 2.6 KB
Line 
1package finki.it.terapijamkbackend.spring.entities;
2
3import finki.it.terapijamkbackend.spring.dto.AppointmentInfo;
4import finki.it.terapijamkbackend.spring.dto.CarriedOutInfo;
5import lombok.*;
6import jakarta.persistence.*;
7
8import java.time.LocalDate;
9import java.time.LocalDateTime;
10import java.util.ArrayList;
11import java.util.List;
12
13@Getter
14@Setter
15@EqualsAndHashCode
16@NoArgsConstructor
17@Entity(name="User")
18@Table(name="users")
19public class User {
20
21 @SequenceGenerator(
22 name="user_sequence",
23 sequenceName = "user_sequence",
24 allocationSize = 1
25 )
26 @Id
27 @GeneratedValue(
28 strategy=GenerationType.SEQUENCE,
29 generator = "user_sequence"
30 )
31 private Long id;
32 private String name;
33 private String surname;
34 private String username;
35 private String password;
36 private LocalDate dateBirth;
37 private String phone;
38 private boolean locked;
39
40 @ElementCollection
41 @CollectionTable(name = "user_appointment_dates", joinColumns = @JoinColumn(name = "user_id"))
42 @Column(name = "appointment_date")
43 private List<AppointmentInfo> dates;
44 @ElementCollection
45 @CollectionTable(name = "user_carriedOut_dates", joinColumns = @JoinColumn(name = "user_id"))
46 @Column(name = "carriedOut_date")
47 private List<CarriedOutInfo> carriedOut;
48
49 @Enumerated(EnumType.STRING)
50 private UserRole userRole;
51
52 public User(String name,String surname,String username,String password,String age,String phone){
53 this.name=name;
54 this.surname=surname;
55 this.username=username;
56 this.password=password;
57 LocalDate temp=LocalDate.parse(age);
58 dateBirth=temp;
59 this.phone=phone;
60 locked=false;
61 userRole=UserRole.USER;
62 dates=new ArrayList<>();
63 carriedOut=new ArrayList<>();
64 }
65
66 @Override
67 public String toString() {
68 return username+" "+name+" "+surname;
69 }
70
71 public void setAppointmentTerms(String term,String additionalInfo,String status){
72 LocalDateTime localDateTime=LocalDateTime.parse(term);
73 AppointmentInfoStatus temp=AppointmentInfoStatus.valueOf(status);
74 AppointmentInfo appointmentInfo=new AppointmentInfo(localDateTime,additionalInfo,temp);
75 dates.add(appointmentInfo);
76 }
77 public void setCarriedOut(String term,String additionalInfo,String adminNote,String status){
78 LocalDateTime localDateTime=LocalDateTime.parse(term);
79 AppointmentInfoStatus temp=AppointmentInfoStatus.valueOf(status);
80 CarriedOutInfo carriedOutInfo=new CarriedOutInfo(localDateTime,additionalInfo,adminNote,temp);
81 carriedOut.add(carriedOutInfo);
82 }
83}
Note: See TracBrowser for help on using the repository browser.