-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
게시판 api 만들기 - 구현까지 완료
- Loading branch information
Showing
5 changed files
with
74 additions
and
2 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
21 changes: 20 additions & 1 deletion
21
src/main/java/com/fastcampus/projectboard/repository/ArticleCommentRepository.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,9 +1,28 @@ | ||
package com.fastcampus.projectboard.repository; | ||
|
||
import com.fastcampus.projectboard.domain.ArticleComment; | ||
import com.fastcampus.projectboard.domain.QArticleComment; | ||
import com.querydsl.core.types.dsl.DateTimeExpression; | ||
import com.querydsl.core.types.dsl.StringExpression; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.querydsl.QuerydslPredicateExecutor; | ||
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; | ||
import org.springframework.data.querydsl.binding.QuerydslBindings; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
@RepositoryRestResource | ||
public interface ArticleCommentRepository extends JpaRepository<ArticleComment, Long> { | ||
public interface ArticleCommentRepository extends | ||
JpaRepository<ArticleComment, Long>, | ||
QuerydslPredicateExecutor<ArticleComment>, | ||
QuerydslBinderCustomizer<QArticleComment> { | ||
|
||
@Override | ||
default void customize(QuerydslBindings bindings, QArticleComment root) { | ||
bindings.excludeUnlistedProperties(true); | ||
bindings.including(root.content, root.createdAt, root.createdBy); | ||
bindings.bind(root.content).first(StringExpression::containsIgnoreCase); | ||
bindings.bind(root.createdAt).first(DateTimeExpression::eq); | ||
bindings.bind(root.createdBy).first(StringExpression::containsIgnoreCase); | ||
} | ||
|
||
} |
23 changes: 22 additions & 1 deletion
23
src/main/java/com/fastcampus/projectboard/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,9 +1,30 @@ | ||
package com.fastcampus.projectboard.repository; | ||
|
||
import com.fastcampus.projectboard.domain.Article; | ||
import com.fastcampus.projectboard.domain.QArticle; | ||
import com.querydsl.core.types.dsl.DateTimeExpression; | ||
import com.querydsl.core.types.dsl.StringExpression; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.querydsl.QuerydslPredicateExecutor; | ||
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; | ||
import org.springframework.data.querydsl.binding.QuerydslBindings; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
@RepositoryRestResource | ||
public interface ArticleRepository extends JpaRepository<Article, Long> { | ||
public interface ArticleRepository extends | ||
JpaRepository<Article, Long>, | ||
QuerydslPredicateExecutor<Article>, | ||
QuerydslBinderCustomizer<QArticle> { | ||
|
||
@Override | ||
default void customize(QuerydslBindings bindings, QArticle root) { | ||
bindings.excludeUnlistedProperties(true); | ||
bindings.including(root.title, root.content, root.hashtag, root.createdAt, root.createdBy); | ||
bindings.bind(root.title).first(StringExpression::containsIgnoreCase); | ||
bindings.bind(root.content).first(StringExpression::containsIgnoreCase); | ||
bindings.bind(root.hashtag).first(StringExpression::containsIgnoreCase); | ||
bindings.bind(root.createdAt).first(DateTimeExpression::eq); | ||
bindings.bind(root.createdBy).first(StringExpression::containsIgnoreCase); | ||
} | ||
|
||
} |
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