-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from IT-Cotato/feat/scrap-etc-#49
[Feat] 스크랩 기능 추가 및 레벨별 진도율 조회 메소드 기능 수정
- Loading branch information
Showing
24 changed files
with
346 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/java/com/ripple/BE/learning/repository/conceptScrap/ConceptScrapRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package com.ripple.BE.learning.repository.conceptScrap; | ||
|
||
import com.ripple.BE.learning.domain.concept.ConceptScrap; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface ConceptScrapRepository | ||
extends JpaRepository<ConceptScrap, Long>, ConceptScrapRepositoryCustom { | ||
Boolean existsByConcept_ConceptIdAndUserId(Long conceptId, Long userId); | ||
|
||
Optional<ConceptScrap> findByConcept_ConceptIdAndUserId(Long conceptId, Long userId); | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/com/ripple/BE/learning/repository/quizScrap/QuizScrapRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package com.ripple.BE.learning.repository.quizScrap; | ||
|
||
import com.ripple.BE.learning.domain.quiz.QuizScrap; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface QuizScrapRepository | ||
extends JpaRepository<QuizScrap, Long>, QuizScrapRepositoryCustom { | ||
Boolean existsByQuizIdAndUserId(Long quizId, Long userId); | ||
|
||
Optional<QuizScrap> findByQuizIdAndUserId(Long quizId, Long userId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/com/ripple/BE/news/repository/newscrap/NewsScrapRepositoryCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.ripple.BE.news.repository.newscrap; | ||
|
||
import com.ripple.BE.news.domain.News; | ||
import java.util.List; | ||
|
||
public interface NewsScrapRepositoryCustom { | ||
|
||
List<News> findNewsScrappedByUser(Long userId); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/ripple/BE/news/repository/newscrap/NewsScrapRepositoryCustomImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.ripple.BE.news.repository.newscrap; | ||
|
||
import static com.ripple.BE.news.domain.QNews.*; | ||
import static com.ripple.BE.news.domain.QNewsScrap.*; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.ripple.BE.news.domain.News; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class NewsScrapRepositoryCustomImpl implements NewsScrapRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<News> findNewsScrappedByUser(Long userId) { | ||
return queryFactory | ||
.select(news) | ||
.from(newsScrap) | ||
.join(newsScrap.news, news) | ||
.where(newsScrap.user.id.eq(userId)) | ||
.orderBy(newsScrap.createdDate.desc()) | ||
.fetch(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/ripple/BE/term/repository/TermScrapRepositoryCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.ripple.BE.term.repository; | ||
|
||
import com.ripple.BE.term.domain.Term; | ||
import java.util.List; | ||
|
||
public interface TermScrapRepositoryCustom { | ||
|
||
List<Term> findTermsScrappedByUserAndInitial(Long userId, String initial); | ||
|
||
List<Term> findTermsScrappedByUserAndKeyword(Long userId, String keyword); | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/com/ripple/BE/term/repository/TermScrapRepositoryCustomImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.ripple.BE.term.repository; | ||
|
||
import static com.ripple.BE.term.domain.QTerm.*; | ||
import static com.ripple.BE.term.domain.QTermScrap.*; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.ripple.BE.term.domain.Term; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class TermScrapRepositoryCustomImpl implements TermScrapRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<Term> findTermsScrappedByUserAndInitial(Long userId, String initial) { | ||
if (initial == null || initial.trim().isEmpty()) { | ||
return queryFactory | ||
.select(term) | ||
.from(termScrap) | ||
.join(termScrap.term, term) | ||
.where(termScrap.user.id.eq(userId)) | ||
.orderBy(termScrap.createdDate.desc()) | ||
.fetch(); | ||
} | ||
|
||
return queryFactory | ||
.select(term) | ||
.from(termScrap) | ||
.join(termScrap.term, term) | ||
.where(termScrap.user.id.eq(userId).and(term.initial.startsWith(initial))) | ||
.orderBy(termScrap.createdDate.desc()) | ||
.fetch(); | ||
} | ||
|
||
@Override | ||
public List<Term> findTermsScrappedByUserAndKeyword(Long userId, String keyword) { | ||
if (keyword == null || keyword.trim().isEmpty()) { | ||
return queryFactory | ||
.select(term) | ||
.from(termScrap) | ||
.join(termScrap.term, term) | ||
.where(termScrap.user.id.eq(userId)) | ||
.orderBy(termScrap.createdDate.desc()) | ||
.fetch(); | ||
} | ||
|
||
return queryFactory | ||
.select(term) | ||
.from(termScrap) | ||
.join(termScrap.term, term) | ||
.where(termScrap.user.id.eq(userId).and(term.title.containsIgnoreCase(keyword))) | ||
.orderBy(termScrap.createdDate.desc()) | ||
.fetch(); | ||
} | ||
} |
Oops, something went wrong.