Skip to content

Commit

Permalink
feat: OfferingEntity에 칼럼 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
masonkimseoul committed Aug 14, 2024
1 parent fd39e38 commit b5be00c
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 400 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public int calculateDividedPrice() {
public double calculateDiscountRate() {
return (double) (originPrice - totalPrice / totalCount) / originPrice;
}
// TODO : 소수점 밑 둘째 자리에서 반올림

public void validateOriginPrice() {
int dividedPrice = totalPrice / totalCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.zzang.chongdae.offering.domain.OfferingMeeting;
import com.zzang.chongdae.offering.domain.OfferingPrice;
import com.zzang.chongdae.offering.domain.OfferingCondition;
import com.zzang.chongdae.offering.domain.OfferingStatus;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
Expand Down Expand Up @@ -63,7 +64,7 @@ public class OfferingEntity extends BaseTimeEntity {

private String meetingAddressDetail;

private String meetingAddressDong; // TODO: nullable?
private String meetingAddressDong;

@NotNull
@Positive
Expand All @@ -83,6 +84,13 @@ public class OfferingEntity extends BaseTimeEntity {
@Positive
private Integer originPrice;

@Positive
private Double discountRate;

@NotNull
@Enumerated(EnumType.STRING)
private OfferingStatus offeringStatus;

@NotNull
@Enumerated(EnumType.STRING)
private CommentRoomStatus roomStatus;
Expand All @@ -91,10 +99,11 @@ public OfferingEntity(MemberEntity member, String title, String description, Str
LocalDateTime deadline, String meetingAddress, String meetingAddressDetail,
String meetingAddressDong,
Integer totalCount, Integer currentCount, Boolean isManualConfirmed, Integer totalPrice,
Integer originPrice, CommentRoomStatus roomStatus) {
Integer originPrice, Double discountRate,
OfferingStatus offeringStatus, CommentRoomStatus roomStatus) {
this(null, member, title, description, thumbnailUrl, productUrl, deadline, meetingAddress,
meetingAddressDetail, meetingAddressDong, totalCount, currentCount, isManualConfirmed, totalPrice,
originPrice, roomStatus);
originPrice, discountRate, offeringStatus, roomStatus);
}

public void participate() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.zzang.chongdae.offering.service.dto;

import static com.zzang.chongdae.offering.domain.CommentRoomStatus.GROUPING;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzang.chongdae.member.repository.entity.MemberEntity;
import com.zzang.chongdae.offering.domain.CommentRoomStatus;
import com.zzang.chongdae.offering.domain.OfferingStatus;
import com.zzang.chongdae.offering.repository.entity.OfferingEntity;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand Down Expand Up @@ -41,6 +41,7 @@ public record OfferingSaveRequest(@NotBlank
public OfferingEntity toEntity(MemberEntity member) {
return new OfferingEntity(member, title, description, thumbnailUrl, productUrl, deadline, meetingAddress,
meetingAddressDetail, meetingAddressDong, totalCount, 1, false,
totalPrice, originPrice, GROUPING);
totalPrice, originPrice, 33.3, OfferingStatus.AVAILABLE, CommentRoomStatus.GROUPING);
// TODO : 각자 맡은 팀에서 계산하는 로직 생각하기, 객체로 빼서 만드셈~
}
}
Loading

0 comments on commit b5be00c

Please sign in to comment.