Skip to content

Commit

Permalink
#266 [refactor] currentdate 삭제, isExpired 도메인으로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
pkl0912 committed Mar 1, 2024
1 parent cef2148 commit c66667e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ public LocalDate getExpiredDate(){
LocalDate expiredDate = getCreatedAt().plusDays(7).toLocalDate();
return expiredDate;
}

public boolean isExpired() {
LocalDate expiredDate = getCreatedAt().plusDays(7).toLocalDate();
LocalDate currentDate = LocalDate.now();

return currentDate.isAfter(expiredDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -43,7 +42,6 @@ public class HairModelApplicationRetrieveService {
private final S3Service s3Service;
private final PreferHairStyleJpaRepository preferHairStyleJpaRepository;
private final HairServiceRecordJpaRepository hairServiceRecordJpaRepository;
private final LocalDate currentDate = LocalDate.now();

public DesignerMainResponse getDesignerMainInfo(final Long designerId, final int page, final int size) {

Expand Down Expand Up @@ -123,7 +121,7 @@ private Page<HairModelApplication> findApplicationsByPaging(final int page, fina

Page<HairModelApplication> nonExpiredApplications = applicationPage
.stream()
.filter(application -> !isExpired(application))
.filter(application -> !application.isExpired())
.collect(Collectors.collectingAndThen(
Collectors.toList(),
list -> new PageImpl<>(list, pageRequest, list.size())
Expand Down Expand Up @@ -163,9 +161,5 @@ private HairModelApplicationResponse getApplicationResponse(final HairModelAppli
);
return applicationResponse;
}

private boolean isExpired(final HairModelApplication application) {
return application.getExpiredDate().isBefore(currentDate);
}
}

0 comments on commit c66667e

Please sign in to comment.