diff --git a/src/main/java/com/dnd/runus/domain/challenge/ChallengeRepository.java b/src/main/java/com/dnd/runus/domain/challenge/ChallengeRepository.java index fe090d30..07f870db 100644 --- a/src/main/java/com/dnd/runus/domain/challenge/ChallengeRepository.java +++ b/src/main/java/com/dnd/runus/domain/challenge/ChallengeRepository.java @@ -7,4 +7,6 @@ public interface ChallengeRepository { List findAllActiveChallengesWithConditions(); Optional findChallengeWithConditionsByChallengeId(long challengeId); + + Optional findById(long challengeId); } diff --git a/src/main/java/com/dnd/runus/infrastructure/persistence/domain/challenge/ChallengeRepositoryImpl.java b/src/main/java/com/dnd/runus/infrastructure/persistence/domain/challenge/ChallengeRepositoryImpl.java index 9d5880b4..bb8b0045 100644 --- a/src/main/java/com/dnd/runus/infrastructure/persistence/domain/challenge/ChallengeRepositoryImpl.java +++ b/src/main/java/com/dnd/runus/infrastructure/persistence/domain/challenge/ChallengeRepositoryImpl.java @@ -1,8 +1,11 @@ package com.dnd.runus.infrastructure.persistence.domain.challenge; +import com.dnd.runus.domain.challenge.Challenge; import com.dnd.runus.domain.challenge.ChallengeRepository; import com.dnd.runus.domain.challenge.ChallengeWithCondition; import com.dnd.runus.infrastructure.persistence.jooq.challenge.JooqChallengeRepository; +import com.dnd.runus.infrastructure.persistence.jpa.challenge.JpaChallengeRepository; +import com.dnd.runus.infrastructure.persistence.jpa.challenge.entity.ChallengeEntity; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; @@ -14,6 +17,7 @@ public class ChallengeRepositoryImpl implements ChallengeRepository { private final JooqChallengeRepository jooqChallengeRepository; + private final JpaChallengeRepository jpaChallengeRepository; @Override public List findAllActiveChallengesWithConditions() { @@ -24,4 +28,9 @@ public List findAllActiveChallengesWithConditions() { public Optional findChallengeWithConditionsByChallengeId(long challengeId) { return Optional.ofNullable(jooqChallengeRepository.findChallengeWithConditionsBy(challengeId)); } + + @Override + public Optional findById(long challengeId) { + return jpaChallengeRepository.findById(challengeId).map(ChallengeEntity::toDomain); + } } diff --git a/src/main/java/com/dnd/runus/infrastructure/persistence/jpa/challenge/JpaChallengeRepository.java b/src/main/java/com/dnd/runus/infrastructure/persistence/jpa/challenge/JpaChallengeRepository.java new file mode 100644 index 00000000..736c2acf --- /dev/null +++ b/src/main/java/com/dnd/runus/infrastructure/persistence/jpa/challenge/JpaChallengeRepository.java @@ -0,0 +1,6 @@ +package com.dnd.runus.infrastructure.persistence.jpa.challenge; + +import com.dnd.runus.infrastructure.persistence.jpa.challenge.entity.ChallengeEntity; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface JpaChallengeRepository extends JpaRepository {}