Skip to content

Commit

Permalink
feat: Add CommentRepositoryImpl (#2)
Browse files Browse the repository at this point in the history
Co-authored-by: nusuy <[email protected]>
Co-authored-by: Queue-ri <[email protected]>
Co-authored-by: hyojeongchoi <[email protected]>
  • Loading branch information
4 people committed Dec 3, 2023
1 parent 789ccd1 commit 193a50e
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.hamahama.pupmory.domain.memorial;

import com.hamahama.pupmory.domain.user.ServiceUser;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@RequiredArgsConstructor
public class CommentRepositoryImpl implements CommentRepositoryCustom {

private final JPAQueryFactory queryFactory;

public List<Comment> findAllByUser(ServiceUser user) {
QComment comment = QComment.comment;
QPost post = QPost.post;

return queryFactory.selectFrom(comment)
.leftJoin(comment.post, post)
.fetchJoin()
.where(comment.user.eq(user))
.fetch();
}
}

0 comments on commit 193a50e

Please sign in to comment.