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