content: package ru.amplicode.orders.domain;
  
  import jakarta.persistence.*;
  import lombok.Getter;
  import lombok.Setter;
  import org.springframework.data.annotation.CreatedDate;
  import org.springframework.data.jpa.domain.support.AuditingEntityListener;
  
  import java.math.BigDecimal;
  import java.time.Instant;
  import java.util.ArrayList;
  import java.util.List;
  
  @Getter
  @Setter
  @Entity
  @Table(name = "order_")
  @EntityListeners(AuditingEntityListener.class)
  public class Order {
      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "order_seq")
      @SequenceGenerator(name = "order_seq")
      @Column(name = "id", nullable = false)
      private Long id;
  
      @ManyToOne(fetch = FetchType.LAZY, optional = false)
      @JoinColumn(name = "customer_id", nullable = false)
      private Customer customer;
  
      @Enumerated(EnumType.STRING)
      @Column(name = "order_status", nullable = false)
      private OrderStatus orderStatus = OrderStatus.NEW;
  
      @OneToMany(mappedBy = "order", orphanRemoval = true, cascade = CascadeType.REMOVE)
      private List<OrderLine> orderLines = new ArrayList<>();
  
      @Column(name = "sum", nullable = false, precision = 19, scale = 2)
      private BigDecimal sum = BigDecimal.ZERO;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "city_id", nullable = false)
      private City city;
  
      @CreatedDate
      @Column(name = "created_date")
      private Instant createdDate;
  }
  