Skip to content

Commit

Permalink
refactor: 모집 공고 수정 시에도 즉각적으로 상태 반영되도록 수정 #353
Browse files Browse the repository at this point in the history
  • Loading branch information
SongJaeHoonn committed Jun 25, 2024
1 parent a12fb03 commit 721951f
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public Long updateRecruitment(Long recruitmentId, RecruitmentUpdateRequestDto re
Recruitment recruitment = getRecruitmentByIdOrThrow(recruitmentId);
recruitment.update(requestDto);
validationService.checkValid(recruitment);
updateRecruitmentStatusByRecruitment(recruitment);
return recruitmentRepository.save(recruitment).getId();
}

Expand All @@ -92,9 +93,12 @@ public void updateRecruitmentStatus(){
public void updateRecruitmentStatusByRecruitment(Recruitment recruitment){
TransactionStatus transactionStatus = transactionManager.getTransaction(transactionDefinition);
LocalDateTime now = LocalDateTime.now();
RecruitmentStatus newStatus = now.isBefore(recruitment.getStartDate())
? RecruitmentStatus.UPCOMING : now.isAfter(recruitment.getEndDate())
? RecruitmentStatus.CLOSED : RecruitmentStatus.OPEN;
RecruitmentStatus newStatus = RecruitmentStatus.OPEN;
if(now.isBefore(recruitment.getStartDate())){
newStatus = RecruitmentStatus.UPCOMING;
}else if(now.isAfter(recruitment.getEndDate())){
newStatus = RecruitmentStatus.CLOSED;
}
recruitment.updateStatus(newStatus);
entityManager.merge(recruitment);
transactionManager.commit(transactionStatus);
Expand Down

0 comments on commit 721951f

Please sign in to comment.