-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#100 개인화 페이지에서 질문글과 답변글 목록을 볼 수 있는 기능 추가함.
displayName을 nickName으로 사용하도록 수정함.
- Loading branch information
Showing
25 changed files
with
445 additions
and
333 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,51 @@ | ||
package net.slipp.domain.qna; | ||
|
||
import static org.springframework.data.jpa.domain.Specifications.*; | ||
|
||
import javax.persistence.criteria.CriteriaBuilder; | ||
import javax.persistence.criteria.CriteriaQuery; | ||
import javax.persistence.criteria.Predicate; | ||
import javax.persistence.criteria.Root; | ||
|
||
import net.slipp.domain.user.SocialUser; | ||
|
||
import org.springframework.data.jpa.domain.Specification; | ||
import org.springframework.data.jpa.domain.Specifications; | ||
|
||
public class QnaSpecifications { | ||
public static Specification<Question> equalsIsDelete(final boolean isDeleted) { | ||
public static Specification<Question> equalsIsDeleteToQuestion(final boolean isDeleted) { | ||
return new Specification<Question>() { | ||
@Override | ||
public Predicate toPredicate(Root<Question> root, CriteriaQuery<?> query, CriteriaBuilder cb) { | ||
return cb.equal(root.get(Question_.deleted), isDeleted); | ||
} | ||
}; | ||
} | ||
|
||
private static Specification<Question> equalsWriterIdToQuestion(final SocialUser writer) { | ||
return new Specification<Question>() { | ||
@Override | ||
public Predicate toPredicate(Root<Question> root, CriteriaQuery<?> query, CriteriaBuilder cb) { | ||
return cb.equal(root.get(Question_.writer), writer); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
}; | ||
} | ||
|
||
public static Specification<Question> findQuestions(final SocialUser writer, final boolean isDeleted) { | ||
if (writer == null) { | ||
return equalsIsDeleteToQuestion(isDeleted); | ||
} | ||
|
||
Specifications<Question> specs = where(equalsWriterIdToQuestion(writer)); | ||
return specs.and(equalsIsDeleteToQuestion(isDeleted)); | ||
} | ||
|
||
public static Specification<Answer> equalsWriterIdToAnswer(final SocialUser writer) { | ||
return new Specification<Answer>() { | ||
@Override | ||
public Predicate toPredicate(Root<Answer> root, CriteriaQuery<?> query, CriteriaBuilder cb) { | ||
return cb.equal(root.get(Answer_.writer), writer); | ||
} | ||
}; | ||
} | ||
} |
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
Oops, something went wrong.
Question_ 욘석은 generate 되는 놈인가?
찾아봐도 없네요?