65 lines
1.8 KiB
Java
65 lines
1.8 KiB
Java
package com.krylov.refound.entity;
|
||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||
import com.krylov.refound.enums.PostCategory;
|
||
import com.krylov.refound.enums.PostStatus;
|
||
import com.krylov.refound.enums.PostType;
|
||
import jakarta.persistence.CascadeType;
|
||
import jakarta.persistence.Column;
|
||
import jakarta.persistence.Entity;
|
||
import jakarta.persistence.EnumType;
|
||
import jakarta.persistence.Enumerated;
|
||
import jakarta.persistence.GeneratedValue;
|
||
import jakarta.persistence.GenerationType;
|
||
import jakarta.persistence.Id;
|
||
import jakarta.persistence.ManyToOne;
|
||
import jakarta.persistence.OneToMany;
|
||
import jakarta.persistence.Table;
|
||
import java.time.LocalDateTime;
|
||
import java.util.ArrayList;
|
||
import java.util.List;
|
||
import lombok.Getter;
|
||
import lombok.Setter;
|
||
|
||
@Entity
|
||
@Table(name = "posts")
|
||
@Getter
|
||
@Setter
|
||
public class Post {
|
||
@Id
|
||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||
private Long id;
|
||
|
||
private String title;
|
||
@Column(length = 2000)
|
||
private String description;
|
||
@Enumerated(EnumType.STRING)
|
||
private PostCategory category;
|
||
private String city;
|
||
private String district;
|
||
private Double latitude;
|
||
private Double longitude;
|
||
private LocalDateTime createdAt;
|
||
private String phone;
|
||
// В БД колонка boolean NOT NULL (changelog 013). Строка была рассинхронизирована
|
||
// со схемой и ломала ddl-auto: validate.
|
||
@Column(name = "rules_accepted", nullable = false)
|
||
private Boolean rulesAccepted = false;
|
||
private Boolean isReward;
|
||
private String reward;
|
||
|
||
@Enumerated(EnumType.STRING)
|
||
private PostType type;
|
||
|
||
@Enumerated(EnumType.STRING)
|
||
private PostStatus status;
|
||
|
||
@ManyToOne
|
||
@JsonIgnore
|
||
private User user;
|
||
|
||
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
|
||
private List<Image> images = new ArrayList<>();
|
||
|
||
}
|