source: src/main/java/com/example/rezevirajmasa/demo/model/Reservation.java@ 8ca35dc

main
Last change on this file since 8ca35dc was 8ca35dc, checked in by Aleksandar Panovski <apano77@…>, 4 months ago

Done with stupid timeslots

  • Property mode set to 100644
File size: 4.9 KB
Line 
1package com.example.rezevirajmasa.demo.model;
2
3import jakarta.persistence.*;
4
5import java.time.LocalDateTime;
6import java.time.LocalTime;
7
8@Entity
9@Table(name = "reservations")
10public class Reservation {
11
12 @Id
13 @GeneratedValue(strategy = GenerationType.IDENTITY)
14 @Column(name = "ReservationID")
15 private Long reservationID;
16
17 @ManyToOne
18 @JoinColumn(name = "UserID")
19 private User user;
20
21 @ManyToOne
22 @JoinColumn(name = "TableNumber", nullable = false)
23 private TableEntity table;
24
25 @ManyToOne
26 @JoinColumn(name = "RestaurantID", nullable = false)
27 private Restaurant restaurant;
28
29 @Column(name = "ReservationDateTime", nullable = false)
30 private LocalDateTime reservationDateTime;
31
32 @Column(name = "PartySize")
33 private int partySize;
34
35 @Column(name = "SpecialRequests")
36 private String specialRequests;
37
38 @Column(name = "Status", length = 20, nullable = false, columnDefinition = "VARCHAR default 'Pending'")
39 private String status;
40
41 @Column(name = "CheckInTime")
42 private LocalDateTime checkInTime;
43
44 @Column(name = "CheckOutTime")
45 private LocalDateTime checkOutTime;
46
47// @Column(name = "TotalAmount", precision = 8, scale = 2)
48// private BigDecimal totalAmount;//rezervacija so depozit ako e
49
50 @Column(name = "PaymentStatus", length = 20, nullable = false, columnDefinition = "VARCHAR default 'Unpaid'")
51 private String paymentStatus;
52
53 public Reservation() {
54
55 }
56
57 // Constructors, getters, setters, and other methods...
58
59 @PrePersist
60 private void prePersist() {
61 // Set default values or perform any pre-persistence logic if needed
62 if (status == null) {
63 status = "Pending";
64 }
65 if (paymentStatus == null) {
66 paymentStatus = "Unpaid";
67 }
68 }
69
70 public Reservation(User user, TableEntity table, Restaurant restaurant, LocalDateTime reservationDateTime, int partySize, String specialRequests, String status, LocalDateTime checkInTime, LocalDateTime checkOutTime, String paymentStatus) {
71// this.customer = customer;
72 this.table = table;
73 this.user = user;
74 this.restaurant = restaurant;
75 this.reservationDateTime = reservationDateTime;
76 this.partySize = partySize;
77 this.specialRequests = specialRequests;
78 this.status = status;
79 this.checkInTime = checkInTime;
80 this.checkOutTime = checkOutTime;
81 this.paymentStatus = paymentStatus;
82 }
83
84 public User getUser() {
85 return user;
86 }
87
88 public void setUser(User user) {
89 this.user = user;
90 }
91
92 public Long getReservationID() {
93 return reservationID;
94 }
95
96 public void setReservationID(Long reservationID) {
97 this.reservationID = reservationID;
98 }
99
100
101 public TableEntity getTable() {
102 return table;
103 }
104
105 public void setTable(TableEntity table) {
106 this.table = table;
107 }
108
109 public Restaurant getRestaurant() {
110 return restaurant;
111 }
112
113 public void setRestaurant(Restaurant restaurant) {
114 this.restaurant = restaurant;
115 }
116
117 public LocalDateTime getReservationDateTime() {
118 return reservationDateTime;
119 }
120
121 public void setReservationDateTime(LocalDateTime reservationDateTime) {
122 this.reservationDateTime = reservationDateTime;
123 }
124
125 public int getPartySize() {
126 return partySize;
127 }
128
129 public void setPartySize(int partySize) {
130 this.partySize = partySize;
131 }
132
133 public String getSpecialRequests() {
134 return specialRequests;
135 }
136
137 public void setSpecialRequests(String specialRequests) {
138 this.specialRequests = specialRequests;
139 }
140
141 public String getStatus() {
142 return status;
143 }
144
145 public void setStatus(String status) {
146 this.status = status;
147 }
148
149 public LocalDateTime getCheckInTime() {
150 return checkInTime;
151 }
152
153 public void setCheckInTime(LocalDateTime checkInTime) {
154 this.checkInTime = checkInTime;
155 }
156
157 public LocalDateTime getCheckOutTime() {
158 return checkOutTime;
159 }
160
161 public void setCheckOutTime(LocalDateTime checkOutTime) {
162 this.checkOutTime = checkOutTime;
163 }
164
165 public String getPaymentStatus() {
166 return paymentStatus;
167 }
168
169 public void setPaymentStatus(String paymentStatus) {
170 this.paymentStatus = paymentStatus;
171 }
172
173 @Override
174 public String toString() {
175 return "Reservation{" +
176 "reservationID=" + reservationID +
177 ", customer=" + user +
178 ", table=" + table +
179 ", restaurant=" + restaurant +
180 ", reservationDateTime=" + reservationDateTime +
181 ", partySize=" + partySize +
182 ", specialRequests='" + specialRequests + '\'' +
183 ", status='" + status + '\'' +
184 ", checkInTime=" + checkInTime +
185 ", checkOutTime=" + checkOutTime +
186 ", paymentStatus='" + paymentStatus + '\'' +
187 '}';
188 }
189}
Note: See TracBrowser for help on using the repository browser.