source: src/main/java/com/example/autopartz/model/Order.java

main
Last change on this file was 1bd8d1e, checked in by andrejtodorovski <82031894+andrejtodorovski@…>, 23 months ago

Added views and functionalities for deliveryman, warehouseman and admin

  • Property mode set to 100644
File size: 1.4 KB
Line 
1package com.example.autopartz.model;
2
3import lombok.Getter;
4import lombok.RequiredArgsConstructor;
5import lombok.Setter;
6import lombok.ToString;
7import org.hibernate.Hibernate;
8
9import javax.persistence.*;
10import java.time.LocalDateTime;
11import java.util.List;
12import java.util.Objects;
13
14@Entity
15@Getter
16@Setter
17@ToString
18@RequiredArgsConstructor
19@Table(name = "order_table")
20public class Order {
21 @Id
22 @GeneratedValue(strategy = GenerationType.IDENTITY)
23 @Column(name = "ID_order")
24 Integer orderid;
25 String order_status;
26 @Column(name = "order_date")
27 LocalDateTime date;
28 @JoinColumn(name = "id_user")
29 @ManyToOne
30 Client user;
31 @ManyToMany
32 @JoinTable(name = "order_contains_part", joinColumns =
33 @JoinColumn(name = "id_order"),
34 inverseJoinColumns = @JoinColumn(name = "id_part"))
35 @ToString.Exclude
36 List<Part> partList;
37
38 public Order(Client user) {
39 this.order_status = "created";
40 this.user = user;
41 this.date = LocalDateTime.now();
42 }
43
44 @Override
45 public boolean equals(Object o) {
46 if (this == o) return true;
47 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
48 Order order = (Order) o;
49 return orderid != null && Objects.equals(orderid, order.orderid);
50 }
51
52 @Override
53 public int hashCode() {
54 return getClass().hashCode();
55 }
56}
Note: See TracBrowser for help on using the repository browser.