-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added more fields and methods to domain classes - fixed import statements (from * to individual import)
- Loading branch information
1 parent
64efe13
commit 405fa00
Showing
4 changed files
with
76 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,46 @@ | ||
package com.f_lab.la_planete.domain; | ||
|
||
import com.f_lab.la_planete.domain.base.BaseEntity; | ||
import jakarta.persistence.*; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import static jakarta.persistence.FetchType.LAZY; | ||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
import static lombok.AccessLevel.PRIVATE; | ||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Entity | ||
@Getter | ||
@Getter @Setter(PRIVATE) | ||
@NoArgsConstructor(access = PROTECTED) | ||
@Table(name = "payments") | ||
public class Payment extends BaseEntity { | ||
|
||
@Id @GeneratedValue(strategy = IDENTITY) | ||
private Long id; | ||
|
||
private BigDecimal amount; | ||
private BigDecimal totalCost; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private PaymentStatus status; | ||
|
||
@OneToOne(mappedBy = "payment", fetch = LAZY) | ||
private Order order; | ||
|
||
public static Payment of(BigDecimal totalCost, Order order) { | ||
Payment payment = new Payment(); | ||
payment.setTotalCost(totalCost); | ||
payment.setOrder(order); | ||
payment.setStatus(PaymentStatus.READY); | ||
return payment; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters