Open tae0y opened 1 year ago
@Data
@Entity
@Table(schema = "notification_keywords")
public class NotificationKeyword {
@Id
@NotNull
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
@ManyToOne
@JoinColumn(name="users_id")
private User registrants;
@NotNull
@Size(min = 1, max=10)
@Column(name = "keyword")
private String keyword;
@NotNull
@CreatedDate
@Column(name = "crated_at")
private LocalDateTime cratedAt;
}
@Data
@Entity
@Table(schema = "users")
public class User {
@OneToMany(fetch = FetchType.LAZY, mappedBy = "users")
private Set<NotificationKeyword> keywords;
}
@Data
@Entity
@Table(schema = "wish_lists")
public class WishList {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
@OneToOne(mappedBy="wish_lists")
private User registrant;
@NotNull
@ManyToMany
@JoinTable(
name = "wish_lists_goods",
joinColumns = @JoinColumn(name = "wish_lists_id"),
inverseJoinColumns = @JoinColumn(name = "goods_id"))
private Set<Product> product;
@NotNull
@CreatedDate
@Column(name = "crated_at")
private LocalDateTime cratedAt;
}
@Data
@Entity
@Table(schema = "users")
public class User {
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "users")
private WishList wishList;
}
@Data
@Entity
@Table(schema = "goods")
public class Product {
@ManyToMany
@JoinTable(
name = "wish_lists_goods",
joinColumns = @JoinColumn(name = "goods_id"),
inverseJoinColumns = @JoinColumn(name = "wish_lists_id"))
private Set<WishList> wishList;
}
@Data
@ToString
@Entity
@Table(schema = "price_offers")
public class PriceOffer {
@Id
@NotNull
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
@ManyToOne
@JoinColumn(name="users_id")
private User offerer;
@NotNull
@ManyToOne
@JoinColumn(name="goods_id")
private Product product;
@NotNull
@Column(name = "offered_price")
private BigDecimal price;
@NotNull
@Column(name = "accept_or_not")
private boolean accepted;
@NotNull
@CreatedDate
private LocalDateTime cratedAt;
}
@Data
@Entity
@Table(schema = "users")
public class User {
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "users")
private Set<PriceOffer> priceOffers;
}
@Data
@Entity
@Table(schema = "goods")
public class Product {
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "goods")
private Set<PriceOffer> priceOffers;
}
import javax.persistence.*; import java.time.LocalDateTime;
@Data @ToString //lazyloading과 tostring주의! @Entity @Table(schema = "goods") public class Product { @Id @GeneratedValue(strategy = GenerationType.AUTO) //TODO: ID 생성정책이 정해지면 정책에 따라 바꾸기 @Column(name = "id", nullable = false) private Long id;
}
class User{ } class Address{ } class PriceOffer{ }