[d24f17c] | 1 | package com.example.rezevirajmasa.demo.model;
|
---|
| 2 |
|
---|
[e15e8d9] | 3 | import com.fasterxml.jackson.annotation.JsonIgnore;
|
---|
[d24f17c] | 4 | import jakarta.persistence.*;
|
---|
[e15e8d9] | 5 | import lombok.Data;
|
---|
[d24f17c] | 6 |
|
---|
| 7 | import java.math.BigDecimal;
|
---|
[2518b3a] | 8 | import java.util.ArrayList;
|
---|
| 9 | import java.util.List;
|
---|
[d24f17c] | 10 |
|
---|
| 11 | @Entity
|
---|
| 12 | @Table(name = "menus")
|
---|
[e15e8d9] | 13 | @Data
|
---|
[d24f17c] | 14 | public class Menu {
|
---|
| 15 | @Id
|
---|
| 16 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
[2518b3a] | 17 | @Column(name = "menu_id")
|
---|
[d24f17c] | 18 | private Long menuID;
|
---|
| 19 |
|
---|
| 20 | @ManyToOne
|
---|
[2518b3a] | 21 | @JoinColumn(name = "restaurant_id", nullable = false)
|
---|
[e15e8d9] | 22 | @JsonIgnore
|
---|
[d24f17c] | 23 | private Restaurant restaurant;
|
---|
| 24 |
|
---|
[2518b3a] | 25 | @Column(name = "item_name", length = 100)
|
---|
[d24f17c] | 26 | private String itemName;
|
---|
| 27 |
|
---|
[b67dfd3] | 28 | @Column(name = "menuCategory", length = 50)
|
---|
| 29 | private String menuCategory;
|
---|
[d24f17c] | 30 |
|
---|
[2518b3a] | 31 | @Column(name = "price", precision = 8, scale = 2)
|
---|
[d24f17c] | 32 | private BigDecimal price;
|
---|
| 33 |
|
---|
[2518b3a] | 34 | @Column(name = "description")
|
---|
[d24f17c] | 35 | private String description;
|
---|
| 36 |
|
---|
[2518b3a] | 37 | @OneToMany(mappedBy = "menu", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
---|
| 38 | private List<MenuTag> tags = new ArrayList<>();
|
---|
[d24f17c] | 39 |
|
---|
[e48199a] | 40 | @OneToMany(mappedBy = "menu", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
---|
| 41 | private List<PriceHistory> priceHistoryList = new ArrayList<>();
|
---|
| 42 |
|
---|
[d24f17c] | 43 | public Menu() {
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[2518b3a] | 46 | public Menu(Long menuID, Restaurant restaurant, String itemName, String category, BigDecimal price, String description, List<MenuTag> tags) {
|
---|
| 47 | this.menuID = menuID;
|
---|
[d24f17c] | 48 | this.restaurant = restaurant;
|
---|
| 49 | this.itemName = itemName;
|
---|
[b67dfd3] | 50 | this.menuCategory = category;
|
---|
[d24f17c] | 51 | this.price = price;
|
---|
| 52 | this.description = description;
|
---|
[2518b3a] | 53 | this.tags = tags;
|
---|
[d24f17c] | 54 | }
|
---|
| 55 | } |
---|