diff --git a/keewe-api/src/main/java/ccc/keeweapi/service/challenge/ChallengeApiService.java b/keewe-api/src/main/java/ccc/keeweapi/service/challenge/ChallengeApiService.java index e8959ee9..7248925d 100644 --- a/keewe-api/src/main/java/ccc/keeweapi/service/challenge/ChallengeApiService.java +++ b/keewe-api/src/main/java/ccc/keeweapi/service/challenge/ChallengeApiService.java @@ -29,6 +29,7 @@ import ccc.keewedomain.service.insight.query.InsightQueryDomainService; import ccc.keewedomain.service.user.query.ProfileQueryDomainService; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -45,6 +46,7 @@ @Service @RequiredArgsConstructor @Transactional(readOnly = true) +@Slf4j public class ChallengeApiService { private final ChallengeParticipateQueryDomainService challengeParticipateQueryDomainService; diff --git a/keewe-domain/src/main/java/ccc/keewedomain/persistence/domain/challenge/Challenge.java b/keewe-domain/src/main/java/ccc/keewedomain/persistence/domain/challenge/Challenge.java index 08e62eda..e1e0ccaf 100644 --- a/keewe-domain/src/main/java/ccc/keewedomain/persistence/domain/challenge/Challenge.java +++ b/keewe-domain/src/main/java/ccc/keewedomain/persistence/domain/challenge/Challenge.java @@ -55,11 +55,12 @@ public static Challenge of(User writer, String name, String interest, String int public ChallengeParticipation participate(User challenger, String myTopic, int insightPerWeek, int duration) { ChallengeParticipation participation = ChallengeParticipation.of( - challenger, - this, - myTopic, - insightPerWeek, - duration); + challenger, + this, + myTopic, + insightPerWeek, + duration + ); getParticipationList().add(participation); this.deleted = false; return participation; diff --git a/keewe-domain/src/main/java/ccc/keewedomain/service/challenge/command/ChallengeCommandDomainService.java b/keewe-domain/src/main/java/ccc/keewedomain/service/challenge/command/ChallengeCommandDomainService.java index e8a06733..6f6a54a2 100644 --- a/keewe-domain/src/main/java/ccc/keewedomain/service/challenge/command/ChallengeCommandDomainService.java +++ b/keewe-domain/src/main/java/ccc/keewedomain/service/challenge/command/ChallengeCommandDomainService.java @@ -10,6 +10,7 @@ import ccc.keewedomain.persistence.domain.challenge.Challenge; import ccc.keewedomain.persistence.domain.challenge.ChallengeParticipation; import ccc.keewedomain.persistence.domain.user.User; +import ccc.keewedomain.persistence.repository.challenge.ChallengeParticipationRepository; import ccc.keewedomain.persistence.repository.challenge.ChallengeRepository; import ccc.keewedomain.service.challenge.query.ChallengeParticipateQueryDomainService; import ccc.keewedomain.service.challenge.query.ChallengeQueryDomainService; @@ -19,15 +20,18 @@ import java.time.Period; import java.util.List; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; @RequiredArgsConstructor @Service +@Slf4j public class ChallengeCommandDomainService { private final ChallengeRepository challengeRepository; + private final ChallengeParticipationRepository challengeParticipationRepository; private final ChallengeQueryDomainService challengeQueryDomainService; private final ChallengeParticipateQueryDomainService challengeParticipateQueryDomainService; private final UserDomainService userDomainService; @@ -54,7 +58,11 @@ public ChallengeParticipation participate(ChallengeParticipateDto dto) { Assert.isTrue(!challenger.isDeleted(), "탈퇴한 사용자는 챌린지에 참여할 수 없어요."); this.exitCurrentChallengeIfExist(challenger); Challenge challenge = challengeQueryDomainService.getByIdOrElseThrow(dto.getChallengeId()); - return challenge.participate(challenger, dto.getMyTopic(), dto.getInsightPerWeek(), dto.getDuration()); + ChallengeParticipation participate = challenge.participate(challenger, dto.getMyTopic(), dto.getInsightPerWeek(), dto.getDuration()); + challengeRepository.save(challenge); + challengeParticipationRepository.save(participate); + log.info("[ChallengeCommandDomainService] 챌린지 참여 완료 - userId({}), challengeId({})", challenger.getId(), challenge.getId()); + return participate; }); }