|
1 | 1 | package com.davcatch.devcatch.repository.article; |
2 | 2 |
|
3 | | -import java.util.List; |
4 | | -import java.util.Optional; |
5 | 3 | import java.util.Set; |
6 | 4 |
|
7 | | -import org.springframework.data.domain.Page; |
8 | | -import org.springframework.data.domain.Pageable; |
9 | | -import org.springframework.data.jpa.repository.EntityGraph; |
10 | 5 | import org.springframework.data.jpa.repository.JpaRepository; |
11 | 6 | import org.springframework.data.jpa.repository.Query; |
12 | 7 |
|
13 | 8 | import com.davcatch.devcatch.domain.article.Article; |
14 | | -import com.davcatch.devcatch.domain.tag.TagType; |
15 | 9 |
|
16 | | -public interface ArticleRepository extends JpaRepository<Article, Long> { |
17 | | - |
18 | | - @Query(value = "select * from article a " |
19 | | - + "where source_id = :sourceId " |
20 | | - + "order by published_at desc " |
21 | | - + "limit 1 ", nativeQuery = true) |
22 | | - Optional<Article> findLastPublishedArticle(Long sourceId); |
23 | | - |
24 | | - @EntityGraph(attributePaths = {"source", "articleTags", "articleTags.tag"}) |
25 | | - @Query("select a from Article a " |
26 | | - + "where a.isSent = false ") |
27 | | - List<Article> findSendArticles(); |
28 | | - |
29 | | - @EntityGraph(attributePaths = {"source"}) |
30 | | - @Query("select a from Article a " |
31 | | - + "order by a.publishedAt desc") |
32 | | - List<Article> findNewArticlesTOP6(Pageable pageable); |
33 | | - |
34 | | - @EntityGraph(attributePaths = {"source"}) |
35 | | - @Query("select distinct a from Article a " |
36 | | - + "left join a.articleTags at " |
37 | | - + "left join at.tag t " |
38 | | - + "where (:keyword is null or lower(a.title) like lower(concat(:keyword, '%'))) " |
39 | | - + "and (:tag is null or t.tagType = :tag) " |
40 | | - + "order by a.publishedAt desc") |
41 | | - Page<Article> findArticlesList(Pageable pageable, String keyword, TagType tag); |
42 | | - |
43 | | - @Query("select a from Article a " |
44 | | - + "order by a.publishedAt desc") |
45 | | - List<Article> findDashboardList(Pageable pageable); |
| 10 | +public interface ArticleRepository extends JpaRepository<Article, Long>, ArticleRepositoryCustom { |
46 | 11 |
|
47 | 12 | @Query("select a.link from Article a where a.link in :links") |
48 | 13 | Set<String> findExistsLinks(Set<String> links); |
49 | 14 |
|
50 | 15 | @Query("select count(a.id) from Article a ") |
51 | 16 | int findTotalArticleSize(); |
52 | | - |
53 | | - @EntityGraph(attributePaths = {"source"}) |
54 | | - @Query("select a from Article a where a.id = :articleId") |
55 | | - Optional<Article> findArticleDetail(Long articleId); |
56 | | - |
57 | | - @EntityGraph(attributePaths = {"source"}) |
58 | | - @Query("select distinct a from Article a " |
59 | | - + "join a.articleTags at " |
60 | | - + "join at.tag t " |
61 | | - + "where a.id != :articleId " |
62 | | - + "and t.tagType in :tagTypes " |
63 | | - + "order by a.publishedAt desc ") |
64 | | - List<Article> findRelatedArticles(Long articleId, List<TagType> tagTypes, Pageable pageable); |
65 | 17 | } |
0 commit comments