From 47305ac35ba4b9370996789241b469d65a922af1 Mon Sep 17 00:00:00 2001 From: kseysh Date: Mon, 9 Sep 2024 16:19:11 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat=20-=20#186=20challenge=EC=97=90?= =?UTF-8?q?=EC=84=9C=20startDate=EB=A5=BC=20=EB=B3=80=EA=B2=BD=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/sopt/org/hmh/domain/challenge/domain/Challenge.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/sopt/org/hmh/domain/challenge/domain/Challenge.java b/src/main/java/sopt/org/hmh/domain/challenge/domain/Challenge.java index 0cadad54..82f6d2c6 100644 --- a/src/main/java/sopt/org/hmh/domain/challenge/domain/Challenge.java +++ b/src/main/java/sopt/org/hmh/domain/challenge/domain/Challenge.java @@ -50,4 +50,8 @@ private Challenge(Integer period, Long userId, Long goalTime, List this.apps = apps; this.startDate = startDate; } + + public void changeStartDate(LocalDate startDate) { + this.startDate = startDate; + } } \ No newline at end of file From d394f1a70b879ab23c7d70a99a39e2a65ee03bd8 Mon Sep 17 00:00:00 2001 From: kseysh Date: Mon, 9 Sep 2024 16:19:52 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat=20-=20#186=20admin=20api=EC=97=90?= =?UTF-8?q?=EC=84=9C=20challenge=EC=9D=98=20=EC=8B=9C=EC=9E=91=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=EB=A5=BC=20=EB=B3=80=EA=B2=BD=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/admin/service/AdminFacade.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/admin/service/AdminFacade.java b/src/main/java/sopt/org/hmh/domain/admin/service/AdminFacade.java index ac11f6f9..529ff438 100644 --- a/src/main/java/sopt/org/hmh/domain/admin/service/AdminFacade.java +++ b/src/main/java/sopt/org/hmh/domain/admin/service/AdminFacade.java @@ -12,6 +12,7 @@ import sopt.org.hmh.domain.admin.dto.response.AdminTokenResponse; import sopt.org.hmh.domain.admin.exception.AdminError; import sopt.org.hmh.domain.admin.exception.AdminException; +import sopt.org.hmh.domain.challenge.domain.Challenge; import sopt.org.hmh.domain.challenge.domain.exception.ChallengeError; import sopt.org.hmh.domain.challenge.domain.exception.ChallengeException; import sopt.org.hmh.domain.challenge.service.ChallengeService; @@ -65,15 +66,17 @@ public void changeUserInfo(AdminUserInfoRequest request) { @Transactional public void changeDailyChallengeInfo(AdminDailyChallengeRequest request) { Long currentChallengeId = userService.getCurrentChallengeIdByUserId(request.userId()); + Challenge challenge = challengeService.findByIdOrElseThrow(currentChallengeId); List statuses = request.statuses(); LocalDate challengeDate = request.startDate(); - validateStatusesPeriod(currentChallengeId, statuses); + validateStatusesPeriod(challenge, statuses); + challenge.changeStartDate(challengeDate); dailyChallengeService.changeInfoOfDailyChallenges(currentChallengeId, statuses, challengeDate); } - private void validateStatusesPeriod(Long challengeId, List statuses) { - Integer challengePeriod = challengeService.getChallengePeriod(challengeId); + private void validateStatusesPeriod(Challenge challenge, List statuses) { + Integer challengePeriod = challenge.getPeriod(); if (challengePeriod != statuses.size()) { throw new ChallengeException(ChallengeError.INVALID_PERIOD_NUMERIC); } From 373781034c9693c0d735b5a71f10076ccacd7ba3 Mon Sep 17 00:00:00 2001 From: kseysh Date: Mon, 9 Sep 2024 16:20:12 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor=20-=20#192=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/hmh/domain/challenge/service/ChallengeService.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java b/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java index 1a986df7..103fedcc 100644 --- a/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java +++ b/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java @@ -35,8 +35,4 @@ public List getCurrentChallengeAppByChallengeId(Long challengeId) public Challenge addChallenge(Challenge challenge) { return challengeRepository.save(challenge); } - - public Integer getChallengePeriod(Long challengeId) { - return this.findByIdOrElseThrow(challengeId).getPeriod(); - } }