Skip to content

Commit

Permalink
Merge pull request #24 from 1223v/test
Browse files Browse the repository at this point in the history
Feat: 쿠폰 및 쿠폰 메뉴, 이벤트 엔티티 추가
  • Loading branch information
marinesnow34 authored Nov 17, 2023
2 parents adb1bc1 + 8f54587 commit 29db2cc
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@Builder
@Table(name = "CEO")
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "CEO")
@Slf4j
public class CeoInfo extends BaseTimeEntity {

Expand Down
51 changes: 51 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/Coupon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.readyvery.readyverydemo.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@Entity
@Builder
@Table(name = "COUPON")
@AllArgsConstructor
@NoArgsConstructor
@Slf4j
public class Coupon extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "coupon_idx")
private Long id;

// 사용 여부
@Column(name = "used")
private boolean isUsed;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "coupon_detail_idx")
private CouponDetail couponDetail;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_idx")
private UserInfo userInfo;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "store_idx")
private Store store;

// @OneToOne(mappedBy = "coupon", fetch = LAZY)
// private Order order;

}
65 changes: 65 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.readyvery.readyverydemo.domain;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@Entity
@Builder
@Table(name = "COUPONDETAIL")
@AllArgsConstructor
@NoArgsConstructor
@Slf4j
public class CouponDetail extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "coupon_detail_idx")
private Long id;

// 할인 가격
@Column
private Long salePrice;

// 쿠폰 이름
@Column
private String name;

// 만료일
@Column
private LocalDateTime expire;

// 발행처 레디베리 발행(0) / 사장님 발행(ceo_idx)
@Column
private Long publisher;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "event_idx")
private Event event;

@Builder.Default
@OneToMany(mappedBy = "couponDetail", cascade = CascadeType.ALL)
private List<CouponMenu> couponMenus = new ArrayList<CouponMenu>();

@Builder.Default
@OneToMany(mappedBy = "couponDetail", cascade = CascadeType.ALL)
private List<Coupon> coupons = new ArrayList<Coupon>();

}
39 changes: 39 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.readyvery.readyverydemo.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@Entity
@Builder
@Table(name = "COUPONMENU")
@AllArgsConstructor
@NoArgsConstructor
@Slf4j
public class CouponMenu extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "coupon_menu_idx")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "coupon_detail_idx")
private CouponDetail couponDetail;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "foodie_idx")
private Foodie foodie;

}
46 changes: 46 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.readyvery.readyverydemo.domain;

import java.util.ArrayList;
import java.util.List;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@Entity
@Builder
@Table(name = "EVENT")
@AllArgsConstructor
@NoArgsConstructor
@Slf4j
public class Event extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "event_idx")
private Long id;

// 이벤트 베너 이미지 url
@Column(name = "banner_img")
private String bannerImg;

// 이벤트 메인 이미지 url
@Column(name = "main_img")
private String mainImg;

@Builder.Default
@OneToMany(mappedBy = "event", cascade = CascadeType.ALL)
private List<CouponDetail> coupons = new ArrayList<CouponDetail>();

}
8 changes: 3 additions & 5 deletions src/main/java/com/readyvery/readyverydemo/domain/Foodie.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@Table(name = "FOODIE")
@AllArgsConstructor
@Slf4j
public class Foodie extends BaseTimeEntity {

Expand Down Expand Up @@ -80,4 +75,7 @@ public class Foodie extends BaseTimeEntity {
@OneToMany(mappedBy = "foodie", cascade = CascadeType.ALL)
private List<CartItem> cartItems = new ArrayList<CartItem>();

@OneToMany(mappedBy = "foodie", cascade = CascadeType.ALL)
private List<CouponMenu> couponMenus = new ArrayList<CouponMenu>();

}

0 comments on commit 29db2cc

Please sign in to comment.