source: src/main/java/com/example/rezevirajmasa/demo/model/Restaurant.java@ db39d9e

main
Last change on this file since db39d9e was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 7.6 KB
Line 
1package com.example.rezevirajmasa.demo.model;
2
3import com.fasterxml.jackson.annotation.JsonIgnore;
4import com.fasterxml.jackson.annotation.JsonManagedReference;
5import jakarta.persistence.*;
6
7import java.math.BigDecimal;
8import java.time.LocalDateTime;
9import java.util.List;
10
11@Entity
12@Table(name = "restaurants")
13public class Restaurant {
14
15 @Id
16 @GeneratedValue(strategy = GenerationType.IDENTITY)
17 @Column(name = "RestaurantID")
18 private Long restaurantId;
19
20 @Column(name = "Name", length = 100)
21 private String name;
22
23 @Column(name = "CuisineType", length = 50)
24 private String cuisineType;
25
26 @Column(name = "Address", length = 1000)
27 private String address;
28
29 @Column(name = "Phone", length = 20)
30 private String phone;
31
32 @Column(name = "OperatingHours", length = 100)
33 private String operatingHours;
34
35 @Column(name = "Website", length = 100)
36 private String website;
37
38 @Column(name = "SocialMediaLinks")
39 private String socialMediaLinks;
40
41 @Column(name = "Rating", precision = 3, scale = 2)
42 private BigDecimal rating;
43
44 @JsonManagedReference
45 @OneToMany(mappedBy = "restaurant", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
46 private List<TableEntity> tablesList;
47
48 public Restaurant() {
49 }
50
51 public Restaurant(String name, String cuisineType, String address, String phone, String operatingHours, String website, String socialMediaLinks, BigDecimal rating, List<TableEntity> tablesList) {
52 this.name = name;
53 this.cuisineType = cuisineType;
54 this.address = address;
55 this.phone = phone;
56 this.operatingHours = operatingHours;
57 this.website = website;
58 this.socialMediaLinks = socialMediaLinks;
59 this.rating = rating;
60 this.tablesList = tablesList;
61 }
62
63 public String getName() {
64 return name;
65 }
66
67 public void setName(String name) {
68 this.name = name;
69 }
70
71 public String getCuisineType() {
72 return cuisineType;
73 }
74
75 public void setCuisineType(String cuisineType) {
76 this.cuisineType = cuisineType;
77 }
78
79 public String getAddress() {
80 return address;
81 }
82
83 public void setAddress(String address) {
84 this.address = address;
85 }
86
87 public String getPhone() {
88 return phone;
89 }
90
91 public void setPhone(String phone) {
92 this.phone = phone;
93 }
94
95 public String getOperatingHours() {
96 return operatingHours;
97 }
98
99 public void setOperatingHours(String operatingHours) {
100 this.operatingHours = operatingHours;
101 }
102
103 public String getWebsite() {
104 return website;
105 }
106
107 public void setWebsite(String website) {
108 this.website = website;
109 }
110
111 public String getSocialMediaLinks() {
112 return socialMediaLinks;
113 }
114
115 public void setSocialMediaLinks(String socialMediaLinks) {
116 this.socialMediaLinks = socialMediaLinks;
117 }
118
119 public BigDecimal getRating() {
120 return rating;
121 }
122
123 public void setRating(BigDecimal rating) {
124 this.rating = rating;
125 }
126
127 public List<TableEntity> getTablesList() {
128 return tablesList;
129 }
130
131 public void setTablesList(List<TableEntity> tablesList) {
132 this.tablesList = tablesList;
133 }
134
135 public Long getRestaurantId() {
136 return restaurantId;
137 }
138
139 public void setRestaurantId(Long restaurantId) {
140 this.restaurantId = restaurantId;
141 }
142
143 @Entity
144 @Table(name = "reservation_history")
145 public static class ReservationHistory {
146
147 @Id
148 @GeneratedValue(strategy = GenerationType.IDENTITY)
149 private Long id;
150
151 @ManyToOne
152 @JoinColumn(name = "customer_id")
153 private Customer customer;
154
155 @ManyToOne
156 @JoinColumn(name = "table_id")
157 private TableEntity table;
158
159 @ManyToOne
160 @JoinColumn(name = "restaurant_id")
161 private Restaurant restaurant; // Add this field
162
163 @Column(name = "reservation_datetime")
164 private LocalDateTime reservationDateTime;
165
166 @Column(name = "party_size")
167 private int partySize;
168
169 @Column(name = "special_requests")
170 private String specialRequests;
171
172 @Column(name = "status")
173 private String status; // Completed, Canceled, etc.
174
175 @Column(name = "cancellation_reason")
176 private String cancellationReason;
177
178 @Column(name = "check_in_date") // Add this field
179 private LocalDateTime checkInDate;
180
181 public ReservationHistory(Customer customer, TableEntity table, Restaurant restaurant, LocalDateTime reservationDateTime, int partySize, String specialRequests, String status, String cancellationReason, LocalDateTime checkInDate) {
182 this.customer = customer;
183 this.table = table;
184 this.restaurant = restaurant;
185 this.reservationDateTime = reservationDateTime;
186 this.partySize = partySize;
187 this.specialRequests = specialRequests;
188 this.status = status;
189 this.cancellationReason = cancellationReason;
190 this.checkInDate = checkInDate;
191 }
192
193 public ReservationHistory() {
194 }
195
196 public Long getId() {
197 return id;
198 }
199
200 public void setId(Long id) {
201 this.id = id;
202 }
203
204 public Customer getCustomer() {
205 return customer;
206 }
207
208 public void setCustomer(Customer customer) {
209 this.customer = customer;
210 }
211
212 public TableEntity getTable() {
213 return table;
214 }
215
216 public void setTable(TableEntity table) {
217 this.table = table;
218 }
219
220 public LocalDateTime getReservationDateTime() {
221 return reservationDateTime;
222 }
223
224 public void setReservationDateTime(LocalDateTime reservationDateTime) {
225 this.reservationDateTime = reservationDateTime;
226 }
227
228 public int getPartySize() {
229 return partySize;
230 }
231
232 public void setPartySize(int partySize) {
233 this.partySize = partySize;
234 }
235
236 public String getSpecialRequests() {
237 return specialRequests;
238 }
239
240 public void setSpecialRequests(String specialRequests) {
241 this.specialRequests = specialRequests;
242 }
243
244 public String getStatus() {
245 return status;
246 }
247
248 public void setStatus(String status) {
249 this.status = status;
250 }
251
252 public String getCancellationReason() {
253 return cancellationReason;
254 }
255
256 public void setCancellationReason(String cancellationReason) {
257 this.cancellationReason = cancellationReason;
258 }
259
260 public Restaurant getRestaurant() {
261 return restaurant;
262 }
263
264 public void setRestaurant(Restaurant restaurant) {
265 this.restaurant = restaurant;
266 }
267
268 public LocalDateTime getCheckInDate() {
269 return checkInDate;
270 }
271
272 public void setCheckInDate(LocalDateTime checkInDate) {
273 this.checkInDate = checkInDate;
274 }
275
276 @Override
277 public String toString() {
278 return "ReservationHistory{" +
279 "id=" + id +
280 ", customer=" + customer +
281 ", table=" + table +
282 ", restaurant=" + restaurant +
283 ", reservationDateTime=" + reservationDateTime +
284 ", partySize=" + partySize +
285 ", specialRequests='" + specialRequests + '\'' +
286 ", status='" + status + '\'' +
287 ", cancellationReason='" + cancellationReason + '\'' +
288 ", checkInDate=" + checkInDate +
289 '}';
290 }
291 }
292}
Note: See TracBrowser for help on using the repository browser.