Skip to content

Commit

Permalink
fix(bill): bill 생성일 추가 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
ehBeak committed Nov 4, 2023
1 parent f4bcb88 commit 79550a6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ public class GetBillResponse {
private LocalDate billPaymentDate;
@JsonProperty("bill_memo")
private String billMemo;
@JsonProperty("register_date")
private LocalDate createdAt;

public GetBillResponse(Bill bill) {
this.billCategory = bill.getBillCategory().getTitle();
this.billPaymentAmount = bill.getBillPayment().setScale(0, RoundingMode.FLOOR);
this.billImageUrl = bill.getBillCategory().getImgUrl();
this.billPaymentDate = bill.getBillPaymentDate();
this.billMemo = bill.getBillMemo();
this.createdAt = bill.getCreatedAt().toLocalDate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public Bill mapToDomainEntity(BillJpaEntity billJpaEntity) {
.billMemo(billJpaEntity.getBillMemo())
.billRegister(getUser(billJpaEntity.getBillRegisterJpaEntity()))
.household(getHousehold(billJpaEntity.getHouseHoldJpaEntity()))
.createdAt(billJpaEntity.getCreatedAt())
.build();
}

Expand All @@ -52,6 +53,7 @@ public BillJpaEntity mapToJpaEntity(Bill bill) {
.billMemo(bill.getBillMemo())
.billRegisterJpaEntity(userMapper.mapToJpaEntity(bill.getBillRegister()))
.houseHoldJpaEntity(householdMapper.mapToJpaEntity(bill.getHousehold()))
.createdAt(bill.getCreatedAt())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
import jakarta.persistence.Table;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;

@Entity
@Getter
Expand All @@ -33,6 +35,9 @@ public class BillJpaEntity {
private String billStore;
private String billMemo;

@CreationTimestamp
private LocalDateTime createdAt;

@Enumerated(EnumType.STRING)
private BillCategory billCategory;

Expand All @@ -47,7 +52,7 @@ public class BillJpaEntity {
@Builder
public BillJpaEntity(Long billId, LocalDate billPaymentDate, BigDecimal billPayment,
String billStore, BillCategory billCategory,
UserJpaEntity billRegisterJpaEntity, HouseHoldJpaEntity houseHoldJpaEntity, String billMemo) {
UserJpaEntity billRegisterJpaEntity, HouseHoldJpaEntity houseHoldJpaEntity, String billMemo, LocalDateTime createdAt) {
this.billId = billId;
this.billPaymentDate = billPaymentDate;
this.billPayment = billPayment;
Expand All @@ -56,5 +61,6 @@ public BillJpaEntity(Long billId, LocalDate billPaymentDate, BigDecimal billPaym
this.billRegisterJpaEntity = billRegisterJpaEntity;
this.houseHoldJpaEntity = houseHoldJpaEntity;
this.billMemo = billMemo;
this.createdAt = createdAt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.connect.accountApp.domain.user.domain.model.User;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -20,12 +21,14 @@ public class Bill {
private BillCategory billCategory;
private String billMemo;

private LocalDateTime createdAt;

private User billRegister;
private Household household;

@Builder
public Bill(Long billId, LocalDate billPaymentDate, BigDecimal billPayment, String billStore,
BillCategory billCategory, User billRegister, Household household, String billMemo) {
BillCategory billCategory, User billRegister, Household household, String billMemo, LocalDateTime createdAt) {
this.billId = billId;
this.billPaymentDate = billPaymentDate;
this.billPayment = billPayment;
Expand All @@ -34,5 +37,6 @@ public Bill(Long billId, LocalDate billPaymentDate, BigDecimal billPayment, Stri
this.billRegister = billRegister;
this.household = household;
this.billMemo = billMemo;
this.createdAt = createdAt;
}
}

0 comments on commit 79550a6

Please sign in to comment.