-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: Condition과 Status 이름 변경 * refactor: 사용하지 않는 DTO 제거 * feat: OfferingEntity에 칼럼 추가
- Loading branch information
1 parent
d32a53d
commit e036152
Showing
15 changed files
with
518 additions
and
519 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
73 changes: 56 additions & 17 deletions
73
backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingCondition.java
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,27 +1,66 @@ | ||
package com.zzang.chongdae.offering.domain; | ||
|
||
public enum OfferingCondition { | ||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
FULL, | ||
IMMINENT, | ||
CONFIRMED, | ||
AVAILABLE; | ||
@Getter | ||
@AllArgsConstructor | ||
public class OfferingCondition { | ||
|
||
public static OfferingCondition decideBy(OfferingStatus offeringStatus) { | ||
if (offeringStatus.isManualConfirmed() || offeringStatus.isAutoConfirmed() | ||
|| (offeringStatus.isDeadlineOver() && offeringStatus.isCountNotFull())) { | ||
return CONFIRMED; | ||
} | ||
if (offeringStatus.isCountFull() && offeringStatus.isDeadlineNotOver()) { | ||
return FULL; | ||
} | ||
if (offeringStatus.isCountAlmostFull() || offeringStatus.isDeadlineAlmostOver()) { | ||
return IMMINENT; | ||
private final LocalDateTime deadline; | ||
private final int totalCount; | ||
private final boolean isManualConfirmed; | ||
private final int currentCount; | ||
|
||
public OfferingStatus decideOfferingStatus() { | ||
return OfferingStatus.decideBy(this); | ||
} | ||
|
||
public boolean isCountFull() { | ||
return this.totalCount == this.currentCount; | ||
} | ||
|
||
public boolean isCountNotFull() { | ||
return !isCountFull(); | ||
} | ||
|
||
public boolean isCountAlmostFull() { | ||
if (totalCount <= 3) { | ||
return (totalCount - currentCount) < 2; | ||
} | ||
return AVAILABLE; | ||
return (totalCount - currentCount) < 3; | ||
} | ||
|
||
public boolean isDeadlineAlmostOver() { | ||
LocalDateTime now = LocalDateTime.now(); | ||
LocalDateTime threshold = deadline.minusHours(6); | ||
return threshold.isBefore(now) && now.isBefore(deadline); // deadline - 6 < now < deadline | ||
} | ||
|
||
public boolean isDeadlineOver() { | ||
LocalDateTime now = LocalDateTime.now(); | ||
return now.isAfter(this.deadline) || now.isEqual(this.deadline); | ||
} | ||
|
||
public boolean isDeadlineNotOver() { | ||
return LocalDateTime.now().isBefore(this.deadline); | ||
} | ||
|
||
public boolean isAutoConfirmed() { | ||
return isCountFull() && isDeadlineOver(); | ||
} | ||
|
||
public boolean isManualConfirmed() { | ||
return isManualConfirmed; | ||
} | ||
|
||
public boolean isOpen() { | ||
return this == AVAILABLE || this == IMMINENT; | ||
OfferingStatus offeringStatus = decideOfferingStatus(); | ||
return offeringStatus.isOpen(); | ||
} | ||
|
||
public boolean isClosed() { | ||
return !isOpen(); | ||
} | ||
} |
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
73 changes: 17 additions & 56 deletions
73
backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingStatus.java
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,66 +1,27 @@ | ||
package com.zzang.chongdae.offering.domain; | ||
|
||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
public enum OfferingStatus { | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class OfferingStatus { | ||
FULL, | ||
IMMINENT, | ||
CONFIRMED, | ||
AVAILABLE; | ||
|
||
private final LocalDateTime deadline; | ||
private final int totalCount; | ||
private final boolean isManualConfirmed; | ||
private final int currentCount; | ||
|
||
public OfferingCondition decideOfferingCondition() { | ||
return OfferingCondition.decideBy(this); | ||
} | ||
|
||
public boolean isCountFull() { | ||
return this.totalCount == this.currentCount; | ||
} | ||
|
||
public boolean isCountNotFull() { | ||
return !isCountFull(); | ||
} | ||
|
||
public boolean isCountAlmostFull() { | ||
if (totalCount <= 3) { | ||
return (totalCount - currentCount) < 2; | ||
public static OfferingStatus decideBy(OfferingCondition offeringCondition) { | ||
if (offeringCondition.isManualConfirmed() || offeringCondition.isAutoConfirmed() | ||
|| (offeringCondition.isDeadlineOver() && offeringCondition.isCountNotFull())) { | ||
return CONFIRMED; | ||
} | ||
return (totalCount - currentCount) < 3; | ||
} | ||
|
||
public boolean isDeadlineAlmostOver() { | ||
LocalDateTime now = LocalDateTime.now(); | ||
LocalDateTime threshold = deadline.minusHours(6); | ||
return threshold.isBefore(now) && now.isBefore(deadline); // deadline - 6 < now < deadline | ||
} | ||
|
||
public boolean isDeadlineOver() { | ||
LocalDateTime now = LocalDateTime.now(); | ||
return now.isAfter(this.deadline) || now.isEqual(this.deadline); | ||
} | ||
|
||
public boolean isDeadlineNotOver() { | ||
return LocalDateTime.now().isBefore(this.deadline); | ||
} | ||
|
||
public boolean isAutoConfirmed() { | ||
return isCountFull() && isDeadlineOver(); | ||
} | ||
|
||
public boolean isManualConfirmed() { | ||
return isManualConfirmed; | ||
if (offeringCondition.isCountFull() && offeringCondition.isDeadlineNotOver()) { | ||
return FULL; | ||
} | ||
if (offeringCondition.isCountAlmostFull() || offeringCondition.isDeadlineAlmostOver()) { | ||
return IMMINENT; | ||
} | ||
return AVAILABLE; | ||
} | ||
|
||
public boolean isOpen() { | ||
OfferingCondition offeringCondition = decideOfferingCondition(); | ||
return offeringCondition.isOpen(); | ||
} | ||
|
||
public boolean isClosed() { | ||
return !isOpen(); | ||
return this == AVAILABLE || this == IMMINENT; | ||
} | ||
} |
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
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
4 changes: 0 additions & 4 deletions
4
.../src/main/java/com/zzang/chongdae/offering/service/dto/OfferingUploadedImageResponse.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.