Skip to content

Commit

Permalink
Feat: 러닝 데이터 저장 시, 챌린지 모드일 경우, 해당 챌린지가 존재하는지 확인하는 확인할 수 있게 findById 리…
Browse files Browse the repository at this point in the history
…파지토리 추가 (#322)
  • Loading branch information
hee9841 authored Dec 20, 2024
1 parent 8f73cf8 commit 7010eb6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public interface ChallengeRepository {
List<ChallengeWithCondition> findAllActiveChallengesWithConditions();

Optional<ChallengeWithCondition> findChallengeWithConditionsByChallengeId(long challengeId);

Optional<Challenge> findById(long challengeId);
}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -14,6 +17,7 @@
public class ChallengeRepositoryImpl implements ChallengeRepository {

private final JooqChallengeRepository jooqChallengeRepository;
private final JpaChallengeRepository jpaChallengeRepository;

@Override
public List<ChallengeWithCondition> findAllActiveChallengesWithConditions() {
Expand All @@ -24,4 +28,9 @@ public List<ChallengeWithCondition> findAllActiveChallengesWithConditions() {
public Optional<ChallengeWithCondition> findChallengeWithConditionsByChallengeId(long challengeId) {
return Optional.ofNullable(jooqChallengeRepository.findChallengeWithConditionsBy(challengeId));
}

@Override
public Optional<Challenge> findById(long challengeId) {
return jpaChallengeRepository.findById(challengeId).map(ChallengeEntity::toDomain);
}
}
Original file line number Diff line number Diff line change
@@ -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<ChallengeEntity, Long> {}

0 comments on commit 7010eb6

Please sign in to comment.