-
Notifications
You must be signed in to change notification settings - Fork 28
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 #1550 from woowacourse/feat/1540-article-filtering
feat: 아티클 필터링 기능 추가
- Loading branch information
Showing
7 changed files
with
133 additions
and
39 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
17 changes: 17 additions & 0 deletions
17
backend/src/main/java/wooteco/prolog/article/domain/ArticleFilterType.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,17 @@ | ||
package wooteco.prolog.article.domain; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum ArticleFilterType { | ||
ALL(""), | ||
ANDROID("안드로이드"), | ||
BACKEND("백엔드"), | ||
FRONTEND("프론트엔드"); | ||
|
||
private final String groupName; | ||
|
||
ArticleFilterType(String groupName) { | ||
this.groupName = groupName; | ||
} | ||
} |
18 changes: 16 additions & 2 deletions
18
backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.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,16 +1,30 @@ | ||
package wooteco.prolog.article.domain.repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import wooteco.prolog.article.domain.Article; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface ArticleRepository extends JpaRepository<Article, Long> { | ||
|
||
List<Article> findAllByOrderByCreatedAtDesc(); | ||
|
||
@Query("select a from Article a join fetch a.articleBookmarks where a.id = :id") | ||
Optional<Article> findFetchById(@Param("id") final Long id); | ||
|
||
@Query("SELECT DISTINCT a FROM Article a " + | ||
"JOIN GroupMember gm ON a.member.id = gm.member.id " + | ||
"JOIN gm.group mg " + | ||
"WHERE mg.name LIKE %:course") | ||
List<Article> findArticlesByCourse(@Param("course") String course); | ||
|
||
@Query("SELECT DISTINCT a FROM Article a " + | ||
"JOIN GroupMember gm ON a.member.id = gm.member.id " + | ||
"JOIN gm.group mg " + | ||
"JOIN a.articleBookmarks.articleBookmarks ab " + | ||
"WHERE mg.name LIKE %:course AND ab.memberId = :memberId") | ||
List<Article> findArticlesByCourseAndMember(@Param("course") String course, @Param("memberId") Long memberId); | ||
} |
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