From 2192ebb11b4e952882f8beb181be73330d1e08c7 Mon Sep 17 00:00:00 2001 From: yoonsseo Date: Wed, 14 Aug 2024 14:23:28 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[refact]=20=EB=A6=AC=ED=81=AC=EB=A3=A8?= =?UTF-8?q?=ED=8C=85=20=EA=B8=B0=EA=B0=84=20=EC=9D=B4=EC=A0=84=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD=20#192?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/subscriber/exception/InvalidAction.java | 13 ------------- .../subscriber/exception/InvalidActionBefore.java | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 src/main/java/ceos/backend/domain/subscriber/exception/InvalidAction.java create mode 100644 src/main/java/ceos/backend/domain/subscriber/exception/InvalidActionBefore.java diff --git a/src/main/java/ceos/backend/domain/subscriber/exception/InvalidAction.java b/src/main/java/ceos/backend/domain/subscriber/exception/InvalidAction.java deleted file mode 100644 index 6fbbf4b..0000000 --- a/src/main/java/ceos/backend/domain/subscriber/exception/InvalidAction.java +++ /dev/null @@ -1,13 +0,0 @@ -package ceos.backend.domain.subscriber.exception; - - -import ceos.backend.global.error.BaseErrorException; - -public class InvalidAction extends BaseErrorException { - - public static final InvalidAction EXCEPTION = new InvalidAction(); - - private InvalidAction() { - super(SubscriberErrorCode.INVALID_ACTION); - } -} diff --git a/src/main/java/ceos/backend/domain/subscriber/exception/InvalidActionBefore.java b/src/main/java/ceos/backend/domain/subscriber/exception/InvalidActionBefore.java new file mode 100644 index 0000000..4895b83 --- /dev/null +++ b/src/main/java/ceos/backend/domain/subscriber/exception/InvalidActionBefore.java @@ -0,0 +1,13 @@ +package ceos.backend.domain.subscriber.exception; + + +import ceos.backend.global.error.BaseErrorException; + +public class InvalidActionBefore extends BaseErrorException { + + public static final InvalidActionBefore EXCEPTION = new InvalidActionBefore(); + + private InvalidActionBefore() { + super(SubscriberErrorCode.INVALID_ACTION_BEFORE); + } +} From 6a63698c262e1f44773902a6efa322d7fd6f83a7 Mon Sep 17 00:00:00 2001 From: yoonsseo Date: Wed, 14 Aug 2024 14:24:47 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[feat]=20=EB=A6=AC=ED=81=AC=EB=A3=A8?= =?UTF-8?q?=ED=8C=85=20=EA=B8=B0=EA=B0=84=20=EC=9D=B4=ED=9B=84=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#192?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subscriber/exception/InvalidActionAfter.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/ceos/backend/domain/subscriber/exception/InvalidActionAfter.java diff --git a/src/main/java/ceos/backend/domain/subscriber/exception/InvalidActionAfter.java b/src/main/java/ceos/backend/domain/subscriber/exception/InvalidActionAfter.java new file mode 100644 index 0000000..2f0c788 --- /dev/null +++ b/src/main/java/ceos/backend/domain/subscriber/exception/InvalidActionAfter.java @@ -0,0 +1,13 @@ +package ceos.backend.domain.subscriber.exception; + + +import ceos.backend.global.error.BaseErrorException; + +public class InvalidActionAfter extends BaseErrorException { + + public static final InvalidActionAfter EXCEPTION = new InvalidActionAfter(); + + private InvalidActionAfter() { + super(SubscriberErrorCode.INVALID_ACTION_AFTER); + } +} From 98707ff14356849f5950d984d690ca1c9306bc14 Mon Sep 17 00:00:00 2001 From: yoonsseo Date: Wed, 14 Aug 2024 14:27:42 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[refact]=20=EB=A6=AC=ED=81=AC=EB=A3=A8?= =?UTF-8?q?=ED=8C=85=20=EA=B8=B0=EA=B0=84=20=EC=9D=B4=EC=99=B8=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EC=B6=94=EA=B0=80=20#192?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/subscriber/exception/SubscriberErrorCode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/ceos/backend/domain/subscriber/exception/SubscriberErrorCode.java b/src/main/java/ceos/backend/domain/subscriber/exception/SubscriberErrorCode.java index 06ada2e..33df5c7 100644 --- a/src/main/java/ceos/backend/domain/subscriber/exception/SubscriberErrorCode.java +++ b/src/main/java/ceos/backend/domain/subscriber/exception/SubscriberErrorCode.java @@ -13,7 +13,8 @@ public enum SubscriberErrorCode implements BaseErrorCode { /* Data */ - INVALID_ACTION(BAD_REQUEST, "SUBSCRIBER_400_1", "리쿠르팅 시작 전입니다."), + INVALID_ACTION_BEFORE(BAD_REQUEST, "SUBSCRIBER_400_1", "리쿠르팅 시작 전입니다."), + INVALID_ACTION_AFTER(BAD_REQUEST, "SUBSCRIBER_400_2", "리쿠르팅 마감 후입니다."), DUPLICATE_DATA(CONFLICT, "SUBSCRIBER_409_1", "이미 존재하는 데이터입니다"); private HttpStatus status; From 7d5dbdb2eb6252767a684b035ca15bae8463dd02 Mon Sep 17 00:00:00 2001 From: yoonsseo Date: Wed, 14 Aug 2024 14:28:45 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[refact]=20=EB=A6=AC=ED=81=AC=EB=A3=A8?= =?UTF-8?q?=ED=8C=85=20=EA=B8=B0=EA=B0=84=20=EC=9D=B4=EC=99=B8=20=EC=A0=91?= =?UTF-8?q?=EA=B7=BC=EC=97=90=20=EB=8C=80=ED=95=B4=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20#192?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/subscriber/helper/SubscriberHelper.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/ceos/backend/domain/subscriber/helper/SubscriberHelper.java b/src/main/java/ceos/backend/domain/subscriber/helper/SubscriberHelper.java index fbfa706..946fe55 100644 --- a/src/main/java/ceos/backend/domain/subscriber/helper/SubscriberHelper.java +++ b/src/main/java/ceos/backend/domain/subscriber/helper/SubscriberHelper.java @@ -1,7 +1,8 @@ package ceos.backend.domain.subscriber.helper; import ceos.backend.domain.subscriber.exception.DuplicateData; -import ceos.backend.domain.subscriber.exception.InvalidAction; +import ceos.backend.domain.subscriber.exception.InvalidActionAfter; +import ceos.backend.domain.subscriber.exception.InvalidActionBefore; import ceos.backend.domain.subscriber.repository.SubscriberRepository; import ceos.backend.global.common.dto.AwsSESRecruitMail; import ceos.backend.global.common.event.Event; @@ -22,9 +23,11 @@ public void validateEmail(String email) { } } - public void validateDate(LocalDate date, LocalDate now) { - if (!date.equals(now)) { - throw InvalidAction.EXCEPTION; + public void validateDate(LocalDate startDate, LocalDate endDate, LocalDate now) { + if (startDate.isBefore(now)) { + throw InvalidActionBefore.EXCEPTION; + } else if (endDate.isAfter(now)) { + throw InvalidActionAfter.EXCEPTION; } } From b242de7ed8e37844e6089716615e1cef4da10e6d Mon Sep 17 00:00:00 2001 From: yoonsseo Date: Wed, 14 Aug 2024 14:31:07 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[refact]=20=EB=A6=AC=ED=81=AC=EB=A3=A8?= =?UTF-8?q?=ED=8C=85=20=EB=A7=88=EA=B0=90=20=EA=B8=B0=ED=95=9C=20=EB=B0=9B?= =?UTF-8?q?=EC=95=84=EC=98=A4=EB=8A=94=20=EB=B6=80=EB=B6=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#192?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/subscriber/service/SubscriberService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/ceos/backend/domain/subscriber/service/SubscriberService.java b/src/main/java/ceos/backend/domain/subscriber/service/SubscriberService.java index 9e03fbc..47068c3 100644 --- a/src/main/java/ceos/backend/domain/subscriber/service/SubscriberService.java +++ b/src/main/java/ceos/backend/domain/subscriber/service/SubscriberService.java @@ -35,12 +35,13 @@ public void subscribeMail(SubscribeRequest subscribeRequest) { @Transactional(readOnly = true) public void sendRecruitingMail() { - LocalDate date = recruitmentRepository.findAll().get(0).getStartDateDoc().toLocalDate(); + LocalDate startDate = recruitmentRepository.findAll().get(0).getStartDateDoc().toLocalDate(); + LocalDate endDate = recruitmentRepository.findAll().get(0).getEndDateDoc().toLocalDate(); LocalDate now = LocalDate.now(); List subscribers = subscriberRepository.findAll(); - //리쿠르팅 시작 날짜 검증 - subscriberHelper.validateDate(date, now); + //리쿠르팅 기간 검증 + subscriberHelper.validateDate(startDate, endDate, now); // 메일 보내기 for (Subscriber subscriber : subscribers) { From dcbbaab22157a88b8fe7ad35d1dcc896552516f0 Mon Sep 17 00:00:00 2001 From: yoonsseo Date: Wed, 14 Aug 2024 15:02:34 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[refact]=20=EB=A6=AC=ED=81=AC=EB=A3=A8?= =?UTF-8?q?=ED=8C=85=20=EA=B8=B0=EA=B0=84=20=EC=9D=B4=EC=99=B8=20=EC=A0=91?= =?UTF-8?q?=EA=B7=BC=EC=97=90=20=EB=8C=80=ED=95=B4=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20#192?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/subscriber/helper/SubscriberHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ceos/backend/domain/subscriber/helper/SubscriberHelper.java b/src/main/java/ceos/backend/domain/subscriber/helper/SubscriberHelper.java index 946fe55..eac1488 100644 --- a/src/main/java/ceos/backend/domain/subscriber/helper/SubscriberHelper.java +++ b/src/main/java/ceos/backend/domain/subscriber/helper/SubscriberHelper.java @@ -24,9 +24,9 @@ public void validateEmail(String email) { } public void validateDate(LocalDate startDate, LocalDate endDate, LocalDate now) { - if (startDate.isBefore(now)) { + if (now.isBefore(startDate)) { throw InvalidActionBefore.EXCEPTION; - } else if (endDate.isAfter(now)) { + } else if (now.isAfter(endDate)) { throw InvalidActionAfter.EXCEPTION; } }