diff --git a/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/application/ChallengeService.java b/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/application/ChallengeService.java index 1eb678d6..a78a2d56 100644 --- a/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/application/ChallengeService.java +++ b/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/application/ChallengeService.java @@ -83,8 +83,10 @@ public ChallengeInfoResDto update(String email, Long challengeId, ChallengeSaveR imageUrl = s3Service.uploadChallengeImage(representImage); } - challenge.update(challengeSaveReqDto.title(), + challenge.update( + challengeSaveReqDto.title(), challengeSaveReqDto.contents(), + challengeSaveReqDto.cycle(), challengeSaveReqDto.cycleDetails(), challengeSaveReqDto.endDate(), challengeSaveReqDto.blockName(), diff --git a/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/domain/Challenge.java b/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/domain/Challenge.java index fad06a9d..649e9c1e 100644 --- a/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/domain/Challenge.java +++ b/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/domain/Challenge.java @@ -44,6 +44,7 @@ public class Challenge extends BaseEntity { @Enumerated(value = EnumType.STRING) private Category category; + @Enumerated(value = EnumType.STRING) private Cycle cycle; @Column(name = "cycle_details") @@ -95,14 +96,16 @@ private Challenge(Status status, this.blockName = blockName; } - public void update(String updateTitle, String updateContents, List updateCycleDetails, + public void update(String updateTitle, String updateContents, Cycle updateCycle, + List updateCycleDetails, LocalDate updateEndDate, String updateBlockName, String updateRepresentImage) { validateCycleDetails(cycle, cycleDetails); - if (hasChanges(updateTitle, updateContents, updateCycleDetails, updateEndDate, + if (hasChanges(updateTitle, updateContents, updateCycle, updateCycleDetails, updateEndDate, updateBlockName)) { this.title = updateTitle; this.contents = updateContents; + this.cycle = updateCycle; this.cycleDetails = updateCycleDetails; this.endDate = updateEndDate; this.blockName = updateBlockName; @@ -131,10 +134,12 @@ private void validateCycleDetailMatch(Cycle cycle, CycleDetail cycleDetail) { } } - private boolean hasChanges(String updateTitle, String updateContents, List updateCycleDetails, + private boolean hasChanges(String updateTitle, String updateContents, Cycle updateCycle, + List updateCycleDetails, LocalDate updateEndDate, String blockName) { return !this.title.equals(updateTitle) || !this.contents.equals(updateContents) || + !this.cycle.equals(updateCycle) || !this.cycleDetails.equals(updateCycleDetails) || !this.endDate.equals(updateEndDate) || !this.blockName.equals(blockName); diff --git a/src/test/java/shop/kkeujeok/kkeujeokbackend/challenge/domain/ChallengeTest.java b/src/test/java/shop/kkeujeok/kkeujeokbackend/challenge/domain/ChallengeTest.java index 7f4e93b3..1184abee 100644 --- a/src/test/java/shop/kkeujeok/kkeujeokbackend/challenge/domain/ChallengeTest.java +++ b/src/test/java/shop/kkeujeok/kkeujeokbackend/challenge/domain/ChallengeTest.java @@ -57,7 +57,7 @@ void setUp() { String updateBlockName = "수정된 블록 이름"; // when - challenge.update(updateTitle, updateContents, updateCycleDetails, updateEndDate, updateBlockName, + challenge.update(updateTitle, updateContents, updateCycle, updateCycleDetails, updateEndDate, updateBlockName, updateRepresentImage); // then @@ -80,7 +80,7 @@ void setUp() { String updateTitle = "수정된 제목"; // when - challenge.update(updateTitle, challenge.getContents(), challenge.getCycleDetails(), + challenge.update(updateTitle, challenge.getContents(), challenge.getCycle(), challenge.getCycleDetails(), challenge.getEndDate(), challenge.getBlockName(), imageUrl); // then @@ -101,7 +101,7 @@ void setUp() { String updateContents = "수정된 내용"; // when - challenge.update(challenge.getTitle(), updateContents, challenge.getCycleDetails(), + challenge.update(challenge.getTitle(), updateContents, challenge.getCycle(), challenge.getCycleDetails(), challenge.getEndDate(), challenge.getBlockName(), imageUrl); // then @@ -121,7 +121,8 @@ void setUp() { LocalDate updateEndDate = LocalDate.now().plusDays(40); // when - challenge.update(challenge.getTitle(), challenge.getContents(), challenge.getCycleDetails(), + challenge.update(challenge.getTitle(), challenge.getContents(), challenge.getCycle(), + challenge.getCycleDetails(), updateEndDate, challenge.getBlockName(), imageUrl); // then