Skip to content

Commit

Permalink
#13 feat: 예약 관련 엔티티 수정
Browse files Browse the repository at this point in the history
- 수정된 ERD에 따라 예약 및 예약 객실 엔티티 수정
- Payment 엔티티 추가
  • Loading branch information
matrixpower1004 committed Dec 29, 2023
1 parent d4047a2 commit 649860e
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.backoffice.upjuyanolja.domain.payment;

import com.backoffice.upjuyanolja.domain.reservation.entity.PayMethod;
import com.backoffice.upjuyanolja.global.common.BaseTime;
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 lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Comment;
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
public class Payment extends BaseTime {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Comment("결제 식별자")
private Long id;

@Column(nullable = false, name = "pay_method")
@Enumerated(value = EnumType.STRING)
@Comment("결제 수단")
private PayMethod payMethod;


@Column(nullable = false, name = "final_price")
@Comment("최종 가격")
private int finalPrice;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import com.backoffice.upjuyanolja.domain.coupon.entity.Coupon;
import com.backoffice.upjuyanolja.domain.member.entity.Member;
import com.backoffice.upjuyanolja.domain.payment.Payment;
import com.backoffice.upjuyanolja.domain.room.entity.Room;
import com.backoffice.upjuyanolja.global.common.BaseTime;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
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.OneToOne;
import java.time.LocalDate;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -30,39 +30,55 @@ public class Reservation extends BaseTime {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Comment("예약 식별자")
private Long id;
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@Comment("예약 숙소 식별자")
private ReservationRoom reservationRoom;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false, name = "member_id")
@Comment("회원 식별자")
private Member member;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "coupon_id")
@Comment("쿠폰 식별자")
private Coupon coupon;
@Column(nullable = false)
@Enumerated(value = EnumType.STRING)
@Comment("결제 수단")
private PayMethod payMethod;
@Column(nullable = false)
@Comment("결제 금액")
private int price;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "payment_id")
@Comment("결제 식별자")
private Payment payment;

@Column(nullable = false, name = "visitor_name")
@Comment("방문자명")
private String visitorName;

@Column(nullable = false, name = "visitor_phone")
@Comment("방문자 전화번호")
private String visitorPhone;

@Column(nullable = false, name = "start_date")
@Comment("입실 일자")
private LocalDate startDate;

@Column(nullable = false, name = "end_date")
@Comment("퇴실 일자")
private LocalDate endDate;

@Builder
public Reservation(
Long id,
ReservationRoom reservationRoom,
public Reservation(Long id,
Member member,
Coupon coupon,
PayMethod payMethod,
int price
) {
Payment payment,
String visitorName,
String visitorPhone,
LocalDate startDate,
LocalDate endDate)
{
this.id = id;
this.reservationRoom = reservationRoom;
this.member = member;
this.coupon = coupon;
this.payMethod = payMethod;
this.price = price;
this.payment = payment;
this.visitorName = visitorName;
this.visitorPhone = visitorPhone;
this.startDate = startDate;
this.endDate = endDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.time.LocalDate;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -24,50 +23,28 @@ public class ReservationRoom extends BaseTime {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Comment("숙소 식별자")
@Comment("예약 객실 식별자")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "reservation_id")
@Comment("예약 식별자")
private Reservation reservation;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "room_id")
@Comment("객실 식별자")
private Room room;

@Column(nullable = false)
@Comment("가격")
@Comment("객실가격") // 예약 결제 할 당시의 객실 가격
private int price;
@Column(nullable = false)
@Comment("숙박 시작일")
private LocalDate startDate;
@Column(nullable = false)
@Comment("숙박 마지막일")
private LocalDate endDate;
@Column(nullable = false)
@Comment("방문자명")
private String visitorName;
@Column(nullable = false)
@Comment("방문자 전화번호")
private String visitorPhone;

@Builder
public ReservationRoom(
Long id,
Reservation reservation,
Room room,
int price,
LocalDate startDate,
LocalDate endDate,
String visitorName,
String visitorPhone
) {
public ReservationRoom(Long id, Reservation reservation, Room room, int price) {
this.id = id;
this.reservation = reservation;
this.room = room;
this.price = price;
this.startDate = startDate;
this.endDate = endDate;
this.visitorName = visitorName;
this.visitorPhone = visitorPhone;
}
}

0 comments on commit 649860e

Please sign in to comment.