feat : Get List Article Implement.?
This commit is contained in:
@@ -10,8 +10,13 @@ import java.util.List;
|
||||
|
||||
public interface ArticleRepository extends JpaRepository<Article,Long> {
|
||||
|
||||
|
||||
@EntityGraph(attributePaths = "tags")
|
||||
@EntityGraph(attributePaths = "tagList")
|
||||
@Query("SELECT a FROM Article a JOIN Tag t ON a.id = t.article.id")
|
||||
List<Article> findByTag(String tag, Pageable pageable);
|
||||
|
||||
@Query("SELECT a FROM Article a WHERE a.author.username = :author")
|
||||
List<Article> findByAuthorName(String author, Pageable pageable);
|
||||
|
||||
@Query("SELECT a FROM Article a LEFT JOIN Favorite f ON f.article.id = a.id WHERE f.user.username =:username")
|
||||
List<Article> findByFavoritedUser(String username, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,14 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
if (articleParam.getTag() != null) {
|
||||
articles = articleRepository.findByTag(articleParam.getTag(), pageable);
|
||||
}
|
||||
System.out.println(articles.size());
|
||||
|
||||
if(articleParam.getAuthor() != null){
|
||||
articles = articleRepository.findByAuthorName(articleParam.getAuthor(), pageable);
|
||||
}
|
||||
|
||||
if(articleParam.getFavorited() != null){
|
||||
articles = articleRepository.findByFavoritedUser(articleParam.getFavorited(), pageable);
|
||||
}
|
||||
|
||||
return articles.stream().map(article -> {
|
||||
return convertDtoWithUser(article, userAuth);
|
||||
|
||||
Reference in New Issue
Block a user