From 721951fb8ada888b6f35ef2745f700f614e5be52 Mon Sep 17 00:00:00 2001 From: JaeHoonSong <128021502+SongJaeHoonn@users.noreply.github.com> Date: Tue, 25 Jun 2024 21:33:08 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=AA=A8=EC=A7=91=20=EA=B3=B5?= =?UTF-8?q?=EA=B3=A0=20=EC=88=98=EC=A0=95=20=EC=8B=9C=EC=97=90=EB=8F=84=20?= =?UTF-8?q?=EC=A6=89=EA=B0=81=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EB=B0=98=EC=98=81=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#353?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recruitment/application/RecruitmentService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/page/clab/api/domain/recruitment/application/RecruitmentService.java b/src/main/java/page/clab/api/domain/recruitment/application/RecruitmentService.java index 76a48b651..4ff344aa0 100644 --- a/src/main/java/page/clab/api/domain/recruitment/application/RecruitmentService.java +++ b/src/main/java/page/clab/api/domain/recruitment/application/RecruitmentService.java @@ -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(); } @@ -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);